euv-docs 0.47.0

Cross-platform documentation viewer and static site generator powered by euv and euv-ui.
Documentation
use super::*;

/// Single externally supplied footer item (for example a filing notice with optional local badge icon).
#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct DocFooterItem {
    /// Selectable link text rendered in the footer row.
    #[serde(default)]
    pub(crate) text: String,
    /// Destination URL opened by this footer item.
    #[serde(default)]
    pub(crate) link: String,
    /// Optional site-relative local icon path rendered before `text`.
    #[serde(default)]
    pub(crate) icon: String,
    /// Optional accessible alt label for `icon`.
    #[serde(default)]
    pub(crate) alt: String,
}

/// Single top-bar navigation link declared under a locale's `navbar:` list.
#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct DocNavbarItem {
    /// Visible navigation link label.
    #[serde(default)]
    pub(crate) text: String,
    /// Internal route or external destination URL.
    #[serde(default)]
    pub(crate) link: String,
}

/// Per-locale site configuration declared under `locales:` in root `README.md` frontmatter.
#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, PartialEq, Serialize)]
pub struct DocLocaleConfig {
    /// Public URL route prefix (e.g. `"/"`, `"/en/"`, `"/ja/"`, `"/ko/"`).
    #[serde(default)]
    pub(crate) prefix: String,
    /// Source content directory beneath `<src_dir>` (e.g. `"zh"`, `"en"`, `"ja"`, `"ko"`).
    #[serde(default)]
    pub(crate) dir: String,
    /// BCP 47 HTML language tag (e.g. `"zh-CN"`, `"en-US"`, `"ja-JP"`, `"ko-KR"`).
    #[serde(default)]
    pub(crate) lang: String,
    /// Human-readable language switcher label (e.g. `"简体中文"`, `"English"`).
    #[serde(default)]
    pub(crate) label: String,
    /// Optional locale-specific site title override.
    #[serde(default)]
    pub(crate) title: Option<String>,
    /// Optional locale-specific site description override.
    #[serde(default)]
    pub(crate) description: Option<String>,
    /// Optional localized footer attribution line.
    #[serde(default)]
    pub(crate) footer: Option<String>,
    /// Optional localized table-of-contents heading label.
    #[serde(default)]
    pub(crate) toc_label: Option<String>,
    /// Optional localized previous-page pager label.
    #[serde(default)]
    pub(crate) prev_label: Option<String>,
    /// Optional localized next-page pager label.
    #[serde(default)]
    pub(crate) next_label: Option<String>,
    /// Optional localized top navbar links.
    #[serde(default)]
    pub(crate) navbar: Vec<DocNavbarItem>,
}

/// Call-to-action button declared under `actions:` on a `home: true` landing page.
#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct DocHomeAction {
    /// Button display text.
    #[serde(default)]
    pub(crate) text: String,
    /// Internal route or external URL opened when clicked.
    #[serde(default)]
    pub(crate) link: String,
    /// Optional symbolic icon name.
    #[serde(default)]
    pub(crate) icon: String,
    /// Visual emphasis kind (`"primary"` or `"secondary"`).
    #[serde(rename = "type", default)]
    pub(crate) kind: String,
}

/// Key metric tile declared under `stats:` on a `home: true` landing page.
#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct DocHomeStat {
    /// Leading glyph or icon label.
    #[serde(default)]
    pub(crate) icon: String,
    /// Prominent metric value (e.g. `"100%"`, `"WASM"`).
    #[serde(default)]
    pub(crate) value: String,
    /// Concise metric description caption.
    #[serde(default)]
    pub(crate) label: String,
}

/// Feature or product card declared under `features:` on a `home: true` landing page.
#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct DocHomeFeature {
    /// Card heading title.
    #[serde(default)]
    pub(crate) title: String,
    /// Card summary details copy.
    #[serde(default)]
    pub(crate) details: String,
    /// Optional external or internal destination URL.
    #[serde(default)]
    pub(crate) link: String,
}

