Skip to content

Commit

Permalink
fix remaining intra-doc links
Browse files Browse the repository at this point in the history
  • Loading branch information
tshepang committed Jul 10, 2021
1 parent a11ca85 commit b4eddf1
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 71 deletions.
4 changes: 2 additions & 2 deletions clap_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ pub fn arg_enum(input: TokenStream) -> TokenStream {

/// Generates the `Clap` implementation.
///
/// This is far less verbose than defining the [`App`] struct manually,
/// receiving an instance of [`ArgMatches`] from conducting parsing, and then
/// This is far less verbose than defining the `clap::App` struct manually,
/// receiving an instance of `clap::ArgMatches` from conducting parsing, and then
/// implementing a conversion code to instantiate an instance of the user
/// context struct.
#[proc_macro_derive(Clap, attributes(clap))]
Expand Down
24 changes: 11 additions & 13 deletions clap_generate/src/generators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ pub trait Generator {
/// ```
fn file_name(name: &str) -> String;

/// Generates output out of [`clap::App`](super::clap::App).
/// Generates output out of [`clap::App`](App).
///
/// # Examples
///
/// The following example generator displays the [`clap::App`](super::clap::App)
/// as if it is printed using [`std::println`](std::println!).
/// The following example generator displays the [`clap::App`](App)
/// as if it is printed using [`std::println`].
///
/// ```
/// use std::{io::Write, fmt::write};
Expand Down Expand Up @@ -68,11 +68,9 @@ pub trait Generator {
subcmds
}

/// Finds the subcommand [`clap::App`][clap] from the given [`clap::App`][clap] with the given path.
/// Finds the subcommand [`clap::App`] from the given [`clap::App`] with the given path.
///
/// **NOTE:** `path` should not contain the root `bin_name`.
///
/// [clap]: super::clap::App
fn find_subcommand_with_path<'help, 'app>(
p: &'app App<'help>,
path: Vec<&str>,
Expand All @@ -86,7 +84,7 @@ pub trait Generator {
app
}

/// Gets subcommands of [`clap::App`](super::clap::App) in the form of `("name", "bin_name")`.
/// Gets subcommands of [`clap::App`] in the form of `("name", "bin_name")`.
///
/// Subcommand `rustup toolchain install` would be converted to
/// `("install", "rustup toolchain install")`.
Expand Down Expand Up @@ -115,8 +113,8 @@ pub trait Generator {
subcmds
}

/// Gets all the short options, their visible aliases and flags of a [`clap::App`](super::clap::App).
/// Includes `h` and `V` depending on the [`clap::AppSettings`](super::clap::AppSettings).
/// Gets all the short options, their visible aliases and flags of a [`clap::App`].
/// Includes `h` and `V` depending on the [`clap::AppSettings`].
fn shorts_and_visible_aliases(p: &App) -> Vec<char> {
debug!("shorts: name={}", p.get_name());

Expand All @@ -140,8 +138,8 @@ pub trait Generator {
.collect()
}

/// Gets all the long options, their visible aliases and flags of a [`clap::App`](super::clap::App).
/// Includes `help` and `version` depending on the [`clap::AppSettings`](super::clap::AppSettings).
/// Gets all the long options, their visible aliases and flags of a [`clap::App`].
/// Includes `help` and `version` depending on the [`clap::AppSettings`].
fn longs_and_visible_aliases(p: &App) -> Vec<String> {
debug!("longs: name={}", p.get_name());

Expand Down Expand Up @@ -170,8 +168,8 @@ pub trait Generator {
.collect()
}

/// Gets all the flags of a [`clap::App`](super::clap::App).
/// Includes `help` and `version` depending on the [`clap::AppSettings`](super::clap::AppSettings).
/// Gets all the flags of a [`clap::App`](App).
/// Includes `help` and `version` depending on the [`clap::AppSettings`].
fn flags<'help>(p: &App<'help>) -> Vec<Arg<'help>> {
debug!("flags: name={}", p.get_name());
p.get_flags().cloned().collect()
Expand Down
21 changes: 12 additions & 9 deletions src/build/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ impl<'help> App<'help> {
///
/// **NOTE:** This **only** replaces the help message for the current
/// command, meaning if you are using subcommands, those help messages will
/// still be auto-generated unless you specify a [`Arg::override_help`] for
/// still be auto-generated unless you specify a [`App::override_help`] for
/// them as well.
///
/// # Examples
Expand All @@ -826,7 +826,6 @@ impl<'help> App<'help> {
/// work Do some work")
/// # ;
/// ```
/// [`Arg::override_help`]: Arg::override_help()
pub fn override_help<S: Into<&'help str>>(mut self, help: S) -> Self {
self.help_str = Some(help.into());
self
Expand Down Expand Up @@ -1982,11 +1981,13 @@ impl<'help> App<'help> {
/// .unwrap_or_else(|e| e.exit());
/// ```
/// [`env::args_os`]: std::env::args_os()
/// [`Error::exit`]: Error::exit()
/// [`Error::exit`]: crate::Error::exit()
/// [`std::process::exit`]: std::process::exit()
/// [`clap::Result`]: Result
/// [`clap::Error`]: Error
/// [`kind`]: Error
/// [`clap::Error`]: crate::Error
/// [`kind`]: crate::Error
/// [`ErrorKind::DisplayHelp`]: crate::ErrorKind::DisplayHelp
/// [`ErrorKind::DisplayVersion`]: crate::ErrorKind::DisplayVersion
#[inline]
pub fn try_get_matches(self) -> ClapResult<ArgMatches> {
// Start the parsing
Expand Down Expand Up @@ -2064,11 +2065,13 @@ impl<'help> App<'help> {
/// ```
/// [`App::get_matches_from`]: App::get_matches_from()
/// [`App::try_get_matches`]: App::try_get_matches()
/// [`Error::exit`]: Error::exit()
/// [`Error::exit`]: crate::Error::exit()
/// [`std::process::exit`]: std::process::exit()
/// [`clap::Error`]: Error
/// [`Error::exit`]: Error::exit()
/// [`kind`]: Error
/// [`clap::Error`]: crate::Error
/// [`Error::exit`]: crate::Error::exit()
/// [`kind`]: crate::Error
/// [`ErrorKind::DisplayHelp`]: crate::ErrorKind::DisplayHelp
/// [`ErrorKind::DisplayVersion`]: crate::ErrorKind::DisplayVersion
pub fn try_get_matches_from<I, T>(mut self, itr: I) -> ClapResult<ArgMatches>
where
I: IntoIterator<Item = T>,
Expand Down
64 changes: 36 additions & 28 deletions src/build/app/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ pub enum AppSettings {
/// assert_eq!(m.value_of_os("arg").unwrap().as_bytes(), &[0xe9]);
/// ```
///
/// [`ArgMatches::value_of_os`]: ArgMatches::value_of_os()
/// [`ArgMatches::values_of_os`]: ArgMatches::values_of_os()
/// [`ArgMatches::value_of_lossy`]: ArgMatches::value_of_lossy()
/// [`ArgMatches::values_of_lossy`]: ArgMatches::values_of_lossy()
/// [`subcommands`]: App::subcommand()
/// [`ArgMatches::value_of_os`]: crate::ArgMatches::value_of_os()
/// [`ArgMatches::values_of_os`]: crate::ArgMatches::values_of_os()
/// [`ArgMatches::value_of_lossy`]: crate::ArgMatches::value_of_lossy()
/// [`ArgMatches::values_of_lossy`]: crate::ArgMatches::values_of_lossy()
/// [`subcommands`]: crate::App::subcommand()
// TODO: Either this or StrictUtf8
AllowInvalidUtf8,

Expand All @@ -236,13 +236,13 @@ pub enum AppSettings {
/// assert_eq!(m.value_of("neg"), Some("-20"));
/// # ;
/// ```
/// [`Arg::allow_hyphen_values`]: Arg::allow_hyphen_values()
/// [`Arg::allow_hyphen_values`]: crate::Arg::allow_hyphen_values()
AllowLeadingHyphen,

/// Specifies that all arguments override themselves. This is the equivalent to saying the `foo`
/// arg using [`Arg::overrides_with("foo")`] for all defined arguments.
///
/// [`Arg::overrides_with("foo")`]: Arg::overrides_with()
/// [`Arg::overrides_with("foo")`]: crate::Arg::overrides_with()
AllArgsOverrideSelf,

/// Allows negative numbers to pass as values. This is similar to
Expand Down Expand Up @@ -371,7 +371,7 @@ pub enum AppSettings {
/// assert_eq!(m.values_of("baz").unwrap().collect::<Vec<_>>(), &["baz1", "baz2", "baz3"]);
/// ```
///
/// [required]: Arg::required()
/// [required]: crate::Arg::required()
AllowMissingPositional,

/// Specifies that an unexpected positional argument,
Expand Down Expand Up @@ -405,7 +405,10 @@ pub enum AppSettings {
/// _ => {},
/// }
/// ```
/// [`subcommand`]: App::subcommand()
///
/// [`subcommand`]: crate::App::subcommand()
/// [`ArgMatches`]: crate::ArgMatches
/// [`ErrorKind::UnknownArgument`]: crate::ErrorKind::UnknownArgument
AllowExternalSubcommands,

/// Specifies that use of a valid argument negates [`subcommands`] being used after. By default
Expand All @@ -426,7 +429,7 @@ pub enum AppSettings {
/// .setting(AppSettings::ArgsNegateSubcommands);
/// ```
///
/// [`subcommands`]: App::subcommand()
/// [`subcommands`]: crate::App::subcommand()
ArgsNegateSubcommands,

/// Specifies that the help text should be displayed (and then exit gracefully),
Expand All @@ -445,8 +448,8 @@ pub enum AppSettings {
/// .setting(AppSettings::ArgRequiredElseHelp);
/// ```
///
/// [`subcommands`]: App::subcommand()
/// [`Arg::default_value`]: Arg::default_value()
/// [`subcommands`]: crate::App::subcommand()
/// [`Arg::default_value`]: crate::Arg::default_value()
ArgRequiredElseHelp,

/// Instructs the parser to stop when encountering a subcommand instead of greedily consuming
Expand Down Expand Up @@ -621,7 +624,8 @@ pub enum AppSettings {
/// .setting(AppSettings::DontDelimitTrailingValues)
/// .get_matches();
/// ```
/// [`Arg::use_delimiter(false)`]: Arg::use_delimiter()
///
/// [`Arg::use_delimiter(false)`]: crate::Arg::use_delimiter()
DontDelimitTrailingValues,

/// Disables `-h` and `--help` flag.
Expand Down Expand Up @@ -658,7 +662,7 @@ pub enum AppSettings {
/// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
/// ```
///
/// [`subcommand`]: App::subcommand()
/// [`subcommand`]: crate::App::subcommand()
DisableHelpSubcommand,

/// Disables `-V` and `--version` flag.
Expand Down Expand Up @@ -694,7 +698,8 @@ pub enum AppSettings {
/// assert_eq!(res.unwrap_err().kind, ErrorKind::UnknownArgument);
/// ```
///
/// [`subcommands`]: App::subcommand()
/// [`subcommands`]: crate::App::subcommand()
/// [`App`]: crate::App
DisableVersionForSubcommands,

/// Displays the arguments and [`subcommands`] in the help message in the order that they were
Expand All @@ -709,7 +714,7 @@ pub enum AppSettings {
/// .get_matches();
/// ```
///
/// [`subcommands`]: App::subcommand()
/// [`subcommands`]: crate::App::subcommand()
DeriveDisplayOrder,

/// Specifies to use the version of the current command for all child [`subcommands`].
Expand All @@ -729,7 +734,7 @@ pub enum AppSettings {
/// // "myprog-test v1.1"
/// ```
///
/// [`subcommands`]: App::subcommand()
/// [`subcommands`]: crate::App::subcommand()
GlobalVersion,

/// Specifies that this [`subcommand`] should be hidden from help messages
Expand All @@ -744,7 +749,7 @@ pub enum AppSettings {
/// # ;
/// ```
///
/// [`subcommand`]: App::subcommand()
/// [`subcommand`]: crate::App::subcommand()
Hidden,

/// Tells `clap` *not* to print possible values when displaying help information.
Expand Down Expand Up @@ -841,9 +846,9 @@ pub enum AppSettings {
/// assert_eq!(m.subcommand_name(), Some("test"));
/// ```
///
/// [`subcommands`]: App::subcommand()
/// [positional/free arguments]: Arg::index()
/// [aliases]: App::alias()
/// [`subcommands`]: crate::App::subcommand()
/// [positional/free arguments]: crate::Arg::index()
/// [aliases]: crate::App::alias()
InferSubcommands,

/// Tries to match unknown args to partial long arguments or their [aliases]. For example, to
Expand All @@ -852,6 +857,8 @@ pub enum AppSettings {
/// **NOTE:** The match *must not* be ambiguous at all in order to succeed. i.e. to match
/// `--te` to `--test` there could not also be another argument or alias `--temp` because both
/// start with `--te`
///
/// [aliases]: crate::App::alias()
InferLongArgs,

/// Specifies that the parser should not assume the first argument passed is the binary name.
Expand Down Expand Up @@ -926,8 +933,8 @@ pub enum AppSettings {
/// # ;
/// ```
///
/// [`Arg::required(true)`]: Arg::required()
/// [`subcommands`]: App::subcommand()
/// [`Arg::required(true)`]: crate::Arg::required()
/// [`subcommands`]: crate::App::subcommand()
SubcommandsNegateReqs,

/// Specifies that the help text should be displayed (before exiting gracefully) if no
Expand All @@ -948,7 +955,7 @@ pub enum AppSettings {
/// .setting(AppSettings::SubcommandRequiredElseHelp);
/// ```
///
/// [`subcommands`]: App::subcommand()
/// [`subcommands`]: crate::App::subcommand()
SubcommandRequiredElseHelp,

/// Specifies that the help subcommand should print the [long format] help message.
Expand All @@ -970,7 +977,7 @@ pub enum AppSettings {
/// )
/// .get_matches();
/// ```
/// [long format]: App::long_about
/// [long format]: crate::App::long_about
UseLongFormatForHelpSubcommand,

/// Specifies that any invalid UTF-8 code points should be treated as an error and fail
Expand Down Expand Up @@ -1003,7 +1010,8 @@ pub enum AppSettings {
/// assert_eq!(m.unwrap_err().kind, ErrorKind::InvalidUtf8);
/// ```
///
/// [`subcommands`]: App::subcommand()
/// [`subcommands`]: crate::App::subcommand()
/// [`ErrorKind::InvalidUtf8`]: crate::ErrorKind::InvalidUtf8
StrictUtf8,

/// Allows specifying that if no [`subcommand`] is present at runtime,
Expand All @@ -1024,7 +1032,7 @@ pub enum AppSettings {
/// # ;
/// ```
///
/// [`subcommand`]: App::subcommand()
/// [`subcommand`]: crate::App::subcommand()
SubcommandRequired,

/// Specifies that the final positional argument is a "VarArg" and that `clap` should not
Expand All @@ -1047,7 +1055,7 @@ pub enum AppSettings {
/// let trail: Vec<&str> = m.values_of("cmd").unwrap().collect();
/// assert_eq!(trail, ["arg1", "-r", "val1"]);
/// ```
/// [`Arg::multiple_values(true)`]: Arg::multiple_values()
/// [`Arg::multiple_values(true)`]: crate::Arg::multiple_values()
TrailingVarArg,

/// Groups flags and options together, presenting a more unified help message
Expand Down
Loading

0 comments on commit b4eddf1

Please sign in to comment.