Documentation Generator¶
Purpose¶
Sample configs in sample-config are rendered into PNG artifacts in generated. Each config demonstrates one visual feature and is designed for stable documentation references.
Generated sections in CLI/TOML reference pages are written to docs/generated/*.md by scripts/generate-documentation.ps1, and runtime CLI metadata is generated into C# at build time from schema metadata. The schema is the single source of truth for TOML defaults/descriptions, CLI help metadata, and documentation tables.
Current state¶
- Schema metadata in
docs/schemas/bgraster-config.schema.jsonis the source of truth for TOML and CLI surfaces. - Build-time generation emits strongly-typed C# option metadata from schema.
- Runtime consumes generated C# metadata only and does not parse schema files.
- Docs generation reads the same schema metadata contract and emits markdown tables under
docs/generated. - Static pages include generated sections using
pymdownx.snippets.
This removes duplicate hand-maintained metadata between schema and runtime code.
Metadata model¶
The schema uses a namespaced extension key: x-bgraster.
Option metadata includes:
- Stable key (for deterministic ordering and diff stability)
- CLI alias and value syntax
- Parse kind/type hint
- Surface visibility (
toml,cli, orboth) - TOML mapping path (when applicable)
- Help/description and default-resolution text
CLI-only options (for example --config) live under cliOnlyOptions in the same extension.
How generation works¶
Sample asset generation (scripts/generate-documentation.ps1):
- Enumerates all TOML files in
docs/sample-config. - Invokes BgRaster once per file.
- Forces non-assignment mode (
--no-discovery true --no-assignment true). - Uses
--render-outputwith a deterministic stem derived from the sample file name. - Writes PNG outputs to
docs/generated.
Metadata generation pipeline:
- Build uses an incremental source generator to read schema metadata and emit C# option metadata.
- CLI binding/help consumes generated metadata for option descriptions and mappings.
scripts/generate-documentation.ps1reads schema metadata and writes generated markdown files underdocs/generated/beforemkdocs build/mkdocs serveruns.- Pages publish fully expanded tables via snippet includes in cli-schema.md and toml-schema.md.
Implementation details¶
The project uses a Roslyn Incremental Source Generator.
Rationale:
- Modern .NET pattern for compile-time metadata projection
- Incremental and cached for fast rebuilds
- Zero runtime schema IO or JSON parse cost
- Strongly typed generated data with compile-time failures on invalid metadata
- Easy parity testing between schema metadata, generated code, and docs outputs
Config requirements for samples¶
Each sample config must:
- Use
[render].no-discovery = true. - Include one
[[output]]entry with[output.hardware_output]dimensions. - Disable unrelated layers where possible so each sample demonstrates a single feature.
Current fixed hardware profile used for simple samples:
index = 0
desktopX = 0
desktopY = 0
widthPx = 640
heightPx = 480
dpiX = 96
dpiY = 96
rotation = 0
adapterName = "FIXED"
friendlyName = "Unspecified"
Path behavior¶
Sample configs intentionally use relative paths (for example, images/logo.png). Path handling rules are documented centrally in toml-schema.md.