Merge pull request #2800 from ehuss/no-default-src

Don't serialize the default for `book.src`
This commit is contained in:
Eric Huss 2025-08-16 22:27:53 +00:00 committed by GitHub
commit 0f0d1f3377
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 4 deletions

View file

@ -297,6 +297,7 @@ pub struct BookConfig {
/// An optional description for the book.
pub description: Option<String>,
/// Location of the book source relative to the book's root directory.
#[serde(skip_serializing_if = "is_default_src")]
pub src: PathBuf,
/// The main language of the book.
pub language: Option<String>,
@ -305,6 +306,11 @@ pub struct BookConfig {
pub text_direction: Option<TextDirection>,
}
/// Helper for serde serialization.
fn is_default_src(src: &PathBuf) -> bool {
src == Path::new("src")
}
impl Default for BookConfig {
fn default() -> BookConfig {
BookConfig {

View file

@ -28,7 +28,6 @@ All done, no errors...
str![[r#"
[book]
authors = []
src = "src"
language = "en"
"#]],
@ -94,7 +93,6 @@ All done, no errors...
str![[r#"
[book]
authors = []
src = "src"
language = "en"
"#]],
@ -128,7 +126,6 @@ All done, no errors...
[book]
title = "Example title"
authors = []
src = "src"
language = "en"
"#]],

View file

@ -188,7 +188,6 @@ fn backends_receive_render_context_via_stdin() {
"authors": [],
"description": null,
"language": "en",
"src": "src",
"text-direction": null,
"title": null
},