@vantagecompute/docusaurus-plugin-godoc
v0.1.3
Published
Docusaurus plugin that auto-generates SDK reference docs from Go source using go doc
Readme
@vantagecompute/docusaurus-plugin-godoc
A Docusaurus plugin that auto-generates SDK reference documentation from Go source code using go doc.
Features
- Parses
go doc -alloutput for each configured package - Generates one Markdown page per package with types, functions, methods, and doc comments
- Generates an SDK reference index page with package summary table
- Optionally extracts cobra command tree for CLI command reference pages
- Runs at Docusaurus build time (or standalone via CLI)
Installation
npm install @vantagecompute/docusaurus-plugin-godocUsage
In your docusaurus.config.ts:
plugins: [
[
'@vantagecompute/docusaurus-plugin-godoc',
{
projectRoot: path.join(__dirname, '..'),
packages: [
{path: './cmd', name: 'cmd'},
{path: './internal/cache', name: 'internal/cache'},
],
outputDir: './docs/sdk-reference',
// Optional: generate commands page from cobra help output
generateCommands: false,
binaryName: 'v8x',
commandsOutputPath: './docs/commands.mdx',
},
],
],Options
| Option | Type | Default | Description |
|--------|------|---------|-------------|
| projectRoot | string | required | Path to Go project root (where go.mod lives) |
| packages | array | [] | Packages to document. Each: {path, name, label?} |
| outputDir | string | ./docs/sdk-reference | Output directory for generated markdown |
| generateCommands | boolean | false | Generate a commands reference from cobra help |
| binaryName | string | - | CLI binary name (used for commands generation) |
| commandsOutputPath | string | ./docs/commands.mdx | Output path for commands page |
Standalone CLI
Generate docs without a full Docusaurus build:
node node_modules/@vantagecompute/docusaurus-plugin-godoc/src/generate.js \
--project-root ../.. \
--output-dir ./docs/sdk-reference \
--packages ./cmd,./internal/cache,./internal/outputRequirements
- Go must be installed and on
$PATH - The Go project must be buildable (
go docneeds compilable source)
How it Works
- At Docusaurus
loadContentphase, runsgo doc -all <package>for each configured package - Parses the structured text output into types, functions, methods, constants, and variables
- Renders each package as a Markdown page with Go code blocks and doc comments
- Generates an index page listing all packages with summary info
License
MIT
