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    pub(crate) blocks: Vec<DocBlock>,
252    /// Table-of-contents headings.
253    pub(crate) toc: Vec<DocTocItem>,
254    /// Preserved Markdown body text (after frontmatter) for full-fidelity HTML and native rendering.
255    #[serde(default, skip_serializing_if = "String::is_empty")]
256    #[get(pub(crate))]
257    #[new(skip)]
258    pub(crate) markdown_body: String,
259    /// Optional last-updated date or version stamp parsed from frontmatter.
260    #[serde(default, skip_serializing_if = "Option::is_none")]
261    #[new(skip)]
262    pub(crate) updated: Option<String>,
263    /// Whether this page declares `home: true` in frontmatter.
264    #[serde(default)]
265    #[get(type(copy))]
266    #[new(skip)]
267    pub(crate) is_home: bool,
268    /// Optional hero display heading for home pages.
269    #[serde(default, skip_serializing_if = "Option::is_none")]
270    #[new(skip)]
271    pub(crate) hero_text: Option<String>,
272    /// Landing-page call-to-action buttons.
273    #[serde(default, skip_serializing_if = "Vec::is_empty")]
274    #[new(skip)]
275    pub(crate) actions: Vec<DocHomeAction>,
276    /// Landing-page metric tiles.
277    #[serde(default, skip_serializing_if = "Vec::is_empty")]
278    #[new(skip)]
279    pub(crate) stats: Vec<DocHomeStat>,
280    /// Landing-page feature and product cards.
281    #[serde(default, skip_serializing_if = "Vec::is_empty")]
282    #[new(skip)]
283    pub(crate) features: Vec<DocHomeFeature>,
284    /// When `true`, hides this page from the sidebar navigation tree.
285    #[serde(default)]
286    #[get(type(copy))]
287    #[new(skip)]
288    pub(crate) hide_sidebar: bool,
289}
290
291/// Collection of parsed documentation pages forming a complete site or locale bundle.
292#[derive(Clone, Data, Debug, Deserialize, New, PartialEq, Serialize)]
293pub struct DocSite {
294    /// Site brand title.
295    pub(crate) title: String,
296    /// Site description tagline.
297    pub(crate) tagline: String,
298    /// Ordered documentation pages.
299    pub(crate) pages: Vec<DocPage>,
300    /// Active BCP 47 HTML language tag (e.g. `"en-US"`, `"zh-CN"`).
301    #[serde(default, skip_serializing_if = "String::is_empty")]
302    #[new(skip)]
303    pub(crate) lang: String,
304    /// Active locale route prefix (e.g. `"/"`, `"/en/"`).
305    #[serde(default, skip_serializing_if = "String::is_empty")]
306    #[new(skip)]
307    pub(crate) locale_prefix: String,
308    /// Optional brand logo URL.
309    #[serde(default, skip_serializing_if = "String::is_empty")]
310    #[new(skip)]
311    pub(crate) logo: String,
312    /// Localized footer attribution line.
313    #[serde(default, skip_serializing_if = "String::is_empty")]
314    #[new(skip)]
315    pub(crate) footer: String,
316    /// Optional URL opened by clicking the primary footer attribution text.
317    #[serde(default, skip_serializing_if = "String::is_empty")]
318    #[new(skip)]
319    pub(crate) footer_link: String,
320    /// Externally supplied footer links and optional local icons.
321    #[serde(default, skip_serializing_if = "Vec::is_empty")]
322    #[new(skip)]
323    pub(crate) footer_items: Vec<DocFooterItem>,
324    /// Localized table-of-contents heading label.
325    #[serde(default, skip_serializing_if = "String::is_empty")]
326    #[new(skip)]
327    pub(crate) toc_label: String,
328    /// Localized previous-page pager label.
329    #[serde(default, skip_serializing_if = "String::is_empty")]
330    #[new(skip)]
331    pub(crate) prev_label: String,
332    /// Localized next-page pager label.
333    #[serde(default, skip_serializing_if = "String::is_empty")]
334    #[new(skip)]
335    pub(crate) next_label: String,
336    /// Localized top navbar links.
337    #[serde(default, skip_serializing_if = "Vec::is_empty")]
338    #[new(skip)]
339    pub(crate) navbar: Vec<DocNavbarItem>,
340    /// Available site locales for the language switcher.
341    #[serde(default, skip_serializing_if = "Vec::is_empty")]
342    #[new(skip)]
343    pub(crate) locales: Vec<DocLocaleConfig>,
344    /// Embedded release version marker carried in serialized WASM site bundles.
345    #[serde(default, skip_serializing_if = "String::is_empty")]
346    #[new(skip)]
347    pub(crate) release_marker: String,
348}