Document feature flags and scrape examples #672
Merged
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.
Objective
Why did you make this PR?
I noticed that the feature flags were not documented and added these
changes so the library documentation is kept perpetually updated.
crate to automatically add documentation about the features to the
crate documentation at the crate level.
to every item that requires a feature flag to be enabled. This is
behind a docsrs feature flag as it can only be enabled using the
nightly toolchain and this allows the documentation to be built with
the stable toolchain when the feature is not enabled. See
https://doc.rust-lang.org/rustdoc/unstable-features.html#doc_auto_cfg-automatically-generate-doccfg
for more information.
unstable rustdoc-scrape-examples feature. See
https://doc.rust-lang.org/nightly/rustdoc/scraped-examples.html for
more information.
To test this change, run:
RUSTDOCFLAGS="--cfg docsrs" \ cargo +nightly doc \ -Zunstable-options -Zrustdoc-scrape-examples \ --all-features --no-deps --open
Context
Discuss any context that may be needed for reviewers to understand the changes you've made.
This may include related issues, previous discussion, or links to documentation or code.
New docs rendered on crate page:
Feature flags noted on item lists
Feature flags noted on items
Scraped examples
Feedback wanted
The command to generate the docs with all features enabled can't be added to the .cargo/config.toml as an alias because custom rustdoc flags and the nightly toolchain are needed. In other projects I've added this to a cargo-make file, a just file, or a bacon config file as a job. A small script similar to the existing ones could also be added to run this perhaps if needed (though cargo-xtask might be a reasonable approach to this more generically). Or perhaps just a shell script somewhere would also work as a shortcut. I'm not sure what's idiomatic for taffy devs on this sort of thing.