mirror of
https://github.com/holos-run/holos.git
synced 2026-03-20 17:25:01 +00:00
The api references are in reverse order and don't have good descriptions in the index listings. This patch adds front matter to each generated document to order them correctly and add a nice description.
22 lines
652 B
Bash
Executable File
22 lines
652 B
Bash
Executable File
#! /bin/bash
|
|
#
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
finish() {
|
|
rm -rf "$tmpdir"
|
|
}
|
|
trap finish EXIT
|
|
|
|
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
|
|
sed -E 's/## type ([A-Za-z0-9_]+)/## type \1 {#\1}/' "doc/md/${package%/}.md" > "${tmpdir}/doc.md"
|
|
cat "./${package%%/}/header.yaml" "${tmpdir}/doc.md" > "doc/md/${package%/}.md"
|