-
-
Notifications
You must be signed in to change notification settings - Fork 60
doc: cross-platform with target tags #237
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
doc: cross-platform with target tags #237
Conversation
e243972
to
4602684
Compare
Allowed docs.rs to build for multiple OS. The experimental doc_cfg feature is used to tag module for its targeting OS.
1c81a47
to
49bbc99
Compare
49bbc99
to
0c473d7
Compare
@brotskydotcom The pr is ready to be review. For the last checkbox, maybe there is a good way to have some thing in the index crate docstring which |
Clearly there is a bug in CI file https://github.com/hwchen/keyring-rs/actions/runs/13550239365/workflow. |
56ce0d3
to
850793d
Compare
.github/workflows/ci.yaml
Outdated
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
toolchain: nightly | ||
targets: [x86_64-unknown-linux-gnu, aarch64-apple-darwin, aarch64-apple-ios, x86_64-pc-windows-msvc] |
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.
I am not sure about the syntax for setting multiple targets. Since every change and test require approve to trigger the CI, @brotskydotcom please fill free to directly add commit and change this.
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.
Nevermind, I test in my own crate, and works now with comma split target names. See the commit.
850793d
to
3d8da96
Compare
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.
I don't want to add unstable features to the code, because it breaks stable and MSRV builds. I will add fuller discussion of this to the PR.
src/lib.rs
Outdated
any(feature = "sync-secret-service", feature = "async-secret-service"), | ||
), | ||
all(target_os = "linux", feature = "linux-native-sync-persistent", doc), |
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.
This feels like overkill. The linux-native-sync-persistent feature turns on the sync-secret-service feature so all you really need to do is add "doc" to the list of features on line 224.
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.
You are right! simpler after using #[cfg_attr(docsrs, doc(cfg(target_os = "linux")))]
.
src/lib.rs
Outdated
any( | ||
feature = "linux-native-sync-persistent", | ||
feature = "linux-native-async-persistent", | ||
) | ||
), | ||
all(target_os = "linux", feature = "linux-native-sync-persistent", doc), |
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.
same comment as above, just add "doc" to line 243
I don't like adding unstable features to the build, for several reasons:
Since building the docs locally (with any target_os you can use locally) will get you the docs for all the modules you can use, and since rustdoc already posts the builds for all target os's except ios, I'm not sure we really need anything in this PR except to change the feature used by docs.rs to be If you really want the names of the other modules to be listed in every platform's build, the easiest way to do that would be to just have build on other platforms use the existing |
I've moved this back to draft status while you consider feedback. Let me know what you think. |
Thanks for the review!
Sure!
That's true, so confine it in the scope where only docrs cfg is set should do the trick, as did in the tokio-rs by having
This may not true, it is mentioned in https://docs.rs/about/builds, "All crates are built in a sandbox using the nightly release of the Rust compiler. ". |
OK, I get it. And, yes, I didn't realize the standard docs build runs on nightly - thanks for pointing that out. Please go ahead and make the change and let's try again once you've fixed the build script. |
0138cc0
to
127a3da
Compare
I addressed all comments, ready for another go. |
276a8b6
to
ac2a3b4
Compare
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.
OK, great! This looks much cleaner, thanks.
There is still one typo in the ci script, please fix that.
Please rename the file build-xplat-docs.sh
to test-docsrs-build.sh
since that's actually what it's for.
Also please fix the CI script as suggested in the failed build logs. |
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.
Thanks for the nice review, requests addressed.
not sure why |
Yes, we see this from time to time due to resource starvation in the CI process. I just rerun in those cases. |
d4a0873
to
307e575
Compare
d080ca5
to
5937f86
Compare
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.
Yes, very nice! Just one last little change and it's ready to pull, thanks!
5937f86
to
09c9c0d
Compare
Great, thanks for all the work on this. I'm going to pull it now, and then fix one more issue before releasing. |
f1b7ec1
into
open-source-cooperative:master
@unkcpz I just released 3.6.2 with this integrated - docs look great!! Thanks again for doing this. |
Thank you for the review! @brotskydotcom I looking forward to contribute more! |
ref #235
The goal of thi PR are:
keyutils
andkeyutils_persistent
module doc in platform dropdown of x86_64_linux target (see fig below).portal list redirect to platform links(may not worth to do it)The plans are to make the docs more friendly to easy redirect to correspond platform is build for each platform with all module section existed (the keyutils is missing for the linux at the moment). Then in the index page of the doc, having a list as the portal to different platform.
Allowed docs.rs to build for multiple OS.
The experimental doc_cfg feature is used to tag module for its targeting OS.
The caveat of this approach is not sure the docs.rs can properly display docs for all platform (I'll test with using docs.rs docker-compose to try locally, so I put it as draft). From what documented in https://docs.rs/about/metadata, and reference how it did in CI of security-framework crate. I think it will work.
I keep the
build-xplot-docs.sh
so it can be used to test the docs can be build for corresponding OS. It can maybe also server as the script for docs build test, if the approach of this PR adapted.UPDATE: apparently after test using docs.rs docker-compose locally, using
targets
in[package.metadata.docs.rs]
is NOT to have a single platform agnostic page to show all, but to have a platform dropdown that user can select which doc to look at (which is already there for the crate but I didn't realize, sorry about it). (see rust-lang/docs.rs#2749 for discussion)Note for local docs.rs test: