disincentivize usage of functions that expose toml::Table in Config #2407
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
hi there,
firstly, thank you for your continued work on mdbook, it's a great tool :)
This is related to #2037, which I encountered while trying to deserialize the exposed
Map
/Table
into a user defined struct in a preprocessor I'm writing.Using
get_deserialized_opt
seems much more preferable toget_preprocessor
(andget_renderer
for that matter).However, I merely happend to stumble across that function while looking through
config.rs
.I don't think I'm alone with this, I did a brief search over the preprocessors listed in the third party plugins page and the ones that do have options use
get_preprocessor
.The one caveat for
get_deserialized_opt
is that you have to pass"preprocessor.my_thing"
instead of"my_thing"
, so I madeget_renderer_deserialized
andget_preprocessor_deserialized
for convenience.I added that to the example to incentivize people writing new preprocessors to use it.
I also marked
get_renderer
andget_preprocessor
as deprecated. However this might be bold. There are probably valid use cases for these functions, unless mdbook were to remove the exposed toml type(s) like #2037 describes (which would significantly changemdbook::config::Config
's interface).Note that this also results in 3 deprecation warnings in the tests.
I haven't addresses these, because I think the decision whether to deprecate them at all should be done by the maintainers, I'm just a user of the library/tool.