fix a bunch of intra-doc links

This commit is contained in:
Tshepang Lekhonkhobe 2021-07-03 23:59:46 +02:00
parent 89d1519f69
commit f5758034f0
6 changed files with 43 additions and 31 deletions

View file

@ -167,6 +167,7 @@ impl_settings! { AppSettings, AppFlags,
/// **NOTE:** When these settings are used, they apply only to current command, and are *not* /// **NOTE:** When these settings are used, they apply only to current command, and are *not*
/// propagated down or up through child or parent subcommands /// propagated down or up through child or parent subcommands
/// ///
/// [`App`]: crate::App
#[derive(Debug, PartialEq, Copy, Clone)] #[derive(Debug, PartialEq, Copy, Clone)]
pub enum AppSettings { pub enum AppSettings {
/// Specifies that any invalid UTF-8 code points should *not* be treated as an error. /// Specifies that any invalid UTF-8 code points should *not* be treated as an error.

View file

@ -72,9 +72,9 @@ use yaml_rust::Yaml;
/// ``` /// ```
/// [`ArgGroup::multiple(true)`]: ArgGroup::multiple() /// [`ArgGroup::multiple(true)`]: ArgGroup::multiple()
/// [`ArgGroup::multiple(false)`]: ArgGroup::multiple() /// [`ArgGroup::multiple(false)`]: ArgGroup::multiple()
/// [arguments]: Arg /// [arguments]: crate::Arg
/// [conflict]: Arg::conflicts_with() /// [conflict]: crate::Arg::conflicts_with()
/// [requirement]: Arg::requires() /// [requirement]: crate::Arg::requires()
#[derive(Default, Debug, PartialEq, Eq)] #[derive(Default, Debug, PartialEq, Eq)]
pub struct ArgGroup<'help> { pub struct ArgGroup<'help> {
pub(crate) id: Id, pub(crate) id: Id,
@ -133,7 +133,7 @@ impl<'help> ArgGroup<'help> {
/// // but we can also check individually if needed /// // but we can also check individually if needed
/// assert!(m.is_present("flag")); /// assert!(m.is_present("flag"));
/// ``` /// ```
/// [argument]: Arg /// [argument]: crate::Arg
pub fn arg<T: Key>(mut self, arg_id: T) -> Self { pub fn arg<T: Key>(mut self, arg_id: T) -> Self {
self.args.push(arg_id.into()); self.args.push(arg_id.into());
self self
@ -158,7 +158,7 @@ impl<'help> ArgGroup<'help> {
/// // but we can also check individually if needed /// // but we can also check individually if needed
/// assert!(m.is_present("flag")); /// assert!(m.is_present("flag"));
/// ``` /// ```
/// [arguments]: Arg /// [arguments]: crate::Arg
pub fn args<T: Key>(mut self, ns: &[T]) -> Self { pub fn args<T: Key>(mut self, ns: &[T]) -> Self {
for n in ns { for n in ns {
self = self.arg(n); self = self.arg(n);
@ -205,6 +205,8 @@ impl<'help> ArgGroup<'help> {
/// let err = result.unwrap_err(); /// let err = result.unwrap_err();
/// assert_eq!(err.kind, ErrorKind::ArgumentConflict); /// assert_eq!(err.kind, ErrorKind::ArgumentConflict);
/// ``` /// ```
///
/// [`Arg`]: crate::Arg
#[inline] #[inline]
pub fn multiple(mut self, m: bool) -> Self { pub fn multiple(mut self, m: bool) -> Self {
self.multiple = m; self.multiple = m;
@ -245,6 +247,7 @@ impl<'help> ArgGroup<'help> {
/// ///
/// [`Subcommand`]: crate::Subcommand /// [`Subcommand`]: crate::Subcommand
/// [`ArgGroup::multiple`]: ArgGroup::multiple() /// [`ArgGroup::multiple`]: ArgGroup::multiple()
/// [`App`]: crate::App
#[inline] #[inline]
pub fn required(mut self, r: bool) -> Self { pub fn required(mut self, r: bool) -> Self {
self.required = r; self.required = r;
@ -280,7 +283,7 @@ impl<'help> ArgGroup<'help> {
/// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument); /// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
/// ``` /// ```
/// [required group]: ArgGroup::required() /// [required group]: ArgGroup::required()
/// [argument requirement rules]: Arg::requires() /// [argument requirement rules]: crate::Arg::requires()
pub fn requires<T: Key>(mut self, id: T) -> Self { pub fn requires<T: Key>(mut self, id: T) -> Self {
self.requires.push(id.into()); self.requires.push(id.into());
self self
@ -317,7 +320,7 @@ impl<'help> ArgGroup<'help> {
/// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument); /// assert_eq!(err.kind, ErrorKind::MissingRequiredArgument);
/// ``` /// ```
/// [required group]: ArgGroup::required() /// [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 { pub fn requires_all(mut self, ns: &[&'help str]) -> Self {
for n in ns { for n in ns {
self = self.requires(n); self = self.requires(n);
@ -351,7 +354,7 @@ impl<'help> ArgGroup<'help> {
/// let err = result.unwrap_err(); /// let err = result.unwrap_err();
/// assert_eq!(err.kind, ErrorKind::ArgumentConflict); /// assert_eq!(err.kind, ErrorKind::ArgumentConflict);
/// ``` /// ```
/// [argument exclusion rules]: Arg::conflicts_with() /// [argument exclusion rules]: crate::Arg::conflicts_with()
pub fn conflicts_with<T: Key>(mut self, id: T) -> Self { pub fn conflicts_with<T: Key>(mut self, id: T) -> Self {
self.conflicts.push(id.into()); self.conflicts.push(id.into());
self self
@ -386,7 +389,8 @@ impl<'help> ArgGroup<'help> {
/// let err = result.unwrap_err(); /// let err = result.unwrap_err();
/// assert_eq!(err.kind, ErrorKind::ArgumentConflict); /// 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 { pub fn conflicts_with_all(mut self, ns: &[&'help str]) -> Self {
for n in ns { for n in ns {
self = self.conflicts_with(n); self = self.conflicts_with(n);

View file

@ -7,7 +7,7 @@
#![doc(html_logo_url = "https://clap.rs/images/media/clap.png")] #![doc(html_logo_url = "https://clap.rs/images/media/clap.png")]
#![doc(html_root_url = "https://docs.rs/clap/3.0.0-beta.2")] #![doc(html_root_url = "https://docs.rs/clap/3.0.0-beta.2")]
#![cfg_attr(feature = "doc", doc(include = "../README.md"))] #![cfg_attr(feature = "doc", doc(include = "../README.md"))]
//! https://github.com/clap-rs/clap //! <https://github.com/clap-rs/clap>
#![crate_type = "lib"] #![crate_type = "lib"]
#![deny( #![deny(
missing_docs, missing_docs,

View file

@ -286,15 +286,15 @@ macro_rules! app_from_crate {
/// * `(@arg "something-else": --"something-else")` /// * `(@arg "something-else": --"something-else")`
/// * `(@subcommand "something-else" => ...)` /// * `(@subcommand "something-else" => ...)`
/// ///
/// [`Arg::short`]: Arg::short() /// [`Arg::short`]: crate::Arg::short()
/// [`Arg::long`]: Arg::long() /// [`Arg::long`]: crate::Arg::long()
/// [`Arg::multiple_values(true)`]: Arg::multiple_values() /// [`Arg::multiple_values(true)`]: crate::Arg::multiple_values()
/// [`Arg::multiple_occurrences(true)`]: Arg::multiple_occurrences() /// [`Arg::multiple_occurrences(true)`]: crate::Arg::multiple_occurrences()
/// [`Arg::value_name`]: Arg::value_name() /// [`Arg::value_name`]: crate::Arg::value_name()
/// [`Arg::min_values(min)`]: Arg::min_values() /// [`Arg::min_values(min)`]: crate::Arg::min_values()
/// [`Arg::max_values(max)`]: Arg::max_values() /// [`Arg::max_values(max)`]: crate::Arg::max_values()
/// [`Arg::validator`]: Arg::validator() /// [`Arg::validator`]: crate::Arg::validator()
/// [`Arg::conflicts_with`]: Arg::conflicts_with() /// [`Arg::conflicts_with`]: crate::Arg::conflicts_with()
#[macro_export] #[macro_export]
macro_rules! clap_app { macro_rules! clap_app {
(@app ($builder:expr)) => { $builder }; (@app ($builder:expr)) => { $builder };

View file

@ -290,6 +290,8 @@ pub enum ErrorKind {
/// assert_eq!(err.unwrap_err().kind, ErrorKind::MissingSubcommand); /// assert_eq!(err.unwrap_err().kind, ErrorKind::MissingSubcommand);
/// # ; /// # ;
/// ``` /// ```
///
/// [`AppSettings::SubcommandRequired`]: crate::AppSettings::SubcommandRequired
MissingSubcommand, MissingSubcommand,
/// Occurs when the user provides multiple values to an argument which doesn't allow that. /// 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!(result.is_err());
/// assert_eq!(result.unwrap_err().kind, ErrorKind::InvalidUtf8); /// assert_eq!(result.unwrap_err().kind, ErrorKind::InvalidUtf8);
/// ``` /// ```
///
/// [`AppSettings::StrictUtf8`]: crate::AppSettings::StrictUtf8
InvalidUtf8, InvalidUtf8,
/// Not a true "error" as it means `--help` or similar was used. /// Not a true "error" as it means `--help` or similar was used.
@ -373,6 +377,8 @@ pub enum ErrorKind {
/// ``` /// ```
/// ///
/// [`Subcommand`]: crate::Subcommand /// [`Subcommand`]: crate::Subcommand
/// [`AppSettings::ArgRequiredElseHelp`]: crate::AppSettings::ArgRequiredElseHelp
/// [`AppSettings::SubcommandRequiredElseHelp`]: crate::AppSettings::SubcommandRequiredElseHelp
DisplayHelpOnMissingArgumentOrSubcommand, DisplayHelpOnMissingArgumentOrSubcommand,
/// Not a true "error" as it means `--version` or similar was used. /// 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 /// 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. /// 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, ArgumentNotFound,
/// Represents an [I/O error]. /// Represents an [I/O error].

View file

@ -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)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct ArgMatches { pub struct ArgMatches {
pub(crate) args: IndexMap<Id, MatchedArg>, pub(crate) args: IndexMap<Id, MatchedArg>,
@ -114,12 +114,11 @@ impl ArgMatches {
/// ///
/// assert_eq!(m.value_of("output"), Some("something")); /// assert_eq!(m.value_of("output"), Some("something"));
/// ``` /// ```
/// [option]: Arg::takes_value() /// [option]: crate::Arg::takes_value()
/// [positional]: Arg::index() /// [positional]: crate::Arg::index()
/// [`ArgMatches::values_of`]: ArgMatches::values_of() /// [`ArgMatches::values_of`]: ArgMatches::values_of()
/// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html /// [`default_value`]: crate::Arg::default_value()
/// [`default_value`]: Arg::default_value() /// [`occurrences_of`]: crate::ArgMatches::occurrences_of()
/// [`occurrences_of`]: ArgMatches::occurrences_of()
pub fn value_of<T: Key>(&self, id: T) -> Option<&str> { pub fn value_of<T: Key>(&self, id: T) -> Option<&str> {
if let Some(arg) = self.args.get(&Id::from(id)) { if let Some(arg) = self.args.get(&Id::from(id)) {
if let Some(v) = arg.get_val(0) { 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'!'])]); /// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]);
/// assert_eq!(&*m.value_of_lossy("arg").unwrap(), "Hi \u{FFFD}!"); /// 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() /// [`occurrences_of`]: ArgMatches::occurrences_of()
/// [`Arg::values_of_lossy`]: ArgMatches::values_of_lossy() /// [`Arg::values_of_lossy`]: ArgMatches::values_of_lossy()
pub fn value_of_lossy<T: Key>(&self, id: T) -> Option<Cow<'_, str>> { pub fn value_of_lossy<T: Key>(&self, id: T) -> Option<Cow<'_, str>> {
@ -194,9 +193,8 @@ impl ArgMatches {
/// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]); /// 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'!']); /// 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() /// [`occurrences_of`]: ArgMatches::occurrences_of()
/// [`String`]: std::string::String
/// [`ArgMatches::values_of_os`]: ArgMatches::values_of_os() /// [`ArgMatches::values_of_os`]: ArgMatches::values_of_os()
pub fn value_of_os<T: Key>(&self, id: T) -> Option<&OsStr> { pub fn value_of_os<T: Key>(&self, id: T) -> Option<&OsStr> {
self.args self.args
@ -365,6 +363,7 @@ impl ArgMatches {
/// ///
/// [`ArgMatches::values_of_t`]: ArgMatches::values_of_t() /// [`ArgMatches::values_of_t`]: ArgMatches::values_of_t()
/// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html /// [`panic!`]: https://doc.rust-lang.org/std/macro.panic!.html
/// [`ErrorKind`]: crate::ErrorKind
pub fn value_of_t<R>(&self, name: &str) -> Result<R, Error> pub fn value_of_t<R>(&self, name: &str) -> Result<R, Error>
where where
R: FromStr, R: FromStr,
@ -535,7 +534,7 @@ impl ArgMatches {
/// assert!(m.is_present("debug")); /// assert!(m.is_present("debug"));
/// ``` /// ```
/// ///
/// [`default_value`]: Arg::default_value() /// [`default_value`]: crate::Arg::default_value()
/// [`occurrences_of`]: ArgMatches::occurrences_of() /// [`occurrences_of`]: ArgMatches::occurrences_of()
pub fn is_present<T: Key>(&self, id: T) -> bool { pub fn is_present<T: Key>(&self, id: T) -> bool {
let id = Id::from(id); let id = Id::from(id);
@ -713,7 +712,7 @@ impl ArgMatches {
/// assert_eq!(m.index_of("option"), Some(2)); /// assert_eq!(m.index_of("option"), Some(2));
/// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 3, 4]); /// assert_eq!(m.indices_of("option").unwrap().collect::<Vec<_>>(), &[2, 3, 4]);
/// ``` /// ```
/// [delimiter]: Arg::value_delimiter() /// [delimiter]: crate::Arg::value_delimiter()
pub fn index_of<T: Key>(&self, name: T) -> Option<usize> { pub fn index_of<T: Key>(&self, name: T) -> Option<usize> {
if let Some(arg) = self.args.get(&Id::from(name)) { if let Some(arg) = self.args.get(&Id::from(name)) {
if let Some(i) = arg.get_index(0) { if let Some(i) = arg.get_index(0) {
@ -830,6 +829,7 @@ impl ArgMatches {
/// ``` /// ```
/// ///
/// [`Subcommand`]: crate::Subcommand /// [`Subcommand`]: crate::Subcommand
/// [`App`]: crate::App
pub fn subcommand_matches<T: Key>(&self, id: T) -> Option<&ArgMatches> { pub fn subcommand_matches<T: Key>(&self, id: T) -> Option<&ArgMatches> {
if let Some(ref s) = self.subcommand { if let Some(ref s) = self.subcommand {
if s.id == id.into() { if s.id == id.into() {
@ -895,6 +895,7 @@ impl ArgMatches {
/// } /// }
/// ``` /// ```
/// [`Subcommand`]: crate::Subcommand /// [`Subcommand`]: crate::Subcommand
/// [`App`]: crate::App
#[inline] #[inline]
pub fn subcommand_name(&self) -> Option<&str> { pub fn subcommand_name(&self) -> Option<&str> {
self.subcommand.as_ref().map(|sc| &*sc.name) self.subcommand.as_ref().map(|sc| &*sc.name)