-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Allow --document-private-items to accept =yes|no #10979
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @ehuss (or someone else) soon. Please see the contribution instructions for more information. |
c43c1b1
to
ed49e86
Compare
There is one downside to this PR that is worth mentioning, and I have no idea how to fix it (perhaps someone well-versed with The added length to the option help text now causes all of the docs to wrap below the option, effectively Is there a way to extend the gap between the options and the help text? Before:
After:
Otherwise, the argument itself could instead be shortened to Given that there might be a reason to allow for other visibility selections (i.e. internally |
Fixes rust-lang#7963. Previously, --document-private-items was only a 'truthy' flag, and was enabled in rust-lang#7593 for binary targets by default. However, this prevented any means of *disabling* this functionality for binary targets, hence rust-lang#7963. This change does a few things. It first adds a new argument parser type called `yesno_flag()` that is a wrapper around a few `clap::Arg` settings to use the built-in `BoolishValueParser` in a way that allows for the `--flag` to return `true`, as well as an optional `=no` or `=yes` (or `=1`, `=off`, etc.) to explicitly set it to `true` or `false`. Then, the internal field for passing the private member documentation flag to rustdoc was changed to an `Option<bool>` to treat `None` as the automatic project type detection, and a `Some` value to override the behavior outright. This change should be entirely backwards compatible.
ed49e86
to
23c973e
Compare
@@ -444,4 +444,8 @@ _cargo_example_names() { | |||
fi | |||
} | |||
|
|||
_cargo_yesno() { | |||
_values 'yes|no' yes no |
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 know if I did this right and don't have any idea on how to actually test this. I tried to read the zsh docs on the compdef file format but... wow it's dense. Any guidance would be appreciated.
Thanks for the PR! Can you say more about what your use case is where you do not want the private items documented? From my perspective, hiding private items in a library makes sense since the library can be used as a dependency which only has access to the public items. However that case doesn't exist for a binary, so whether or not something is public in a binary doesn't really have much consequence. @epage Would you be able to review this (or at least the clap side of things)? |
The use-case at the time of submission was that only Feel free to close (though I also recommend closing #7963 too). Still curious about the CLI help text formatting issue though, just for curiosity's sake. I fought with that for a while and figured I'd see if someone else knew what was happening. |
OK, will close this out then. I don't think there is a way to prevent the next-line help stuff. I believe here it uses a hueristic to determine things are too long, and it doesn't look like that can be turned off. |
I mentioned this in #7963, but unfortunately the |
Fixes #7963.
Previously, --document-private-items was only a 'truthy' flag,
and was enabled in #7593 for binary targets by default. However,
this prevented any means of disabling this functionality for
binary targets, hence #7963.
This change does a few things. It first adds a new argument
parser type called
yesno_flag()
that is a wrapper arounda few
clap::Arg
settings to use the built-inBoolishValueParser
in a way that allows for the
--flag
to returntrue
, as wellas an optional
=no
or=yes
(or=1
,=off
, etc.) to explicitlyset it to
true
orfalse
.Then, the internal field for passing the private member documentation
flag to rustdoc was changed to an
Option<bool>
to treatNone
as the automatic project type detection, and a
Some
value tooverride the behavior outright.
This change should be entirely backwards compatible.