Web
Web file generation by output format
Generates web documentation from Rust DSL sources. Each generator targets a specific output format and integrates with Bazel through Starlark rules for authoring, publishing, and serving.
HTML
Renders a Page
element tree into complete HTML documents. Handles heading extraction for automatic table-of-contents generation, syntax-highlighted code blocks, and data injection for runtime assets.
Pages are authored as .page.rs
content libraries using the Composition
trait, which provides semantic methods for document structure:
Composition
The Composition
trait adds high-level semantic methods to the body builder:
-
heading,title,subtitle,section— document structure -
paragraph,aside,rule,term,definition— content blocks -
navigation,figure— navigation -
bold,link— inline formatting
Style
Generates CSS from a golden-ratio design system. All spacing, typography, and responsive breakpoints scale from PHI
(1.618). Colors are defined as paired light/dark values, switchable via data-theme
attribute.
-
Proportions
: phi-scaled spacing variables from
--scale-n2to--scale-3 - Typography : heading sizes follow the golden ratio scale
- Layout : three-column grid (sidebar, main, outline) with responsive collapse
- Themes : light and dark via CSS custom properties, persisted in localStorage
Highlight
Syntax highlighting dispatches to language-specific highlighters. Each produces HTML spans with semantic CSS classes for theme-aware coloring.
| Language | Strategy |
|---|---|
| Rust | AST via syn, with snippet fallback |
| Molten | Custom AST traversal |
| JSON | Structural value coloring |
| Starlark | Tree-sitter grammar |
| Bash | Tree-sitter grammar |
Assembly
Compiles Rust to WebAssembly for client-side interactivity. The assembly chain produces compute.js
and compute_bg.wasm
via rust_wasm_bindgen
.
- Navigate : SPA navigation without page reloads
- Theme : toggle button with localStorage persistence
- Clipboard : copy-to-clipboard on code blocks
- Outline : scroll-tracking table of contents
- Scroll : smooth scroll behavior
- Hamburger : mobile sidebar toggle
Starlark
Bazel rules for authoring, publishing, verifying, and serving documentation. All rules are loaded from //component/web/starlark:defs.bzl
.
document
Compiles a Rust DSL source into a binary, executes it, and collects the generated output. Standard dependencies ( html
, miette
) are injected automatically.
| Parameter | Description |
|---|---|
src
|
Rust binary source file (.document.rs) |
destination
|
Workspace-relative output path |
deps
|
Additional compile dependencies |
data
|
Runtime data files for WASM or code injection |
compile_data
|
Compile-time data files for include_str!
sources
|
copy
Wraps an existing file with a destination path for inclusion in folder manifests. Uses a zero-cost symlink action.
folder
Aggregates document and copy targets into a manifest, then copies all generated files into the workspace.
distribute
Serves the workspace directory over HTTP for local preview.