Skip to content

Revamp config code #287

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

Merged
merged 9 commits into from
Jun 5, 2017
Merged

Revamp config code #287

merged 9 commits into from
Jun 5, 2017

Conversation

azerupi
Copy link
Contributor

@azerupi azerupi commented May 18, 2017

This is a rewrite of the configuration code for the TOML configuration push #285
The JSON configuration should remain unchanged, but is deprecated. Unless we want to support both?

The supported TOML format has been changed to the following:

title = "A book about nothing"
description = "A large book that tells no story"
author = "John Doe"
# authors = ["John Doe", "Jane Doe"]   <-- multiple authors
source = "path/to/src"

[output.html]
destination = "path/to/dest"
theme = "path/to/them"
google-analytics = "123456"

I have also added tests for each key, both in TOML and JSON.

The other files that use the configs have only gotten changes necessary to compile and work. But by going through the code for the changes I realised how ugly my code is... 😄 I think changing the rest is out of scope for this PR, but there is a lot of opportunity for clean-ups.

Closes #285, closes #178, closes #240 and improves the test coverage.

@azerupi azerupi force-pushed the toml-config branch 2 times, most recently from 3cf3d20 to c9dfd1e Compare May 20, 2017 12:37
@azerupi
Copy link
Contributor Author

azerupi commented May 20, 2017

Ok, this PR is ready for review. I have implemented all the things from #285

@azerupi azerupi requested review from steveklabnik and frewsxcv May 20, 2017 13:07
@azerupi azerupi added this to the 0.1.0 milestone May 20, 2017
Copy link
Member

@frewsxcv frewsxcv left a comment

Choose a reason for hiding this comment

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

just skimmed this, everything seems fine to me 👌

src/book/mod.rs Outdated
}

/*
pub fn set_author(mut self, author: &str) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

do we still need these methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get and set author?
No, we can remove them. I would like to remove the other methods as well and provide a better way to access the configuration, but they are too pervasively used throughout the code and a little to ambitious for this PR.

@azerupi
Copy link
Contributor Author

azerupi commented May 31, 2017

Thanks! Let's wait to see if Steve wants to have a look before we merge :)

@budziq
Copy link
Contributor

budziq commented Jun 3, 2017

Hi,

I was thinking about removing duplication of fields between MDBook and BookConfig (most likely keep Option<BookConfig> within MDBook) add getters instead of direct field access (most likely also add builder here and there) for https://github.com/azerupi/mdBook/issues/301 but such refactor would clash with this work.

I'll wait until this gets merged and dust settles before making any proposals.

@azerupi
Copy link
Contributor Author

azerupi commented Jun 3, 2017

Oh yes, that would be a good refactor, when making this PR it was pretty painfull to update all the getters everywhere. Actually now I think MDBook should not even provide getters and setters but just have a method to get the config.

It's pretty safe to say that this PR is going to land soon without much changes. I'm just waiting to see if @steveklabnik wants to have a look before we do.

@budziq
Copy link
Contributor

budziq commented Jun 3, 2017

I think MDBook should not even provide getters and setters but just have a method to get the config.

My thoughts exactly :)

@steveklabnik
Copy link
Member

It's pretty safe to say that this PR is going to land soon without much changes. I'm just waiting to see if @steveklabnik wants to have a look before we do.

Yup! 👍

@steveklabnik steveklabnik merged commit 8a05f0d into master Jun 5, 2017
@azerupi azerupi deleted the toml-config branch August 1, 2017 14:32
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.

Push the TOML configuration as default some values are overwritten by read_config Add an empty, but included last, custom.css file
4 participants