-
Notifications
You must be signed in to change notification settings - Fork 13k
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
rustdoc: Split out rustdoc pass to strip private imports #32055
Conversation
774c8f1
to
5671166
Compare
cc @SimonSapin |
9d8f63e
to
745c7cf
Compare
impl fold::DocFolder for ImportStripper { | ||
fn fold_item(&mut self, i: Item) -> Option<Item> { | ||
match i.inner { | ||
clean::ExternCrateItem(..) | |
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 should also test visibility, right? #31362 made pub extern crate
meaningful.
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 think the pattern guard on the next line should take care of that (?) 😃
Or do you mean a rustdoc test? I've added one since there doesn't appear to be any rustdoc test for pub extern crate
.
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.
Never mind, I read this code too quickly and didn’t realize these two lines are the same match
arm :)
Nice! This should make pages like http://doc.servo.org/servo/index.html#reexports much less noisy. Thanks @mitaa! |
745c7cf
to
180b1a9
Compare
(highfive might be awake again) |
180b1a9
to
688e522
Compare
@@ -106,7 +106,7 @@ pub fn strip_private(mut krate: clean::Crate) -> plugins::PluginResult { | |||
retained: &mut retained, | |||
access_levels: &access_levels, | |||
}; | |||
krate = stripper.fold_crate(krate); | |||
krate = ImportStripper.fold_crate(stripper.fold_crate(krate)); |
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.
Now that this change hit Nightly I’m trying it out but I’m surprised to not see strip-priv-imports
listed in the default passes in rustdoc --passes list
. As far as I understand it’s indeed not a default pass, but this line makes it implied by strip-private
. This is not exactly wrong, but at least confusing.
Maybe add “, implies strip-priv-imports
” should be added to the description for strip-private
in src/librustdoc/lib.rs
?
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, I think that'd be a good idea. I'll submit a PR later if you or someone else hasn't by then.
rust-lang/rust#32055 This will make e.g. http://doc.servo.org/servo/index.html#reexports stop listing `extern crate` and `use` statements that don’t have `pub`.
Use rustdoc’s new `--passes strip-priv-imports` flag. rust-lang/rust#32055 This will make e.g. http://doc.servo.org/servo/index.html#reexports stop listing `extern crate` and `use` statements that don’t have `pub`. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9894) <!-- Reviewable:end -->
Use rustdoc’s new `--passes strip-priv-imports` flag. rust-lang/rust#32055 This will make e.g. http://doc.servo.org/servo/index.html#reexports stop listing `extern crate` and `use` statements that don’t have `pub`. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9894) <!-- Reviewable:end -->
Use rustdoc’s new `--passes strip-priv-imports` flag. rust-lang/rust#32055 This will make e.g. http://doc.servo.org/servo/index.html#reexports stop listing `extern crate` and `use` statements that don’t have `pub`. <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9894) <!-- Reviewable:end -->
…flag (from servo:strip-priv-imports); r=Ms2ger rust-lang/rust#32055 This will make e.g. http://doc.servo.org/servo/index.html#reexports stop listing `extern crate` and `use` statements that don’t have `pub`. Source-Repo: https://github.com/servo/servo Source-Revision: 1453f438256afe92b0f79980c984824aac4afeae UltraBlame original commit: 8429d073276a3daeb5d4403ad44274bc39113092
…flag (from servo:strip-priv-imports); r=Ms2ger rust-lang/rust#32055 This will make e.g. http://doc.servo.org/servo/index.html#reexports stop listing `extern crate` and `use` statements that don’t have `pub`. Source-Repo: https://github.com/servo/servo Source-Revision: 1453f438256afe92b0f79980c984824aac4afeae UltraBlame original commit: 8429d073276a3daeb5d4403ad44274bc39113092
…flag (from servo:strip-priv-imports); r=Ms2ger rust-lang/rust#32055 This will make e.g. http://doc.servo.org/servo/index.html#reexports stop listing `extern crate` and `use` statements that don’t have `pub`. Source-Repo: https://github.com/servo/servo Source-Revision: 1453f438256afe92b0f79980c984824aac4afeae UltraBlame original commit: 8429d073276a3daeb5d4403ad44274bc39113092
fixes #27104
r? @alexcrichton