Skip to content
New issue

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

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

Already on GitHub? # to your account

Enable crate feature info in rustdocs #371

Merged
merged 2 commits into from
Jan 11, 2022
Merged

Enable crate feature info in rustdocs #371

merged 2 commits into from
Jan 11, 2022

Conversation

clehner
Copy link
Contributor

@clehner clehner commented Jan 7, 2022

As mentioned in #360 (comment)

The doc_cfg and doc_auto_cfg features are described in rust-lang/rust#90502 and enable rustdocs to render uses of #[cfg(feature = ...]). These features are enabled using a cfg attribute docsrs which is enabled in Cargo.toml for docs.rs. Since doc_cfg and doc_auto_cfg are unstable features, this docsrs attribute is left disabled by default. It can also be enabled on the command-line as in the following command to build the docs using a nightly toolchain (Run rustup update nightly first if you haven't installed nightly recently):
RUSTDOCFLAGS='--cfg docsrs' cargo +nightly doc --no-deps --features secp256r1,secp256k1,ripemd-160,http-did

After building docs with that command, open target/doc/ssi/hash/fn.sha256.html:
Screenshot of ssi::hash::sha256 rustdocs with feature info

Features secp256r1,secp256k1,ripemd-160,http-did are set as enabled by default for the docs.rs build (from 883f3c4 in #311).

I combined the two sha256 function implementations into one function, as I wasn't otherwise able to get the docs to list its supported crate features as "sha2 or ring". (Similar: rust-lang/rust#90497 (comment))

@clehner clehner requested a review from sbihel January 7, 2022 16:25
@clehner clehner merged commit 7e5eb4d into main Jan 11, 2022
@clehner clehner deleted the feat/docs-features branch January 11, 2022 14:05
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants