#! /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"