1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//!
//! <div class="warning">
//! You are currently reading Maudit API reference. For a more gentle introduction, please refer to our <a href="https://maudit.org/docs">documentation</a>.
//! </div>
// Modules the end-user will interact directly or indirectly with
// Exports for end-users
pub use ;
pub use ;
pub use ;
// Re-export FxHashMap so that macro-generated code can use it without requiring users to add it as a dependency.
pub use FxHashMap;
// Internal modules
use env;
use execute_build;
use ContentSources;
use init_logging;
use FullRoute;
/// Returns whether Maudit is running in development mode (through `maudit dev`).
///
/// This can be useful to conditionally enable features or logging that should only be active during development.
/// Oftentimes, this is used to disable some expensive operations that would slow down build times during development.
/// Helps to define every route that should be build by [`coronate()`].
///
/// ## Example
/// ```rust
/// use maudit::{
/// content_sources, coronate, routes, BuildOptions, BuildOutput,
/// };
///
/// # mod routes {
/// # use maudit::route::prelude::*;
/// #
/// # #[route("/")]
/// # pub struct Index;
/// # impl Route for Index {
/// # fn render(&self, _ctx: &mut PageContext) -> impl Into<RenderResult> {
/// # "Hello, world!"
/// # }
/// # }
/// #
/// # #[route("/article")]
/// # pub struct Article;
/// #
/// # impl Route for Article {
/// # fn render(&self, _ctx: &mut PageContext) -> impl Into<RenderResult> {
/// # "Hello, world!"
/// # }
/// # }
/// # }
///
/// fn main() -> Result<BuildOutput, Box<dyn std::error::Error>> {
/// coronate(
/// routes![routes::Index, routes::Article],
/// content_sources![],
/// BuildOptions::default(),
/// )
/// }
/// ```
///
;
}
/// Helps to define all sources of content that should be loaded by [`coronate()`].
///
/// ## Example
/// ```rust
/// use maudit::{
/// content_sources, coronate, routes, BuildOptions, BuildOutput,
/// };
/// use maudit::content::{glob_markdown, markdown_entry};
///
/// #[markdown_entry]
/// pub struct ArticleContent {
/// pub title: String,
/// pub description: String,
/// }
///
/// fn main() -> Result<BuildOutput, Box<dyn std::error::Error>> {
/// coronate(
/// routes![],
/// content_sources![
/// "articles" => glob_markdown::<ArticleContent>("content/articles/*.md")
/// ],
/// BuildOptions::default(),
/// )
/// }
/// ```
///
/// ## Expand
/// ```rust
/// # use maudit::{content_sources};
/// # use maudit::content::{glob_markdown, markdown_entry};
/// # #[markdown_entry]
/// # pub struct ArticleContent {
/// # pub title: String,
/// # pub description: String,
/// # }
///
/// content_sources![
/// "articles" => glob_markdown::<ArticleContent>("content/articles/*.md")
/// ];
/// ```
/// expands to
/// ```rust
/// # use maudit::content::{glob_markdown, markdown_entry};
/// # #[markdown_entry]
/// # pub struct ArticleContent {
/// # pub title: String,
/// # pub description: String,
/// # }
///
/// maudit::content::ContentSources(vec![
/// Box::new(maudit::content::ContentSource::new("articles", Box::new(move || glob_markdown::<ArticleContent>("content/articles/*.md"))))
/// ]);
/// The version of Maudit being used.
///
/// Can be used to create a generator tag in the output HTML.
///
/// ## Example
/// ```rust
/// use maudit::GENERATOR;
///
/// format!("<meta name=\"generator\" content=\"{}\">", GENERATOR);
/// ```
pub const GENERATOR: &str = concat!;
/// 👑 Maudit entrypoint. Starts the build process and generates the output files.
///
/// ## Example
/// Should be called from the main function of the binary crate.
/// ```rust
/// use maudit::{
/// content_sources, coronate, routes, BuildOptions, BuildOutput,
/// };
///
/// fn main() -> Result<BuildOutput, Box<dyn std::error::Error>> {
/// coronate(
/// routes![],
/// content_sources![],
/// BuildOptions::default(),
/// )
/// }
/// ```