1use eure::ParseDocument;
4use eure_document::map::Map;
5
6#[derive(Debug, Clone, PartialEq, ParseDocument)]
8#[eure(crate = ::eure::document)]
9pub struct EumdDocument {
10 #[eure(ext, default)]
12 pub schema: Option<String>,
13
14 pub title: String,
16
17 #[eure(default)]
19 pub authors: Vec<Author>,
20
21 #[eure(default)]
23 pub date: Option<String>,
24
25 #[eure(default)]
27 pub tags: Vec<String>,
28
29 #[eure(default)]
31 pub draft: Option<bool>,
32
33 #[eure(default)]
35 pub description: Option<String>,
36
37 #[eure(default)]
39 pub cites: Option<String>,
40
41 #[eure(default)]
43 pub footnotes: Map<String, Footnote>,
44
45 #[eure(default)]
47 pub intro: Option<String>,
48
49 #[eure(default)]
51 pub sections: Map<String, Section>,
52}
53
54#[derive(Debug, Clone, PartialEq, ParseDocument)]
56#[eure(crate = ::eure::document)]
57pub enum Author {
58 Detailed(DetailedAuthor),
60
61 Simple(String),
63}
64
65#[derive(Debug, Clone, PartialEq, ParseDocument)]
67#[eure(crate = ::eure::document)]
68pub struct DetailedAuthor {
69 pub name: String,
70 #[eure(default)]
71 pub affiliation: Option<String>,
72 #[eure(default)]
73 pub email: Option<String>,
74 #[eure(default)]
75 pub url: Option<String>,
76}
77
78#[derive(Debug, Clone, PartialEq, ParseDocument)]
80#[eure(crate = ::eure::document)]
81pub struct Footnote {
82 pub content: String,
84}
85
86#[derive(Debug, Clone, PartialEq, ParseDocument)]
88#[eure(crate = ::eure::document)]
89pub struct Section {
90 #[eure(default)]
92 pub header: Option<String>,
93
94 #[eure(default)]
96 pub body: Option<String>,
97
98 #[eure(default)]
100 pub sections: Map<String, Section>,
101}
102
103impl EumdDocument {
104 pub fn get_section_header<'a>(key: &'a str, section: &'a Section) -> &'a str {
106 section.header.as_deref().unwrap_or(key)
107 }
108}