Documentation
¶
Overview ¶
Package docgenenv normalizes the process environment so documentation generators produce host-independent output.
Index ¶
Constants ¶
const GeneratedContentBanner = "<!-- DO NOT EDIT | GENERATED CONTENT -->"
GeneratedContentBanner is the HTML comment placed in the Markdown body of every generated reference page, directly below the front matter. The in-fence generatedMarker flags the page metadata as generated; this body banner flags the whole page as generated, so an editor who reads past the front matter is still warned. Both documentation generators reference this one constant so the wording cannot drift between them.
Variables ¶
This section is empty.
Functions ¶
func FrontMatter ¶ added in v2.37.0
FrontMatter renders r's metadata (title plus any description, icon_path, and state) as a YAML front matter block. The block opens with generatedMarker, carries the fences, and ends with the blank line that separates it from the Markdown body. Optional fields are omitted when empty.
Both documentation generators emit their front matter through this single function so a new per-page metadata field is wired in one place instead of drifting between the CLI template and the API generator. Structural manifest fields (path, children) are intentionally not mirrored here.
func GeneratedHeader ¶ added in v2.37.0
GeneratedHeader returns the full generated-page preamble: the front matter block (from FrontMatter) followed by GeneratedContentBanner and the blank line before the Markdown body. The API generator prepends this to every page so CLI and API reference pages share the same two markers; the CLI template composes the equivalent preamble inline from the frontMatter and generatedContentBanner template helpers.
func Prepare ¶
func Prepare()
Prepare clears CODER_* variables and pins the cache, config, and temp directories so generated docs don't embed the generating host's home directory.
func YAMLScalar ¶ added in v2.37.0
YAMLScalar renders s as a YAML scalar suitable for a front matter value. Simple values are emitted verbatim. Anything YAML could misparse, such as special characters or a bare word/number YAML would otherwise resolve to a bool, null, or number, is JSON-encoded, which is valid YAML that quotes and escapes the value so it round-trips back to the original string.
Both the CLI and API documentation generators share this helper so their front-matter escaping cannot silently diverge.
Types ¶
type Manifest ¶ added in v2.37.0
type Manifest struct {
Versions []string `json:"versions,omitempty"`
Routes []Route `json:"routes,omitempty"`
}
Manifest describes the entire documentation index (docs/manifest.json).
func LoadManifest ¶ added in v2.37.0
LoadManifest reads and unmarshals the manifest.json at path. Its errors wrap the path and cause, so callers should return the error as-is rather than wrapping it again.
func (*Manifest) FindRoute ¶ added in v2.37.0
FindRoute walks the manifest, following titles as a breadcrumb from the top-level routes, and returns a pointer to the matching route (or nil if any title in the path has no match). The returned pointer aliases the manifest, so mutating it (for example, replacing Children) updates the manifest in place.
Both documentation generators resolve their target route through this single traversal so the route they read metadata from and the route they rewrite cannot drift apart.
type Route ¶ added in v2.37.0
type Route struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Path string `json:"path,omitempty"`
IconPath string `json:"icon_path,omitempty"`
State []string `json:"state,omitempty"`
Children []Route `json:"children,omitempty"`
}
Route is an individual page object in the docs manifest.json. Per-page metadata (title, description, icon_path, state) is mirrored into page front matter by the doc generators; the structural fields (path, children) stay in the manifest.