/// Optional site-level metadata declared under `site:` in root Markdown frontmatter.
#[derive(Clone, Debug, Default, Deserialize, Getter, PartialEq, Serialize)]
pub struct DocSiteFrontmatter {
    /// Optional site display title.
    pub(crate) title: Option<String>,
    /// Optional site summary tagline.
    pub(crate) description: Option<String>,
    /// Optional brand logo URL or monogram text.
    pub(crate) logo: Option<String>,
    /// Optional footer attribution line.
    pub(crate) footer: Option<String>,
    /// Optional URL opened when clicking the primary footer attribution text.
    #[serde(default)]
    pub(crate) footer_link: Option<String>,
    /// Externally supplied footer links and optional local badge icons.
    #[serde(default)]
    pub(crate) footer_items: Vec<DocFooterItem>,
}

/// Combined multi-locale site configuration parsed from root `README.md` frontmatter.
#[derive(Clone, Debug, Default, Deserialize, Getter, PartialEq, Serialize)]
pub struct DocSiteConfig {
    /// Shared site-level metadata and footer items.
    #[serde(default)]
    pub(crate) site: DocSiteFrontmatter,
    /// Declared site locales (empty for single-locale documentation trees).
    #[serde(default)]
    pub(crate) locales: Vec<DocLocaleConfig>,
}

/// Parsed YAML frontmatter metadata attached to a Markdown documentation file.
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
pub struct DocFrontmatter {
    /// Optional document title.
    pub(crate) title: Option<String>,
    /// Optional numeric sidebar sort order.
    pub(crate) order: Option<i32>,
    /// Optional tagline for home/landing pages.
    pub(crate) tagline: Option<String>,
    /// Optional page summary description.
    #[serde(default)]
    pub(crate) description: Option<String>,
    /// Optional section group name.
    pub(crate) section: Option<String>,
    /// Optional last-updated date or release string.
    #[serde(default)]
    pub(crate) updated: Option<String>,
    /// When `true`, renders this page with the hero/actions/stats/features/catalog landing layout.
    #[serde(default)]
    pub(crate) home: bool,
    /// Optional hero display heading for landing pages.
    #[serde(rename = "heroText", default)]
    pub(crate) hero_text: Option<String>,
    /// Optional landing-page call-to-action buttons.
    #[serde(default)]
    pub(crate) actions: Vec<DocHomeAction>,
    /// Optional landing-page metric tiles.
    #[serde(default)]
    pub(crate) stats: Vec<DocHomeStat>,
    /// Optional landing-page feature and product cards.
    #[serde(default)]
    pub(crate) features: Vec<DocHomeFeature>,
    /// Optional explicit VuePress-style sidebar child ordering (`[dir_or_stem, ...]`).
    #[serde(default)]
    pub(crate) sidebar_order: Vec<String>,
    /// Optional flag controlling sidebar inclusion (`Some(false)` hides page from sidebar tree).
    #[serde(default)]
    pub(crate) sidebar: Option<bool>,
    /// Optional site-level configuration block.
    pub(crate) site: Option<DocSiteFrontmatter>,
    /// Optional multi-locale configuration block.
    #[serde(default)]
    pub(crate) locales: Vec<DocLocaleConfig>,
}

/// Single published project artifact returned by `/api/page-artifacts` and rendered in Rust.
#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct DocsCatalogArtifact {
    /// Published project or qualified `org/repo` artifact name.
    pub(crate) name: String,
    /// Total number of files in the published artifact.
    #[get(type(copy))]
    pub(crate) file_count: u64,
    /// Total artifact payload size in raw bytes.
    #[get(type(copy))]
    pub(crate) total_bytes: u64,
    /// Hex-encoded lowercase SHA-256 digest of the artifact.
    pub(crate) sha256: String,
    /// Publication timestamp as Unix epoch seconds (UTC).
    #[get(type(copy))]
    pub(crate) updated_at: i64,
}

/// Compact search index record serialized into `search-index.json` and embedded client search.
#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
pub struct SearchIndexEntry {
    /// Canonical route path for navigation.
    pub(crate) route: String,
    /// Document title.
    pub(crate) title: String,
    /// Section category label.
    pub(crate) section: String,
    /// Short page description or lead excerpt.
    pub(crate) summary: String,
    /// Concatenated heading titles for keyword matching.
    pub(crate) headings: Vec<String>,
    /// Plain-text searchable body excerpt.
    pub(crate) excerpt: String,
}

