Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow to serialize the "build" section #1378

Merged
merged 1 commit into from
Nov 12, 2020

Conversation

daynin
Copy link
Contributor

@daynin daynin commented Nov 10, 2020

Without this change it's impossible to setup build parameters through API like that:

use mdbook::MDBook;
use mdbook::config::Config;

let root_dir = "/path/to/book/root";

let mut cfg = Config::default();
cfg.book.title = Some("My Book".to_string());
cfg.book.authors.push("Michael-F-Bryan".to_string());

cfg.build.build_dir = PathBuf::from("output"); <---------------- we can set it, but it won't be serialized

MDBook::init(root_dir)
    .create_gitignore(true)
    .with_config(cfg)
    .build()
    .expect("Book generation failed");

@ehuss
Copy link
Contributor

ehuss commented Nov 10, 2020

Thanks! A problem with this change is that mdbook init will start the book.toml file with a [build] section. Can it maybe use the same check for default as the [rust] table uses?

@daynin daynin force-pushed the serialize-build-section branch 2 times, most recently from a65fb76 to 9e89442 Compare November 11, 2020 08:06
@daynin
Copy link
Contributor Author

daynin commented Nov 11, 2020

@ehuss yes, of course. I did it

@ehuss
Copy link
Contributor

ehuss commented Nov 11, 2020

Sorry, forgot to ask, can you add a test for this? It looks like run_mdbook_init_with_custom_book_and_src_locations could just be updated to have an assert_eq! of the contents of book.toml, similar to how base_mdbook_init_should_create_default_content works.

@daynin
Copy link
Contributor Author

daynin commented Nov 12, 2020

@ehuss done

Copy link
Contributor

@ehuss ehuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ehuss ehuss merged commit 552e337 into rust-lang:master Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants