Files
llmgw/internal/docgen/gen/main.go
T
Ilker ManapandClaude Opus 5.5 9ab93a0aa6 Watch the cluster and edit every setting from the console
The console gains live views of nodes, GPUs, models, replicas, usage and
agent logs, and a settings tree over every key of server.yaml (agent.yaml on
a node), generated from the configuration structs: values with their
defaults and doc comments, edited in dialogs, saved only once the service's
own loader accepts them, comments kept. The generator now tells blocks apart
by package, which brings the TLS, engine and supervisor settings back into
the reference.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-03 22:54:09 +02:00

47 lines
1.4 KiB
Go

// Command gen writes docs/reference.md from the configuration structs.
//
// Run by `go generate ./...`, and checked by a test, so the reference cannot
// quietly stop describing the code.
package main
import (
"fmt"
"os"
"path/filepath"
"runtime"
"gitea.mynodes.xyz/ilker/llmgw/internal/docgen"
)
func main() {
// The repository root, found from this file rather than from the working
// directory, so `go generate ./...` produces the same document wherever
// it is run from.
_, self, _, ok := runtime.Caller(0)
if !ok {
fmt.Fprintln(os.Stderr, "error: cannot locate the generator")
os.Exit(1)
}
root := filepath.Join(filepath.Dir(self), "..", "..", "..")
paths := make([]string, len(docgen.Sources))
for i, s := range docgen.Sources {
paths[i] = filepath.Join(root, s)
}
blocks, err := docgen.Collect(paths)
if err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
os.Exit(1)
}
if err := os.WriteFile(filepath.Join(root, "docs", "reference.md"), []byte(docgen.Render(blocks)), 0o644); err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
os.Exit(1)
}
if err := os.WriteFile(filepath.Join(root, "internal", "docgen", "reference_gen.go"), []byte(docgen.RenderGo(blocks)), 0o644); err != nil {
fmt.Fprintln(os.Stderr, "error:", err)
os.Exit(1)
}
fmt.Printf("docs/reference.md and internal/docgen/reference_gen.go: %d blocks\n", len(blocks))
}