Skip to content

Commit 3824ed9

Browse files
authored
docs: docgen proto with protoc-gen-doc (#557)
fixes #555 utilizes https://github.com/pseudomuto/protoc-gen-doc to generate the needed docs ready to upload to the homepage. > [!NOTE] > did not setup a proper template, yet. used the default one for now, so we can track template-related changes in future PRs > But the template has been foreseen, it is expected to go into the folder `docgen/proto/template`. > See template docs here: <https://github.com/pseudomuto/protoc-gen-doc/wiki/Custom-Templates> CI run: https://github.com/CycloneDX/specification/actions/runs/12536710058/job/34960006706 CI result: https://github.com/CycloneDX/specification/actions/runs/12536710058/artifacts/2369477602 structure: ```text docgen/proto/docs ├── 1.3 │   └── index.html ├── 1.4 │   └── index.html ├── 1.5 │   └── index.html └── 1.6 └── index.html ``` ---- might rework the resutling structure in regards to #568 --------- Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
1 parent 1f42698 commit 3824ed9

File tree

4 files changed

+503
-0
lines changed

4 files changed

+503
-0
lines changed

.github/workflows/build_docs.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,21 @@ jobs:
5959
name: JSON-Schema-documentation
6060
path: docgen/json/docs
6161
if-no-files-found: error
62+
docs_proto:
63+
runs-on: ubuntu-latest
64+
defaults:
65+
run:
66+
working-directory: docgen/proto
67+
steps:
68+
- name: Checkout
69+
# see https://github.com/actions/checkout
70+
uses: actions/checkout@v4
71+
- name: Generate Schema documentation
72+
run: ./gen.sh
73+
- name: Archive Schema documentation
74+
# https://github.com/actions/upload-artifact
75+
uses: actions/upload-artifact@v4
76+
with:
77+
name: PROTO-Schema-documentation
78+
path: docgen/proto/docs
79+
if-no-files-found: error

docgen/proto/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/docs/

docgen/proto/gen.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
set -eu
3+
4+
THIS_PATH="$(realpath "$(dirname "$0")")"
5+
SCHEMA_PATH="$(realpath "$THIS_PATH/../../schema")"
6+
DOCS_PATH="$THIS_PATH/docs"
7+
TEMPLATES_PATH="$THIS_PATH/templates"
8+
9+
PROTOC_GEN_DOC_VERSION='1.5.1'
10+
11+
# --
12+
13+
rm -f -R "$DOCS_PATH"
14+
15+
generate () {
16+
version="$1"
17+
title="CycloneDX v$version Proto Reference"
18+
echo "Generating: $title"
19+
20+
OUT_DIR="$DOCS_PATH/$version/proto/"
21+
mkdir -p "$OUT_DIR"
22+
23+
## docs: https://github.com/pseudomuto/protoc-gen-doc
24+
docker run --rm \
25+
-v "${OUT_DIR}:/out" \
26+
-v "${SCHEMA_PATH}:/protos:ro" \
27+
-v "${TEMPLATES_PATH}:/templates:ro" \
28+
"pseudomuto/protoc-gen-doc:${PROTOC_GEN_DOC_VERSION}" \
29+
--doc_opt=/templates/html.tmpl,index.html \
30+
"bom-${version}.proto"
31+
32+
# fix file permissions
33+
docker run --rm \
34+
-v "${OUT_DIR}:/out" \
35+
--entrypoint chown \
36+
"pseudomuto/protoc-gen-doc:${PROTOC_GEN_DOC_VERSION}" \
37+
"$(id -g):$(id -u)" -R /out
38+
}
39+
40+
generate 1.3
41+
generate 1.4
42+
generate 1.5
43+
generate 1.6

0 commit comments

Comments
 (0)