@@ -54,7 +54,8 @@ impl Config {
54
54
/// # Note
55
55
///
56
56
/// This is for compatibility only. It will be removed completely once the
57
- /// rendering and plugin system is established.
57
+ /// HTML renderer is refactored to be less coupled to `mdbook` internals.
58
+ #[ doc( hidden) ]
58
59
pub fn html_config ( & self ) -> Option < HtmlConfig > {
59
60
self . get_deserialized ( "output.html" ) . ok ( )
60
61
}
@@ -75,6 +76,9 @@ impl Config {
75
76
}
76
77
77
78
/// Set a config key, clobbering any existing values along the way.
79
+ ///
80
+ /// The only way this can fail is if we can't serialize `value` into a
81
+ /// `toml::Value`.
78
82
pub fn set < S : Serialize , I : AsRef < str > > ( & mut self , index : I , value : S ) -> Result < ( ) > {
79
83
let pieces: Vec < _ > = index. as_ref ( ) . split ( "." ) . collect ( ) ;
80
84
let value =
@@ -123,6 +127,11 @@ impl Config {
123
127
}
124
128
}
125
129
130
+ /// Recursively walk down a table and try to set some `foo.bar.baz` value.
131
+ ///
132
+ /// If at any table along the way doesn't exist (or isn't itself a `Table`!) an
133
+ /// empty `Table` will be inserted. e.g. if the `foo` table didn't contain a
134
+ /// nested table called `bar`, we'd insert one and then keep recursing.
126
135
fn recursive_set ( key : & [ & str ] , table : & mut Table , value : Value ) {
127
136
if key. is_empty ( ) {
128
137
unreachable ! ( ) ;
@@ -143,6 +152,7 @@ fn recursive_set(key: &[&str], table: &mut Table, value: Value) {
143
152
}
144
153
}
145
154
155
+ /// The "getter" version of `recursive_set()`.
146
156
fn recursive_get < ' a > ( key : & [ & str ] , table : & ' a Table ) -> Option < & ' a Value > {
147
157
if key. is_empty ( ) {
148
158
return None ;
@@ -160,6 +170,7 @@ fn recursive_get<'a>(key: &[&str], table: &'a Table) -> Option<&'a Value> {
160
170
}
161
171
}
162
172
173
+ /// The mutable version of `recursive_get()`.
163
174
fn recursive_get_mut < ' a > ( key : & [ & str ] , table : & ' a mut Table ) -> Option < & ' a mut Value > {
164
175
// TODO: Figure out how to abstract over mutability to reduce copy-pasta
165
176
if key. is_empty ( ) {
@@ -248,7 +259,6 @@ fn is_legacy_format(table: &Table) -> bool {
248
259
. any ( |key| table. contains_key ( & key. to_string ( ) ) )
249
260
}
250
261
251
-
252
262
/// Configuration options which are specific to the book and required for
253
263
/// loading it from disk.
254
264
#[ derive( Debug , Clone , PartialEq , Serialize , Deserialize ) ]
@@ -308,7 +318,7 @@ pub struct HtmlConfig {
308
318
pub additional_css : Vec < PathBuf > ,
309
319
pub additional_js : Vec < PathBuf > ,
310
320
pub playpen : Playpen ,
311
- /// This is used as a bit of a workaround for the `mdbook serve` command.
321
+ /// This is used as a bit of a workaround for the `mdbook serve` command.
312
322
/// Basically, because you set the websocket port from the command line, the
313
323
/// `mdbook serve` command needs a way to let the HTML renderer know where
314
324
/// to point livereloading at, if it has been enabled.
@@ -335,7 +345,6 @@ impl Default for Playpen {
335
345
}
336
346
}
337
347
338
-
339
348
#[ cfg( test) ]
340
349
mod tests {
341
350
use super :: * ;
0 commit comments