/// Table-of-contents heading entry derived from a parsed document.
#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
pub struct DocTocItem {
    /// Heading depth from 1 to 6.
    #[get(type(copy))]
    pub(crate) level: u8,
    /// Anchor slug for jump navigation.
    pub(crate) slug: String,
    /// Display title text.
    pub(crate) title: String,
}

/// Fully parsed documentation page ready for native rendering or static generation.
#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
pub struct DocPage {
    /// Canonical route path (for example `/guide/getting-started`).
    pub(crate) route: String,
    /// Resolved page title.
    pub(crate) title: String,
    /// Sidebar sort order.
    #[get(type(copy))]
    pub(crate) order: i32,
    /// Section category label.
    pub(crate) section: String,
    /// Short summary or tagline.
    pub(crate) summary: String,
    /// Structured Markdown content blocks.
    pub(crate) blocks: Vec<DocBlock>,
    /// Table-of-contents headings.
    pub(crate) toc: Vec<DocTocItem>,
    /// Preserved Markdown body text (after frontmatter) for full-fidelity HTML and native rendering.
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[get(pub(crate))]
    #[new(skip)]
    pub(crate) markdown_body: String,
    /// Optional last-updated date or version stamp parsed from frontmatter.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[new(skip)]
    pub(crate) updated: Option<String>,
    /// Whether this page declares `home: true` in frontmatter.
    #[serde(default)]
    #[get(type(copy))]
    #[new(skip)]
    pub(crate) is_home: bool,
    /// Optional hero display heading for home pages.
    #[serde(default, skip_serializing_if = "Option::is_none")]
    #[new(skip)]
    pub(crate) hero_text: Option<String>,
    /// Landing-page call-to-action buttons.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    #[new(skip)]
    pub(crate) actions: Vec<DocHomeAction>,
    /// Landing-page metric tiles.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    #[new(skip)]
    pub(crate) stats: Vec<DocHomeStat>,
    /// Landing-page feature and product cards.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    #[new(skip)]
    pub(crate) features: Vec<DocHomeFeature>,
    /// When `true`, hides this page from the sidebar navigation tree.
    #[serde(default)]
    #[get(type(copy))]
    #[new(skip)]
    pub(crate) hide_sidebar: bool,
}

/// Collection of parsed documentation pages forming a complete site or locale bundle.
#[derive(Clone, Data, Debug, Deserialize, New, PartialEq, Serialize)]
pub struct DocSite {
    /// Site brand title.
    pub(crate) title: String,
    /// Site description tagline.
    pub(crate) tagline: String,
    /// Ordered documentation pages.
    pub(crate) pages: Vec<DocPage>,
    /// Active BCP 47 HTML language tag (e.g. `"en-US"`, `"zh-CN"`).
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[new(skip)]
    pub(crate) lang: String,
    /// Active locale route prefix (e.g. `"/"`, `"/en/"`).
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[new(skip)]
    pub(crate) locale_prefix: String,
    /// Optional brand logo URL.
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[new(skip)]
    pub(crate) logo: String,
    /// Localized footer attribution line.
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[new(skip)]
    pub(crate) footer: String,
    /// Optional URL opened by clicking the primary footer attribution text.
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[new(skip)]
    pub(crate) footer_link: String,
    /// Externally supplied footer links and optional local icons.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    #[new(skip)]
    pub(crate) footer_items: Vec<DocFooterItem>,
    /// Localized table-of-contents heading label.
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[new(skip)]
    pub(crate) toc_label: String,
    /// Localized previous-page pager label.
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[new(skip)]
    pub(crate) prev_label: String,
    /// Localized next-page pager label.
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[new(skip)]
    pub(crate) next_label: String,
    /// Localized top navbar links.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    #[new(skip)]
    pub(crate) navbar: Vec<DocNavbarItem>,
    /// Available site locales for the language switcher.
    #[serde(default, skip_serializing_if = "Vec::is_empty")]
    #[new(skip)]
    pub(crate) locales: Vec<DocLocaleConfig>,
    /// Embedded release version marker carried in serialized WASM site bundles.
    #[serde(default, skip_serializing_if = "String::is_empty")]
    #[new(skip)]
    pub(crate) release_marker: String,
}