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
Add Rust documentation check to GitHub Actions #937
Conversation
This reverts commit eb49433.
env: | ||
RUSTDOCFLAGS: "-D warnings" | ||
with: | ||
command: doc | ||
args: --all-features --no-deps --workspace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we build it the way docs.rs builds the documentation, so we don't run into the 0.6
doc problems again?
So specifically using nightly and --cfg docsrs
. So:
RUSTDOCFLAGS='-D warnings --cfg docsrs' cargo +nightly doc --all-features --no-deps --workspace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, will do done.
Is the docsrs
config really necessary in our code though?
For example, the double cfg
features in identty_iota
?
#[cfg(feature = "account")]
#[cfg_attr(docsrs, doc(cfg(feature = "account")))]
pub mod account_storage {
Edit: should we specify the features in Cargo.toml
instead or something? Not sure what the best practice is.
E.g.
[package.metadata.docs.rs]
features = [ "account", "..." ]
Edit2: we currently have all-features
though, so probably unnecessary.
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The double-cfg is necessary I think, since #[doc(cfg(...))]
is unstable. It's how crypto.rs does it, too. I mainly copied their approach: https://github.com/iotaledger/crypto.rs/blob/94be7913f11018467edb64c3d126ab682c29edcf/src/signatures/mod.rs#L5.
Yes, I think all-features = true
in the toml metadata should be fine.
Description of change
Build Rust documentation in CI to catch broken links early. The new check is relatively fast at ~5 minutes, so should not slow down the overall CI, especially when run in parallel with much larger jobs.
Type of change
How the change has been tested
To test locally, change one of the documentation links in a Rust file to be incorrect.
Then run:
RUSTDOCFLAGS="-D warnings" cargo doc --all-features --no-deps --workspace
It should print an error similar to the one below and exit with code 1:
Change checklist
Add an
x
to the boxes that are relevant to your changes.