From f5758034f03ed269535a4ffad10abf592cd9a68b Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Sat, 3 Jul 2021 23:59:46 +0200 Subject: [PATCH] fix a bunch of intra-doc links --- src/build/app/settings.rs | 1 + src/build/arg_group.rs | 22 +++++++++++++--------- src/lib.rs | 2 +- src/macros.rs | 18 +++++++++--------- src/parse/errors.rs | 8 +++++++- src/parse/matches/arg_matches.rs | 23 ++++++++++++----------- 6 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/build/app/settings.rs b/src/build/app/settings.rs index 4959f348..955f4823 100644 --- a/src/build/app/settings.rs +++ b/src/build/app/settings.rs @@ -167,6 +167,7 @@ impl_settings! { AppSettings, AppFlags, /// **NOTE:** When these settings are used, they apply only to current command, and are *not* /// propagated down or up through child or parent subcommands /// +/// [`App`]: crate::App #[derive(Debug, PartialEq, Copy, Clone)] pub enum AppSettings { /// Specifies that any invalid UTF-8 code points should *not* be treated as an error. diff --git a/src/build/arg_group.rs b/src/build/arg_group.rs index 960ff23d..5c489a78 100644 --- a/src/build/arg_group.rs +++ b/src/build/arg_group.rs @@ -72,9 +72,9 @@ use yaml_rust::Yaml; /// ``` /// [`ArgGroup::multiple(true)`]: ArgGroup::multiple() /// [`ArgGroup::multiple(false)`]: ArgGroup::multiple() -/// [arguments]: Arg -/// [conflict]: Arg::conflicts_with() -/// [requirement]: Arg::requires() +/// [arguments]: crate::Arg +/// [conflict]: crate::Arg::conflicts_with() +/// [requirement]: crate::Arg::requires() #[derive(Default, Debug, PartialEq, Eq)] pub struct ArgGroup<'help> { pub(crate) id: Id, @@ -133,7 +133,7 @@ impl<'help> ArgGroup<'help> { /// // but we can also check individually if needed /// assert!(m.is_present("flag")); /// ``` - /// [argument]: Arg + /// [argument]: crate::Arg pub fn arg(mut self, arg_id: T) -> Self { self.args.push(arg_id.into()); self @@ -158,7 +158,7 @@ impl<'help> ArgGroup<'help> { /// // but we can also check individually if needed /// assert!(m.is_present("flag")); /// ``` - /// [arguments]: Arg + /// [arguments]: crate::Arg pub fn args(mut self, ns: &[T]) -> Self { for n in ns { self = self.arg(n); @@ -205,6 +205,8 @@ impl<'help> ArgGroup<'help> { /// let err = result.unwrap_err(); /// assert_eq!(err.kind, ErrorKind::ArgumentConflict); /// ``` + /// + /// [`Arg`]: crate::Arg #[inline] pub fn multiple(mut self, m: bool) -> Self { self.multiple = m; @@ -245,6 +247,7 @@ impl<'help> ArgGroup<'help> { /// /// [`Subcommand`]: crate::Subcommand /// [`ArgGroup::multiple`]: ArgGroup::multiple() + /// [`App`]: crate::App #[inline] pub fn required(mut self, r: bool) -> Self { self.required = r; @@ -280,7 +283,7 @@ impl<'help> ArgGroup<'help> { /// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument); /// ``` /// [required group]: ArgGroup::required() - /// [argument requirement rules]: Arg::requires() + /// [argument requirement rules]: crate::Arg::requires() pub fn requires(mut self, id: T) -> Self { self.requires.push(id.into()); self @@ -317,7 +320,7 @@ impl<'help> ArgGroup<'help> { /// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument); /// ``` /// [required group]: ArgGroup::required() - /// [argument requirement rules]: Arg::requires_all() + /// [argument requirement rules]: crate::Arg::requires_all() pub fn requires_all(mut self, ns: &[&'help str]) -> Self { for n in ns { self = self.requires(n); @@ -351,7 +354,7 @@ impl<'help> ArgGroup<'help> { /// let err = result.unwrap_err(); /// assert_eq!(err.kind, ErrorKind::ArgumentConflict); /// ``` - /// [argument exclusion rules]: Arg::conflicts_with() + /// [argument exclusion rules]: crate::Arg::conflicts_with() pub fn conflicts_with(mut self, id: T) -> Self { self.conflicts.push(id.into()); self @@ -386,7 +389,8 @@ impl<'help> ArgGroup<'help> { /// let err = result.unwrap_err(); /// assert_eq!(err.kind, ErrorKind::ArgumentConflict); /// ``` - /// [argument exclusion rules]: Arg::conflicts_with_all() + /// + /// [argument exclusion rules]: crate::Arg::conflicts_with_all() pub fn conflicts_with_all(mut self, ns: &[&'help str]) -> Self { for n in ns { self = self.conflicts_with(n); diff --git a/src/lib.rs b/src/lib.rs index d3c0513d..6cf85adf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -7,7 +7,7 @@ #![doc(html_logo_url = "https://clap.rs/images/media/clap.png")] #![doc(html_root_url = "https://docs.rs/clap/3.0.0-beta.2")] #![cfg_attr(feature = "doc", doc(include = "../README.md"))] -//! https://github.com/clap-rs/clap +//! #![crate_type = "lib"] #![deny( missing_docs, diff --git a/src/macros.rs b/src/macros.rs index 502f15f8..f5c68883 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -286,15 +286,15 @@ macro_rules! app_from_crate { /// * `(@arg "something-else": --"something-else")` /// * `(@subcommand "something-else" => ...)` /// -/// [`Arg::short`]: Arg::short() -/// [`Arg::long`]: Arg::long() -/// [`Arg::multiple_values(true)`]: Arg::multiple_values() -/// [`Arg::multiple_occurrences(true)`]: Arg::multiple_occurrences() -/// [`Arg::value_name`]: Arg::value_name() -/// [`Arg::min_values(min)`]: Arg::min_values() -/// [`Arg::max_values(max)`]: Arg::max_values() -/// [`Arg::validator`]: Arg::validator() -/// [`Arg::conflicts_with`]: Arg::conflicts_with() +/// [`Arg::short`]: crate::Arg::short() +/// [`Arg::long`]: crate::Arg::long() +/// [`Arg::multiple_values(true)`]: crate::Arg::multiple_values() +/// [`Arg::multiple_occurrences(true)`]: crate::Arg::multiple_occurrences() +/// [`Arg::value_name`]: crate::Arg::value_name() +/// [`Arg::min_values(min)`]: crate::Arg::min_values() +/// [`Arg::max_values(max)`]: crate::Arg::max_values() +/// [`Arg::validator`]: crate::Arg::validator() +/// [`Arg::conflicts_with`]: crate::Arg::conflicts_with() #[macro_export] macro_rules! clap_app { (@app ($builder:expr)) => { $builder }; diff --git a/src/parse/errors.rs b/src/parse/errors.rs index 66462cd7..e09a1751 100644 --- a/src/parse/errors.rs +++ b/src/parse/errors.rs @@ -290,6 +290,8 @@ pub enum ErrorKind { /// assert_eq!(err.unwrap_err().kind, ErrorKind::MissingSubcommand); /// # ; /// ``` + /// + /// [`AppSettings::SubcommandRequired`]: crate::AppSettings::SubcommandRequired MissingSubcommand, /// Occurs when the user provides multiple values to an argument which doesn't allow that. @@ -333,6 +335,8 @@ pub enum ErrorKind { /// assert!(result.is_err()); /// assert_eq!(result.unwrap_err().kind, ErrorKind::InvalidUtf8); /// ``` + /// + /// [`AppSettings::StrictUtf8`]: crate::AppSettings::StrictUtf8 InvalidUtf8, /// Not a true "error" as it means `--help` or similar was used. @@ -373,6 +377,8 @@ pub enum ErrorKind { /// ``` /// /// [`Subcommand`]: crate::Subcommand + /// [`AppSettings::ArgRequiredElseHelp`]: crate::AppSettings::ArgRequiredElseHelp + /// [`AppSettings::SubcommandRequiredElseHelp`]: crate::AppSettings::SubcommandRequiredElseHelp DisplayHelpOnMissingArgumentOrSubcommand, /// Not a true "error" as it means `--version` or similar was used. @@ -393,7 +399,7 @@ pub enum ErrorKind { /// into type `T`, but the argument you requested wasn't used. I.e. you asked for an argument /// with name `config` to be converted, but `config` wasn't used by the user. /// - /// [`ArgMatches::value_of_t`]: ArgMatches::value_of_t() + /// [`ArgMatches::value_of_t`]: crate::ArgMatches::value_of_t() ArgumentNotFound, /// Represents an [I/O error]. diff --git a/src/parse/matches/arg_matches.rs b/src/parse/matches/arg_matches.rs index 8d98e00a..f0b5a1d9 100644 --- a/src/parse/matches/arg_matches.rs +++ b/src/parse/matches/arg_matches.rs @@ -71,7 +71,7 @@ pub(crate) struct SubCommand { /// } /// } /// ``` -/// [`App::get_matches`]: App::get_matches() +/// [`App::get_matches`]: crate::App::get_matches() #[derive(Debug, Clone, PartialEq, Eq)] pub struct ArgMatches { pub(crate) args: IndexMap, @@ -114,12 +114,11 @@ impl ArgMatches { /// /// assert_eq!(m.value_of("output"), Some("something")); /// ``` - /// [option]: Arg::takes_value() - /// [positional]: Arg::index() + /// [option]: crate::Arg::takes_value() + /// [positional]: crate::Arg::index() /// [`ArgMatches::values_of`]: ArgMatches::values_of() - /// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html - /// [`default_value`]: Arg::default_value() - /// [`occurrences_of`]: ArgMatches::occurrences_of() + /// [`default_value`]: crate::Arg::default_value() + /// [`occurrences_of`]: crate::ArgMatches::occurrences_of() pub fn value_of(&self, id: T) -> Option<&str> { if let Some(arg) = self.args.get(&Id::from(id)) { if let Some(v) = arg.get_val(0) { @@ -154,7 +153,7 @@ impl ArgMatches { /// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]); /// assert_eq!(&*m.value_of_lossy("arg").unwrap(), "Hi \u{FFFD}!"); /// ``` - /// [`default_value`]: Arg::default_value() + /// [`default_value`]: crate::Arg::default_value() /// [`occurrences_of`]: ArgMatches::occurrences_of() /// [`Arg::values_of_lossy`]: ArgMatches::values_of_lossy() pub fn value_of_lossy(&self, id: T) -> Option> { @@ -194,9 +193,8 @@ impl ArgMatches { /// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]); /// assert_eq!(&*m.value_of_os("arg").unwrap().as_bytes(), [b'H', b'i', b' ', 0xe9, b'!']); /// ``` - /// [`default_value`]: Arg::default_value() + /// [`default_value`]: crate::Arg::default_value() /// [`occurrences_of`]: ArgMatches::occurrences_of() - /// [`String`]: std::string::String /// [`ArgMatches::values_of_os`]: ArgMatches::values_of_os() pub fn value_of_os(&self, id: T) -> Option<&OsStr> { self.args @@ -365,6 +363,7 @@ impl ArgMatches { /// /// [`ArgMatches::values_of_t`]: ArgMatches::values_of_t() /// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html + /// [`ErrorKind`]: crate::ErrorKind pub fn value_of_t(&self, name: &str) -> Result where R: FromStr, @@ -535,7 +534,7 @@ impl ArgMatches { /// assert!(m.is_present("debug")); /// ``` /// - /// [`default_value`]: Arg::default_value() + /// [`default_value`]: crate::Arg::default_value() /// [`occurrences_of`]: ArgMatches::occurrences_of() pub fn is_present(&self, id: T) -> bool { let id = Id::from(id); @@ -713,7 +712,7 @@ impl ArgMatches { /// assert_eq!(m.index_of("option"), Some(2)); /// assert_eq!(m.indices_of("option").unwrap().collect::>(), &[2, 3, 4]); /// ``` - /// [delimiter]: Arg::value_delimiter() + /// [delimiter]: crate::Arg::value_delimiter() pub fn index_of(&self, name: T) -> Option { if let Some(arg) = self.args.get(&Id::from(name)) { if let Some(i) = arg.get_index(0) { @@ -830,6 +829,7 @@ impl ArgMatches { /// ``` /// /// [`Subcommand`]: crate::Subcommand + /// [`App`]: crate::App pub fn subcommand_matches(&self, id: T) -> Option<&ArgMatches> { if let Some(ref s) = self.subcommand { if s.id == id.into() { @@ -895,6 +895,7 @@ impl ArgMatches { /// } /// ``` /// [`Subcommand`]: crate::Subcommand + /// [`App`]: crate::App #[inline] pub fn subcommand_name(&self) -> Option<&str> { self.subcommand.as_ref().map(|sc| &*sc.name)