// 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) } fmt.Printf("docs/reference.md: %d blocks\n", len(blocks)) }