Skip to content

Commit

Permalink
Auto-generation of API CRD documentation
Browse files Browse the repository at this point in the history
Added the command in make docs now so when make docs command is ran, the API CRD documentation is also created automatically with "API.md" name, created a folder called template which contains all the necessary files (template files, place-holder go file, json file and executable binary file)
which are used/needed in the creating of the API CRD documentation

Signed-off-by: Kartik-Garg <[email protected]>
  • Loading branch information
Kartik-Garg committed Nov 8, 2022
1 parent 31c0985 commit 3b19d48
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -1359,5 +1359,5 @@ map[string]interface{}
<hr/>
<p><em>
Generated with <code>gen-crd-api-reference-docs</code>
on git commit <code>10c67243</code>.
on git commit <code>31c09856</code>.
</em></p>
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ codegen:
DOCS_CMD = "cd docs && make clean && \
doc8 --max-line-length 90 --ignore D000 . && \
make spelling && make html \
"

"
docs:
ifeq ($(DOCKER_BUILD),"true")
@echo "running DOCS_CMD in the containerized build environment"
Expand All @@ -204,10 +204,15 @@ ifeq ($(DOCKER_BUILD),"true")
-w /repo \
$(DOCS_BUILD_IMAGE) \
/bin/bash -c $(DOCS_CMD)
@$(MAKE) run CMD='-c "./template/gen-crd-api-reference-docs -config template/example-config.json -api-dir ./pkg/apis/cr/v1alpha1 -out-file API.md"'
else
@/bin/bash -c $(DOCS_CMD)
@$(MAKE) run CMD='-c "./template/gen-crd-api-reference-docs -config template/example-config.json -api-dir ./pkg/apis/cr/v1alpha1 -out-file API.md"'
endif

# docs2:
# @$(MAKE) run CMD='-c "./template/gen-crd-api-reference-docs -config template/example-config.json -api-dir ./pkg/apis/cr/v1alpha1 -out-file APIs.md"'

build-dirs:
@mkdir -p bin/$(ARCH)
@mkdir -p .go/src/$(PKG) .go/pkg .go/bin .go/std/$(ARCH)
Expand Down
28 changes: 28 additions & 0 deletions template/example-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"hideMemberFields": [
"TypeMeta"
],
"hideTypePatterns": [
"ParseError$",
"List$"
],
"externalPackages": [
{
"typeMatchPrefix": "^k8s\\.io/apimachinery/pkg/apis/meta/v1\\.Duration$",
"docsURLTemplate": "https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#Duration"
},
{
"typeMatchPrefix": "^k8s\\.io/(api|apimachinery/pkg/apis)/",
"docsURLTemplate": "https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#{{lower .TypeIdentifier}}-{{arrIndex .PackageSegments -1}}-{{arrIndex .PackageSegments -2}}"
},
{
"typeMatchPrefix": "^github\\.com/knative/pkg/apis/duck/",
"docsURLTemplate": "https://pkg.go.dev/github.com/knative/pkg/apis/duck/{{arrIndex .PackageSegments -1}}#{{.TypeIdentifier}}"
}
],
"typeDisplayNamePrefixOverrides": {
"k8s.io/api/": "Kubernetes ",
"k8s.io/apimachinery/pkg/apis/": "Kubernetes "
},
"markdownDisabled": false
}
Binary file added template/gen-crd-api-reference-docs
Binary file not shown.

0 comments on commit 3b19d48

Please sign in to comment.