Skip to main content

euv_docs/model/
struct.rs

1use super::*;
2
3/// Single externally supplied footer item (for example a filing notice with optional local badge icon).
4#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
5pub struct DocFooterItem {
6    /// Selectable link text rendered in the footer row.
7    #[serde(default)]
8    pub(crate) text: String,
9    /// Destination URL opened by this footer item.
10    #[serde(default)]
11    pub(crate) link: String,
12    /// Optional site-relative local icon path rendered before `text`.
13    #[serde(default)]
14    pub(crate) icon: String,
15    /// Optional accessible alt label for `icon`.
16    #[serde(default)]
17    pub(crate) alt: String,
18}
19
20/// Single top-bar navigation link declared under a locale's `navbar:` list.
21#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
22pub struct DocNavbarItem {
23    /// Visible navigation link label.
24    #[serde(default)]
25    pub(crate) text: String,
26    /// Internal route or external destination URL.
27    #[serde(default)]
28    pub(crate) link: String,
29}
30
31/// Per-locale site configuration declared under `locales:` in root `README.md` frontmatter.
32#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, PartialEq, Serialize)]
33pub struct DocLocaleConfig {
34    /// Public URL route prefix (e.g. `"/"`, `"/en/"`, `"/ja/"`, `"/ko/"`).
35    #[serde(default)]
36    pub(crate) prefix: String,
37    /// Source content directory beneath `<src_dir>` (e.g. `"zh"`, `"en"`, `"ja"`, `"ko"`).
38    #[serde(default)]
39    pub(crate) dir: String,
40    /// BCP 47 HTML language tag (e.g. `"zh-CN"`, `"en-US"`, `"ja-JP"`, `"ko-KR"`).
41    #[serde(default)]
42    pub(crate) lang: String,
43    /// Human-readable language switcher label (e.g. `"简体中文"`, `"English"`).
44    #[serde(default)]
45    pub(crate) label: String,
46    /// Optional locale-specific site title override.
47    #[serde(default)]
48    pub(crate) title: Option<String>,
49    /// Optional locale-specific site description override.
50    #[serde(default)]
51    pub(crate) description: Option<String>,
52    /// Optional localized footer attribution line.
53    #[serde(default)]
54    pub(crate) footer: Option<String>,
55    /// Optional localized table-of-contents heading label.
56    #[serde(default)]
57    pub(crate) toc_label: Option<String>,
58    /// Optional localized previous-page pager label.
59    #[serde(default)]
60    pub(crate) prev_label: Option<String>,
61    /// Optional localized next-page pager label.
62    #[serde(default)]
63    pub(crate) next_label: Option<String>,
64    /// Optional localized top navbar links.
65    #[serde(default)]
66    pub(crate) navbar: Vec<DocNavbarItem>,
67}
68
69/// Call-to-action button declared under `actions:` on a `home: true` landing page.
70#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
71pub struct DocHomeAction {
72    /// Button display text.
73    #[serde(default)]
74    pub(crate) text: String,
75    /// Internal route or external URL opened when clicked.
76    #[serde(default)]
77    pub(crate) link: String,
78    /// Optional symbolic icon name.
79    #[serde(default)]
80    pub(crate) icon: String,
81    /// Visual emphasis kind (`"primary"` or `"secondary"`).
82    #[serde(rename = "type", default)]
83    pub(crate) kind: String,
84}
85
86/// Key metric tile declared under `stats:` on a `home: true` landing page.
87#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
88pub struct DocHomeStat {
89    /// Leading glyph or icon label.
90    #[serde(default)]
91    pub(crate) icon: String,
92    /// Prominent metric value (e.g. `"100%"`, `"WASM"`).
93    #[serde(default)]
94    pub(crate) value: String,
95    /// Concise metric description caption.
96    #[serde(default)]
97    pub(crate) label: String,
98}
99
100/// Feature or product card declared under `features:` on a `home: true` landing page.
101#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
102pub struct DocHomeFeature {
103    /// Card heading title.
104    #[serde(default)]
105    pub(crate) title: String,
106    /// Card summary details copy.
107    #[serde(default)]
108    pub(crate) details: String,
109    /// Optional external or internal destination URL.
110    #[serde(default)]
111    pub(crate) link: String,
112}
113
114/// Optional site-level metadata declared under `site:` in root Markdown frontmatter.
115#[derive(Clone, Debug, Default, Deserialize, Getter, PartialEq, Serialize)]
116pub struct DocSiteFrontmatter {
117    /// Optional site display title.
118    pub(crate) title: Option<String>,
119    /// Optional site summary tagline.
120    pub(crate) description: Option<String>,
121    /// Optional brand logo URL or monogram text.
122    pub(crate) logo: Option<String>,
123    /// Optional footer attribution line.
124    pub(crate) footer: Option<String>,
125    /// Optional URL opened when clicking the primary footer attribution text.
126    #[serde(default)]
127    pub(crate) footer_link: Option<String>,
128    /// Externally supplied footer links and optional local badge icons.
129    #[serde(default)]
130    pub(crate) footer_items: Vec<DocFooterItem>,
131}
132
133/// Combined multi-locale site configuration parsed from root `README.md` frontmatter.
134#[derive(Clone, Debug, Default, Deserialize, Getter, PartialEq, Serialize)]
135pub struct DocSiteConfig {
136    /// Shared site-level metadata and footer items.
137    #[serde(default)]
138    pub(crate) site: DocSiteFrontmatter,
139    /// Declared site locales (empty for single-locale documentation trees).
140    #[serde(default)]
141    pub(crate) locales: Vec<DocLocaleConfig>,
142}
143
144/// Parsed YAML frontmatter metadata attached to a Markdown documentation file.
145#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
146pub struct DocFrontmatter {
147    /// Optional document title.
148    pub(crate) title: Option<String>,
149    /// Optional numeric sidebar sort order.
150    pub(crate) order: Option<i32>,
151    /// Optional tagline for home/landing pages.
152    pub(crate) tagline: Option<String>,
153    /// Optional page summary description.
154    #[serde(default)]
155    pub(crate) description: Option<String>,
156    /// Optional section group name.
157    pub(crate) section: Option<String>,
158    /// Optional last-updated date or release string.
159    #[serde(default)]
160    pub(crate) updated: Option<String>,
161    /// When `true`, renders this page with the hero/actions/stats/features/catalog landing layout.
162    #[serde(default)]
163    pub(crate) home: bool,
164    /// Optional hero display heading for landing pages.
165    #[serde(rename = "heroText", default)]
166    pub(crate) hero_text: Option<String>,
167    /// Optional landing-page call-to-action buttons.
168    #[serde(default)]
169    pub(crate) actions: Vec<DocHomeAction>,
170    /// Optional landing-page metric tiles.
171    #[serde(default)]
172    pub(crate) stats: Vec<DocHomeStat>,
173    /// Optional landing-page feature and product cards.
174    #[serde(default)]
175    pub(crate) features: Vec<DocHomeFeature>,
176    /// Optional explicit VuePress-style sidebar child ordering (`[dir_or_stem, ...]`).
177    #[serde(default)]
178    pub(crate) sidebar_order: Vec<String>,
179    /// Optional flag controlling sidebar inclusion (`Some(false)` hides page from sidebar tree).
180    #[serde(default)]
181    pub(crate) sidebar: Option<bool>,
182    /// Optional site-level configuration block.
183    pub(crate) site: Option<DocSiteFrontmatter>,
184    /// Optional multi-locale configuration block.
185    #[serde(default)]
186    pub(crate) locales: Vec<DocLocaleConfig>,
187}
188
189/// Single published project artifact returned by `/api/page-artifacts` and rendered in Rust.
190#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
191pub struct DocsCatalogArtifact {
192    /// Published project or qualified `org/repo` artifact name.
193    pub(crate) name: String,
194    /// Total number of files in the published artifact.
195    #[get(type(copy))]
196    pub(crate) file_count: u64,
197    /// Total artifact payload size in raw bytes.
198    #[get(type(copy))]
199    pub(crate) total_bytes: u64,
200    /// Hex-encoded lowercase SHA-256 digest of the artifact.
201    pub(crate) sha256: String,
202    /// Publication timestamp as Unix epoch seconds (UTC).
203    #[get(type(copy))]
204    pub(crate) updated_at: i64,
205}
206
207/// Compact search index record serialized into `search-index.json` and embedded client search.
208#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
209pub struct SearchIndexEntry {
210    /// Canonical route path for navigation.
211    pub(crate) route: String,
212    /// Document title.
213    pub(crate) title: String,
214    /// Section category label.
215    pub(crate) section: String,
216    /// Short page description or lead excerpt.
217    pub(crate) summary: String,
218    /// Concatenated heading titles for keyword matching.
219    pub(crate) headings: Vec<String>,
220    /// Plain-text searchable body excerpt.
221    pub(crate) excerpt: String,
222}
223
224/// Table-of-contents heading entry derived from a parsed document.
225#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
226pub struct DocTocItem {
227    /// Heading depth from 1 to 6.
228    #[get(type(copy))]
229    pub(crate) level: u8,
230    /// Anchor slug for jump navigation.
231    pub(crate) slug: String,
232    /// Display title text.
233    pub(crate) title: String,
234}
235
236/// Fully parsed documentation page ready for native rendering or static generation.
237#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
238pub struct DocPage {
239    /// Canonical route path (for example `/guide/getting-started`).
240    pub(crate) route: String,
241    /// Resolved page title.
242    pub(crate) title: String,
243    /// Sidebar sort order.
244    #[get(type(copy))]
245    pub(crate) order: i32,
246    /// Section category label.
247    pub(crate) section: String,
248    /// Short summary or tagline.
249    pub(crate) summary: String,
250    /// Structured Markdown content blocks.
251    #[serde(default, skip_serializing_if = "Vec::is_empty")]
252    pub(crate) blocks: Vec<DocBlock>,
253    /// Table-of-contents headings.
254    pub(crate) toc: Vec<DocTocItem>,
255    /// Preserved Markdown body text (after frontmatter) for full-fidelity HTML and native rendering.
256    #[serde(default, skip_serializing_if = "String::is_empty")]
257    #[get(pub(crate))]
258    #[new(skip)]
259    pub(crate) markdown_body: String,
260    /// Optional last-updated date or version stamp parsed from frontmatter.
261    #[serde(default, skip_serializing_if = "Option::is_none")]
262    #[new(skip)]
263    pub(crate) updated: Option<String>,
264    /// Whether this page declares `home: true` in frontmatter.
265    #[serde(default)]
266    #[get(type(copy))]
267    #[new(skip)]
268    pub(crate) is_home: bool,
269    /// Optional hero display heading for home pages.
270    #[serde(default, skip_serializing_if = "Option::is_none")]
271    #[new(skip)]
272    pub(crate) hero_text: Option<String>,
273    /// Landing-page call-to-action buttons.
274    #[serde(default, skip_serializing_if = "Vec::is_empty")]
275    #[new(skip)]
276    pub(crate) actions: Vec<DocHomeAction>,
277    /// Landing-page metric tiles.
278    #[serde(default, skip_serializing_if = "Vec::is_empty")]
279    #[new(skip)]
280    pub(crate) stats: Vec<DocHomeStat>,
281    /// Landing-page feature and product cards.
282    #[serde(default, skip_serializing_if = "Vec::is_empty")]
283    #[new(skip)]
284    pub(crate) features: Vec<DocHomeFeature>,
285    /// When `true`, hides this page from the sidebar navigation tree.
286    #[serde(default)]
287    #[get(type(copy))]
288    #[new(skip)]
289    pub(crate) hide_sidebar: bool,
290}
291
292/// Collection of parsed documentation pages forming a complete site or locale bundle.
293#[derive(Clone, Data, Debug, Deserialize, New, PartialEq, Serialize)]
294pub struct DocSite {
295    /// Site brand title.
296    pub(crate) title: String,
297    /// Site description tagline.
298    pub(crate) tagline: String,
299    /// Ordered documentation pages.
300    pub(crate) pages: Vec<DocPage>,
301    /// Active BCP 47 HTML language tag (e.g. `"en-US"`, `"zh-CN"`).
302    #[serde(default, skip_serializing_if = "String::is_empty")]
303    #[new(skip)]
304    pub(crate) lang: String,
305    /// Active locale route prefix (e.g. `"/"`, `"/en/"`).
306    #[serde(default, skip_serializing_if = "String::is_empty")]
307    #[new(skip)]
308    pub(crate) locale_prefix: String,
309    /// Optional brand logo URL.
310    #[serde(default, skip_serializing_if = "String::is_empty")]
311    #[new(skip)]
312    pub(crate) logo: String,
313    /// Localized footer attribution line.
314    #[serde(default, skip_serializing_if = "String::is_empty")]
315    #[new(skip)]
316    pub(crate) footer: String,
317    /// Optional URL opened by clicking the primary footer attribution text.
318    #[serde(default, skip_serializing_if = "String::is_empty")]
319    #[new(skip)]
320    pub(crate) footer_link: String,
321    /// Externally supplied footer links and optional local icons.
322    #[serde(default, skip_serializing_if = "Vec::is_empty")]
323    #[new(skip)]
324    pub(crate) footer_items: Vec<DocFooterItem>,
325    /// Localized table-of-contents heading label.
326    #[serde(default, skip_serializing_if = "String::is_empty")]
327    #[new(skip)]
328    pub(crate) toc_label: String,
329    /// Localized previous-page pager label.
330    #[serde(default, skip_serializing_if = "String::is_empty")]
331    #[new(skip)]
332    pub(crate) prev_label: String,
333    /// Localized next-page pager label.
334    #[serde(default, skip_serializing_if = "String::is_empty")]
335    #[new(skip)]
336    pub(crate) next_label: String,
337    /// Localized top navbar links.
338    #[serde(default, skip_serializing_if = "Vec::is_empty")]
339    #[new(skip)]
340    pub(crate) navbar: Vec<DocNavbarItem>,
341    /// Available site locales for the language switcher.
342    #[serde(default, skip_serializing_if = "Vec::is_empty")]
343    #[new(skip)]
344    pub(crate) locales: Vec<DocLocaleConfig>,
345    /// Embedded release version marker carried in serialized WASM site bundles.
346    #[serde(default, skip_serializing_if = "String::is_empty")]
347    #[new(skip)]
348    pub(crate) release_marker: String,
349}