Files
holos/hack/gendoc
Jeff McCune e3c3ab6799 api: establish core v1alpha3 for quickstart
Switch holos to use v1alpha3 so we can establish more of the CUE
structures in the documented API using Go structs.
2024-09-06 10:59:45 -07:00

18 lines
677 B
Bash
Executable File

#! /bin/bash
#
set -euo pipefail
# Generate the documentation for the package the calls go:generate
package="$(git rev-parse --show-prefix)"
cd "$(git rev-parse --show-toplevel)"
mkdir -p "doc/md/$(dirname "${package}")"
gomarkdoc --output "doc/md/${package%/}.md" "./${package}"
# Fix heading anchors by making them explicit
# Refer to https://docusaurus.io/docs/markdown-features/toc#heading-ids
stamp=$RANDOM
# sed 's/^## type /## /' "doc/md/${package%/}.md" > "doc/md/${package%/}.md.${stamp}"
sed -E 's/## type ([A-Za-z0-9_]+)/## type \1 {#\1}/' "doc/md/${package%/}.md" > "doc/md/${package%/}.md.${stamp}"
mv "doc/md/${package%/}.md.${stamp}" "doc/md/${package%/}.md"