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/// Directory presentation metadata parsed from a VuePress-style `dir:` frontmatter block.
145#[derive(Clone, Debug, Default, Deserialize, Getter, PartialEq, Serialize)]
146pub struct DocDirFrontmatter {
147    /// Explicit sort order for this directory among its sibling entries.
148    #[serde(default)]
149    #[get(type(copy))]
150    pub(crate) order: Option<i32>,
151    /// Optional display label override for this directory in the sidebar tree.
152    #[serde(default)]
153    pub(crate) text: Option<String>,
154    /// Optional flag indicating whether clicking the directory links to its README index.
155    #[serde(default)]
156    #[get(type(copy))]
157    pub(crate) link: Option<bool>,
158    /// Optional flag indicating whether the directory branch is collapsible.
159    #[serde(default)]
160    #[get(type(copy))]
161    pub(crate) collapsible: Option<bool>,
162}
163
164/// Parsed YAML frontmatter metadata attached to a Markdown documentation file.
165#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
166pub struct DocFrontmatter {
167    /// Optional document title.
168    pub(crate) title: Option<String>,
169    /// Optional numeric sidebar sort order.
170    pub(crate) order: Option<i32>,
171    /// Optional tagline for home/landing pages.
172    pub(crate) tagline: Option<String>,
173    /// Optional page summary description.
174    #[serde(default)]
175    pub(crate) description: Option<String>,
176    /// Optional section group name.
177    pub(crate) section: Option<String>,
178    /// Optional last-updated date or release string.
179    #[serde(default)]
180    pub(crate) updated: Option<String>,
181    /// Optional publication date string (e.g. `2025-11-23`).
182    #[serde(default)]
183    pub(crate) date: Option<String>,
184    /// Optional category tags attached to the page.
185    #[serde(default)]
186    pub(crate) category: Vec<String>,
187    /// Optional directory index toggle (`Some(false)` marks a directory overview/folder index without duplicating README as a child).
188    #[serde(default)]
189    pub(crate) index: Option<bool>,
190    /// Optional initial sidebar expansion toggle (`Some(false)` starts collapsed unless on the active ancestor path).
191    #[serde(default)]
192    pub(crate) expanded: Option<bool>,
193    /// Optional nested `dir:` frontmatter block controlling folder order, text, link, and collapsibility.
194    #[serde(default)]
195    pub(crate) dir: Option<DocDirFrontmatter>,
196    /// Optional page or directory password protecting content until unlocked.
197    #[serde(default)]
198    pub(crate) password: Option<String>,
199    /// Optional raw HTML `<head>` metadata array preserved transparently during YAML parsing.
200    #[serde(default)]
201    pub(crate) head: Value,
202    /// When `true`, renders this page with the hero/actions/stats/features/catalog landing layout.
203    #[serde(default)]
204    pub(crate) home: bool,
205    /// Optional hero display heading for landing pages.
206    #[serde(rename = "heroText", default)]
207    pub(crate) hero_text: Option<String>,
208    /// Optional landing-page call-to-action buttons.
209    #[serde(default)]
210    pub(crate) actions: Vec<DocHomeAction>,
211    /// Optional landing-page metric tiles.
212    #[serde(default)]
213    pub(crate) stats: Vec<DocHomeStat>,
214    /// Optional landing-page feature and product cards.
215    #[serde(default)]
216    pub(crate) features: Vec<DocHomeFeature>,
217    /// Optional explicit VuePress-style sidebar child ordering (`[dir_or_stem, ...]`).
218    #[serde(default)]
219    pub(crate) sidebar_order: Vec<String>,
220    /// Optional flag controlling sidebar inclusion (`Some(false)` hides page from sidebar tree).
221    #[serde(default)]
222    pub(crate) sidebar: Option<bool>,
223    /// Optional site-level configuration block.
224    pub(crate) site: Option<DocSiteFrontmatter>,
225    /// Optional multi-locale configuration block.
226    #[serde(default)]
227    pub(crate) locales: Vec<DocLocaleConfig>,
228}
229
230/// Recursive filesystem-mirrored catalog tree node powering the left documentation sidebar.
231#[derive(Clone, Data, Debug, Default, Deserialize, PartialEq, Serialize)]
232pub struct DocCatalogNode {
233    /// Stable tree key (`"euv/core"` for directories, canonical route for files).
234    pub(crate) key: String,
235    /// Visible sidebar display label.
236    pub(crate) title: String,
237    /// Optional direct document route rendered when activating this node.
238    pub(crate) route: Option<String>,
239    /// First ordered readable descendant document route (used for auto-navigation on empty-README or README-less folders).
240    pub(crate) first_child_route: Option<String>,
241    /// Whether this entry represents a filesystem directory.
242    #[get(type(copy))]
243    pub(crate) is_dir: bool,
244    /// Whether the directory README declared `index: false`.
245    #[get(type(copy))]
246    pub(crate) index_disabled: bool,
247    /// Whether this node owns non-empty document body content.
248    #[get(type(copy))]
249    pub(crate) has_own_content: bool,
250    /// Explicit frontmatter expansion override (`Some(false)` starts collapsed, `Some(true)` starts expanded).
251    #[get(type(copy))]
252    pub(crate) expanded_pref: Option<bool>,
253    /// Whether the directory can be collapsed interactively.
254    #[get(type(copy))]
255    pub(crate) collapsible: bool,
256    /// Effective numeric sort order within its parent directory.
257    #[get(type(copy))]
258    pub(crate) order: i32,
259    /// Whether this node or an ancestor directory requires password unlock.
260    #[get(type(copy))]
261    pub(crate) locked: bool,
262    /// Ordered child entries strictly mirroring the filesystem hierarchy.
263    #[serde(default, skip_serializing_if = "Vec::is_empty")]
264    pub(crate) children: Vec<DocCatalogNode>,
265}
266
267/// Nested hierarchical table-of-contents tree node derived from flat page headings.
268#[derive(Clone, Data, Debug, Deserialize, PartialEq, Serialize)]
269pub struct DocTocTreeNode {
270    /// Heading item at this tree node.
271    pub(crate) item: DocTocItem,
272    /// Ordered deeper-level child headings nested beneath this heading.
273    #[serde(default, skip_serializing_if = "Vec::is_empty")]
274    pub(crate) children: Vec<DocTocTreeNode>,
275}
276
277/// Single published project artifact returned by `/api/page-artifacts` and rendered in Rust.
278#[derive(Clone, Debug, Default, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
279pub struct DocsCatalogArtifact {
280    /// Published project or qualified `org/repo` artifact name.
281    pub(crate) name: String,
282    /// Total number of files in the published artifact.
283    #[get(type(copy))]
284    pub(crate) file_count: u64,
285    /// Total artifact payload size in raw bytes.
286    #[get(type(copy))]
287    pub(crate) total_bytes: u64,
288    /// Hex-encoded lowercase SHA-256 digest of the artifact.
289    pub(crate) sha256: String,
290    /// Publication timestamp as Unix epoch seconds (UTC).
291    #[get(type(copy))]
292    pub(crate) updated_at: i64,
293}
294
295/// Compact search index record serialized into `search-index.json` and embedded client search.
296#[derive(Clone, Debug, Deserialize, Eq, Getter, New, PartialEq, Serialize)]
297pub struct SearchIndexEntry {
298    /// Canonical route path for navigation.
299    pub(crate) route: String,
300    /// Document title.
301    pub(crate) title: String,
302    /// Section category label.
303    pub(crate) section: String,
304    /// Short page description or lead excerpt.
305    pub(crate) summary: String,
306    /// Concatenated heading titles for keyword matching.
307    pub(crate) headings: Vec<String>,
308    /// Plain-text searchable body excerpt.
309    pub(crate) excerpt: String,
310}
311
312/// Table-of-contents heading entry derived from a parsed document.
313#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
314pub struct DocTocItem {
315    /// Heading depth from 1 to 6.
316    #[get(type(copy))]
317    pub(crate) level: u8,
318    /// Anchor slug for jump navigation.
319    pub(crate) slug: String,
320    /// Display title text.
321    pub(crate) title: String,
322}
323
324/// Fully parsed documentation page ready for native rendering or static generation.
325#[derive(Clone, Debug, Deserialize, Getter, New, PartialEq, Serialize)]
326pub struct DocPage {
327    /// Canonical route path (for example `/guide/getting-started`).
328    pub(crate) route: String,
329    /// Resolved page title.
330    pub(crate) title: String,
331    /// Sidebar sort order.
332    #[get(type(copy))]
333    pub(crate) order: i32,
334    /// Section category label.
335    pub(crate) section: String,
336    /// Short summary or tagline.
337    pub(crate) summary: String,
338    /// Structured Markdown content blocks.
339    #[serde(default, skip_serializing_if = "Vec::is_empty")]
340    pub(crate) blocks: Vec<DocBlock>,
341    /// Table-of-contents headings.
342    pub(crate) toc: Vec<DocTocItem>,
343    /// Preserved Markdown body text (after frontmatter) for full-fidelity HTML and native rendering.
344    #[serde(default, skip_serializing_if = "String::is_empty")]
345    #[get(pub(crate))]
346    #[new(skip)]
347    pub(crate) markdown_body: String,
348    /// Optional last-updated date or version stamp parsed from frontmatter.
349    #[serde(default, skip_serializing_if = "Option::is_none")]
350    #[new(skip)]
351    pub(crate) updated: Option<String>,
352    /// Whether this page declares `home: true` in frontmatter.
353    #[serde(default)]
354    #[get(type(copy))]
355    #[new(skip)]
356    pub(crate) is_home: bool,
357    /// Optional hero display heading for home pages.
358    #[serde(default, skip_serializing_if = "Option::is_none")]
359    #[new(skip)]
360    pub(crate) hero_text: Option<String>,
361    /// Landing-page call-to-action buttons.
362    #[serde(default, skip_serializing_if = "Vec::is_empty")]
363    #[new(skip)]
364    pub(crate) actions: Vec<DocHomeAction>,
365    /// Landing-page metric tiles.
366    #[serde(default, skip_serializing_if = "Vec::is_empty")]
367    #[new(skip)]
368    pub(crate) stats: Vec<DocHomeStat>,
369    /// Landing-page feature and product cards.
370    #[serde(default, skip_serializing_if = "Vec::is_empty")]
371    #[new(skip)]
372    pub(crate) features: Vec<DocHomeFeature>,
373    /// When `true`, hides this page from the sidebar navigation tree.
374    #[serde(default)]
375    #[get(type(copy))]
376    #[new(skip)]
377    pub(crate) hide_sidebar: bool,
378    /// Relative forward-slash filesystem path inside the locale root (e.g. `"euv/core/README.md"`).
379    #[serde(default, skip_serializing_if = "String::is_empty")]
380    #[new(skip)]
381    pub(crate) source_rel_path: String,
382    /// Whether this document originated from a directory `README.md` or `index.md` file.
383    #[serde(default)]
384    #[get(type(copy))]
385    #[new(skip)]
386    pub(crate) is_dir_index: bool,
387    /// Whether directory README indexing is disabled via `index: false` frontmatter.
388    #[serde(default)]
389    #[get(type(copy))]
390    #[new(skip)]
391    pub(crate) index_disabled: bool,
392    /// Optional initial directory expansion override parsed from `expanded: true|false`.
393    #[serde(default, skip_serializing_if = "Option::is_none")]
394    #[get(type(copy))]
395    #[new(skip)]
396    pub(crate) dir_expanded: Option<bool>,
397    /// Optional directory sort order parsed from `dir.order`.
398    #[serde(default, skip_serializing_if = "Option::is_none")]
399    #[get(type(copy))]
400    #[new(skip)]
401    pub(crate) dir_order: Option<i32>,
402    /// Optional directory display text override parsed from `dir.text`.
403    #[serde(default, skip_serializing_if = "Option::is_none")]
404    #[new(skip)]
405    pub(crate) dir_text: Option<String>,
406    /// Optional directory collapsible flag parsed from `dir.collapsible`.
407    #[serde(default, skip_serializing_if = "Option::is_none")]
408    #[get(type(copy))]
409    #[new(skip)]
410    pub(crate) dir_collapsible: Option<bool>,
411    /// Optional effective password protecting this page (declared directly or inherited from a parent directory README).
412    #[serde(default, skip_serializing_if = "Option::is_none")]
413    #[new(skip)]
414    pub(crate) password: Option<String>,
415    /// Optional publication date string parsed from `date:` frontmatter.
416    #[serde(default, skip_serializing_if = "Option::is_none")]
417    #[new(skip)]
418    pub(crate) date: Option<String>,
419    /// Optional category tags parsed from `category:` frontmatter.
420    #[serde(default, skip_serializing_if = "Vec::is_empty")]
421    #[new(skip)]
422    pub(crate) categories: Vec<String>,
423}
424
425/// Collection of parsed documentation pages forming a complete site or locale bundle.
426#[derive(Clone, Data, Debug, Deserialize, New, PartialEq, Serialize)]
427pub struct DocSite {
428    /// Site brand title.
429    pub(crate) title: String,
430    /// Site description tagline.
431    pub(crate) tagline: String,
432    /// Ordered documentation pages.
433    pub(crate) pages: Vec<DocPage>,
434    /// Active BCP 47 HTML language tag (e.g. `"en-US"`, `"zh-CN"`).
435    #[serde(default, skip_serializing_if = "String::is_empty")]
436    #[new(skip)]
437    pub(crate) lang: String,
438    /// Active locale route prefix (e.g. `"/"`, `"/en/"`).
439    #[serde(default, skip_serializing_if = "String::is_empty")]
440    #[new(skip)]
441    pub(crate) locale_prefix: String,
442    /// Optional brand logo URL.
443    #[serde(default, skip_serializing_if = "String::is_empty")]
444    #[new(skip)]
445    pub(crate) logo: String,
446    /// Localized footer attribution line.
447    #[serde(default, skip_serializing_if = "String::is_empty")]
448    #[new(skip)]
449    pub(crate) footer: String,
450    /// Optional URL opened by clicking the primary footer attribution text.
451    #[serde(default, skip_serializing_if = "String::is_empty")]
452    #[new(skip)]
453    pub(crate) footer_link: String,
454    /// Externally supplied footer links and optional local icons.
455    #[serde(default, skip_serializing_if = "Vec::is_empty")]
456    #[new(skip)]
457    pub(crate) footer_items: Vec<DocFooterItem>,
458    /// Localized table-of-contents heading label.
459    #[serde(default, skip_serializing_if = "String::is_empty")]
460    #[new(skip)]
461    pub(crate) toc_label: String,
462    /// Localized previous-page pager label.
463    #[serde(default, skip_serializing_if = "String::is_empty")]
464    #[new(skip)]
465    pub(crate) prev_label: String,
466    /// Localized next-page pager label.
467    #[serde(default, skip_serializing_if = "String::is_empty")]
468    #[new(skip)]
469    pub(crate) next_label: String,
470    /// Localized top navbar links.
471    #[serde(default, skip_serializing_if = "Vec::is_empty")]
472    #[new(skip)]
473    pub(crate) navbar: Vec<DocNavbarItem>,
474    /// Available site locales for the language switcher.
475    #[serde(default, skip_serializing_if = "Vec::is_empty")]
476    #[new(skip)]
477    pub(crate) locales: Vec<DocLocaleConfig>,
478    /// Embedded release version marker carried in serialized WASM site bundles.
479    #[serde(default, skip_serializing_if = "String::is_empty")]
480    #[new(skip)]
481    pub(crate) release_marker: String,
482}