Skip to content

Commit 65ab1bc

Browse files
committed
Generate a gomarkdoc API reference in the docs site build (P1b)
docs.yml now installs gomarkdoc and runs it over the packages meant for external reuse (core/protocol/..., core/service/..., client/..., plus the shared core/{csnet,binaryprimitives,config,fs,encoding,link, buf} packages — adapter/* and cmd/* excluded as internal composition/ CLI layer), writing one page per package into site/content/reference/ with a minimal injected Hugo frontmatter. Also widen the workflow's trigger paths to those source trees so the reference regenerates when they change, and point Set up Go at the root go.mod (was site/go.mod) so `go list`/`go install` run against the real module. The generated pages aren't committed (gitignored, apart from the hand-written _index.md landing page) — verified locally end-to-end: ran the exact script, then `hugo --minify --gc` against the real repo content, and confirmed the reference pages render with correct per-package titles.
1 parent d17632f commit 65ab1bc

3 files changed

Lines changed: 68 additions & 1 deletion

File tree

.github/workflows/docs.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ on:
99
- "spec/**"
1010
- "ARCHITECTURE.md"
1111
- "site/**"
12+
- "core/protocol/**"
13+
- "core/service/**"
14+
- "client/**"
15+
- "core/csnet/**"
16+
- "core/binaryprimitives/**"
17+
- "core/config/**"
18+
- "core/fs/**"
19+
- "core/encoding/**"
20+
- "core/link/**"
21+
- "core/buf/**"
1222
- ".github/workflows/docs.yml"
1323
workflow_dispatch: {}
1424

@@ -32,7 +42,35 @@ jobs:
3242
- name: Set up Go
3343
uses: actions/setup-go@v6
3444
with:
35-
go-version-file: site/go.mod
45+
go-version-file: go.mod
46+
47+
- name: Generate API reference (gomarkdoc)
48+
run: |
49+
set -euo pipefail
50+
go install github.com/princjef/gomarkdoc/cmd/gomarkdoc@v1.1.0
51+
52+
# Packages meant for external reuse: protocol codecs, file/network
53+
# services, the client SDK, and the shared support packages.
54+
# adapter/* and cmd/* are ClassicStack's own composition/CLI layer,
55+
# not reuse surface, so they're excluded.
56+
MODULE=$(go list -m)
57+
PKGS=$(go list -tags all \
58+
./core/protocol/... ./core/service/... ./client/... \
59+
./core/csnet/... ./core/binaryprimitives/... ./core/config/... \
60+
./core/fs/... ./core/encoding/... ./core/link/... ./core/buf/... \
61+
| sed "s|^$MODULE/|./|")
62+
63+
mkdir -p site/content/reference
64+
gomarkdoc --tags all -o 'site/content/reference/{{.Dir}}.md' $PKGS
65+
66+
# gomarkdoc's output carries no Hugo frontmatter; add a minimal one
67+
# per page, titled from the "# <pkg>" heading gomarkdoc already wrote.
68+
find site/content/reference -name '*.md' ! -name '_index.md' -print0 |
69+
while IFS= read -r -d '' f; do
70+
title=$(grep -m1 '^# ' "$f" | sed 's/^# //')
71+
{ printf -- '---\ntitle: "%s"\n---\n\n' "$title"; cat "$f"; } > "$f.tmp"
72+
mv "$f.tmp" "$f"
73+
done
3674
3775
- name: Set up Hugo
3876
uses: peaceiris/actions-hugo@v3

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ vendor/
4949
go.work
5050
go.work.sum
5151

52+
# Hugo build output and the gomarkdoc-generated API reference pages (docs.yml
53+
# regenerates both on every build; only site/content/reference/_index.md is
54+
# hand-written and tracked).
55+
/public/
56+
/site/content/reference/*
57+
!/site/content/reference/_index.md
58+
5259
# env file
5360
.env
5461

site/content/reference/_index.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: "API Reference"
3+
weight: 12
4+
---
5+
6+
# API Reference
7+
8+
Generated from Go doc comments (via [gomarkdoc](https://github.com/princjef/gomarkdoc)) for the
9+
packages meant for external reuse: the protocol codecs (`core/protocol/...`), the file/network
10+
services (`core/service/...`), the client SDK (`client/...`), and the shared support packages
11+
(`core/csnet`, `core/binaryprimitives`, `core/config`, `core/fs`, `core/encoding`, `core/link`,
12+
`core/buf`). See [§5](../docs/manual/#5-extending-classicstack--the-client-sdk) and
13+
[§6](../docs/manual/#6-extending-classicstack--the-server-sdk) of the manual for the guided
14+
walkthroughs these pages are the reference companion to.
15+
16+
`adapter/*` and `cmd/*` are excluded — they are ClassicStack's own composition/CLI layer, not
17+
reuse surface for an external importer.
18+
19+
This section is regenerated on every build; the pages under it are not stored in the repository.
20+
A thin or missing doc comment on a package shows up here as a thin page — if you're extending
21+
ClassicStack and a page is missing detail you need, that's a good sign the source package's doc
22+
comment could use it too.

0 commit comments

Comments
 (0)