euv_docs/generator/struct.rs
1use super::*;
2
3/// Result summary emitted after generating a static documentation bundle.
4#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
5pub struct GeneratedSiteReport {
6 /// Total HTML pages written.
7 #[get(type(copy))]
8 pub(crate) page_count: usize,
9 /// UTC RFC-3339 build timestamp.
10 pub(crate) generated_at: String,
11 /// Path to the generated JSON search index.
12 pub(crate) index_path: String,
13}
14
15/// Configuration controlling static documentation site generation and optional dev live-reload.
16#[derive(Clone, Data, Debug, Deserialize, Eq, PartialEq, Serialize)]
17pub struct DocsBuildOptions {
18 /// Optional explicit site brand title overriding frontmatter and directory heuristics.
19 pub(crate) title: Option<String>,
20 /// Optional URL base prefix (for example `""` or `"/docs"`).
21 pub(crate) base_url: String,
22 /// Optional SSE live-reload endpoint injected in dev mode (for example `Some("/__euv_hmr")`).
23 pub(crate) hmr_endpoint: Option<String>,
24 /// Optional source root directory whose static assets are copied into the build output.
25 pub(crate) assets_root: Option<PathBuf>,
26 /// When `true`, writes both `<route>/index.html` and `<route>.html` for universal static hosting.
27 #[get(type(copy))]
28 pub(crate) clean_urls: bool,
29}
30
31/// Shared immutable context passed into page HTML generation to keep helper signatures compact.
32#[derive(Clone, Copy, Debug, Getter)]
33pub(crate) struct PageRenderContext<'a> {
34 /// Parent documentation site containing navigation metadata.
35 #[get(pub(crate), type(copy))]
36 pub(crate) site: &'a DocSite,
37 /// Previous page in canonical sidebar reading order.
38 #[get(pub(crate), type(copy))]
39 pub(crate) prev_page: Option<&'a DocPage>,
40 /// Next page in canonical sidebar reading order.
41 #[get(pub(crate), type(copy))]
42 pub(crate) next_page: Option<&'a DocPage>,
43 /// Build timestamp formatted as RFC-3339.
44 #[get(pub(crate), type(copy))]
45 pub(crate) generated_at: &'a str,
46 /// Script-safe compact JSON search index payload.
47 #[get(pub(crate), type(copy))]
48 pub(crate) search_json_compact: &'a str,
49 /// Active documentation build options.
50 #[get(pub(crate), type(copy))]
51 pub(crate) options: &'a DocsBuildOptions,
52}
53
54/// Mutable state threaded through Markdown chunk rendering for a single page.
55pub(crate) struct MarkdownRenderState<'a> {
56 /// Current documentation page being rendered.
57 pub(crate) page: &'a DocPage,
58 /// Normalized base URL prefix without trailing slash.
59 pub(crate) base: &'a str,
60 /// Per-page heading anchor slug counter for deduplication.
61 pub(crate) seen_slugs: BTreeMap<String, usize>,
62 /// Whether the leading H1 matching `page.title` has already been skipped.
63 pub(crate) skipped_title_h1: bool,
64 /// Destination HTML buffer.
65 pub(crate) out: &'a mut String,
66}