Merge pull request #4790 from epage/doc

doc: Clean up cfgs
This commit is contained in:
Ed Page 2023-03-27 10:12:15 -05:00 committed by GitHub
commit 615c1dc6a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 127 additions and 90 deletions

View file

@ -77,7 +77,7 @@ Note: We have not yet determined the End-of-Life schedule for previous major ver
### Verifying Changes
A common (sub)set of commands for verifying your change:
```sh
```console
$ make test-full
$ make clippy-full
$ make doc

View file

@ -1,16 +1,16 @@
//! How to use value hints and generate shell completions.
//!
//! Usage with zsh:
//! ```sh
//! cargo run --example completion-derive -- --generate=zsh > /usr/local/share/zsh/site-functions/_completion_derive
//! compinit
//! ./target/debug/examples/completion_derive --<TAB>
//! ```console
//! $ cargo run --example completion-derive -- --generate=zsh > /usr/local/share/zsh/site-functions/_completion_derive
//! $ compinit
//! $ ./target/debug/examples/completion_derive --<TAB>
//! ```
//! fish:
//! ```sh
//! cargo run --example completion-derive -- --generate=fish > completion_derive.fish
//! . ./completion_derive.fish
//! ./target/debug/examples/completion_derive --<TAB>
//! ```console
//! $ cargo run --example completion-derive -- --generate=fish > completion_derive.fish
//! $ . ./completion_derive.fish
//! $ ./target/debug/examples/completion_derive --<TAB>
//! ```
use clap::{Args, Command, CommandFactory, Parser, Subcommand, ValueHint};
use clap_complete::{generate, Generator, Shell};

View file

@ -1,16 +1,16 @@
//! Example to test arguments with different ValueHint values.
//!
//! Usage with zsh:
//! ```sh
//! cargo run --example completion -- --generate=zsh > /usr/local/share/zsh/site-functions/_completion
//! compinit
//! ./target/debug/examples/completion --<TAB>
//! ```console
//! $ cargo run --example completion -- --generate=zsh > /usr/local/share/zsh/site-functions/_completion$
//! $ compinit
//! $ ./target/debug/examples/completion --<TAB>
//! ```
//! fish:
//! ```sh
//! cargo run --example completion -- --generate=fish > completion.fish
//! . ./completion.fish
//! ./target/debug/examples/completion --<TAB>
//! ```console
//! $ cargo run --example completion -- --generate=fish > completion.fish
//! $ . ./completion.fish
//! $ ./target/debug/examples/completion --<TAB>
//! ```
use clap::{value_parser, Arg, Command, ValueHint};
use clap_complete::{generate, Generator, Shell};

View file

@ -217,7 +217,7 @@ where
///
/// Usage:
///
/// ```shell
/// ```console
/// $ myapp generate-bash-completions > /usr/share/bash-completion/completions/myapp.bash
/// ```
pub fn generate<G, S>(gen: G, cmd: &mut clap::Command, bin_name: S, buf: &mut dyn Write)

View file

@ -2,8 +2,8 @@
///
/// # Examples
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::Command;
/// # use clap::Arg;
/// let cmd = Command::new("mycmd")
@ -20,6 +20,7 @@
/// // New help available
/// let err = cmd.try_get_matches_from(["mycmd", "-?"]).unwrap_err();
/// assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp);
/// # }
/// ```
#[derive(Clone, Debug)]
#[non_exhaustive]
@ -224,8 +225,8 @@ pub enum ArgAction {
///
/// # Examples
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::Command;
/// # use clap::Arg;
/// let cmd = Command::new("mycmd")
@ -242,6 +243,7 @@ pub enum ArgAction {
/// // New help available
/// let err = cmd.try_get_matches_from(["mycmd", "-?"]).unwrap_err();
/// assert_eq!(err.kind(), clap::error::ErrorKind::DisplayHelp);
/// # }
/// ```
Help,
/// When encountered, display [`Command::version`][super::Command::version]

View file

@ -1125,8 +1125,8 @@ impl Arg {
/// # ;
/// ```
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg};
/// let m = Command::new("prog")
/// .arg(Arg::new("config")
@ -1136,6 +1136,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "--help"
/// ]);
/// # }
/// ```
/// Running the above program produces the following output
///
@ -1187,8 +1188,8 @@ impl Arg {
/// .value_names(["fast", "slow"]);
/// ```
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg};
/// let m = Command::new("prog")
/// .arg(Arg::new("io")
@ -1197,6 +1198,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "--help"
/// ]);
/// # }
/// ```
///
/// Running the above program produces the following output
@ -2013,8 +2015,8 @@ impl Arg {
/// Setting `help` displays a short message to the side of the argument when the user passes
/// `-h` or `--help` (by default).
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg};
/// let m = Command::new("prog")
/// .arg(Arg::new("cfg")
@ -2023,6 +2025,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "--help"
/// ]);
/// # }
/// ```
///
/// The above example displays
@ -2063,8 +2066,8 @@ impl Arg {
/// Setting `help` displays a short message to the side of the argument when the user passes
/// `-h` or `--help` (by default).
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg};
/// let m = Command::new("prog")
/// .arg(Arg::new("cfg")
@ -2077,6 +2080,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "--help"
/// ]);
/// # }
/// ```
///
/// The above example displays
@ -2121,8 +2125,8 @@ impl Arg {
///
/// # Examples
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg, ArgAction};
/// let m = Command::new("prog")
/// .arg(Arg::new("a") // Typically args are grouped alphabetically by name.
@ -2144,6 +2148,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "--help"
/// ]);
/// # }
/// ```
///
/// The above example displays the following help message
@ -2188,8 +2193,8 @@ impl Arg {
///
/// # Examples
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg, ArgAction};
/// let m = Command::new("prog")
/// .arg(Arg::new("opt")
@ -2204,6 +2209,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "--help"
/// ]);
/// # }
/// ```
///
/// The above example displays the following help message
@ -2239,8 +2245,8 @@ impl Arg {
///
/// Setting `Hidden` will hide the argument when displaying help text
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg};
/// let m = Command::new("prog")
/// .arg(Arg::new("cfg")
@ -2250,6 +2256,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "--help"
/// ]);
/// # }
/// ```
///
/// The above example displays
@ -2413,8 +2420,8 @@ impl Arg {
///
/// Setting `hide_short_help(true)` will hide the argument when displaying short help text
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg};
/// let m = Command::new("prog")
/// .arg(Arg::new("cfg")
@ -2424,6 +2431,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "-h"
/// ]);
/// # }
/// ```
///
/// The above example displays
@ -2440,8 +2448,8 @@ impl Arg {
///
/// However, when --help is called
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg};
/// let m = Command::new("prog")
/// .arg(Arg::new("cfg")
@ -2451,6 +2459,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "--help"
/// ]);
/// # }
/// ```
///
/// Then the following would be displayed
@ -2486,8 +2495,8 @@ impl Arg {
///
/// Setting `hide_long_help(true)` will hide the argument when displaying long help text
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg};
/// let m = Command::new("prog")
/// .arg(Arg::new("cfg")
@ -2497,6 +2506,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "--help"
/// ]);
/// # }
/// ```
///
/// The above example displays
@ -2513,8 +2523,8 @@ impl Arg {
///
/// However, when -h is called
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg};
/// let m = Command::new("prog")
/// .arg(Arg::new("cfg")
@ -2524,6 +2534,7 @@ impl Arg {
/// .get_matches_from(vec![
/// "prog", "-h"
/// ]);
/// # }
/// ```
///
/// Then the following would be displayed

View file

@ -2608,8 +2608,8 @@ impl Command {
///
/// # Examples
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, };
/// let m = Command::new("cust-ord")
/// .subcommand(Command::new("alpha") // typically subcommands are grouped
@ -2627,6 +2627,7 @@ impl Command {
/// .get_matches_from(vec![
/// "cust-ord", "--help"
/// ]);
/// # }
/// ```
///
/// The above example displays the following help message
@ -2756,8 +2757,8 @@ impl Command {
///
/// # Examples
///
#[cfg_attr(not(unix), doc = " ```ignore")]
#[cfg_attr(unix, doc = " ```")]
/// ```rust
/// # #[cfg(unix)] {
/// # use std::ffi::OsString;
/// # use clap::Command;
/// # use clap::value_parser;
@ -2778,6 +2779,7 @@ impl Command {
/// },
/// _ => {},
/// }
/// # }
/// ```
///
/// ```

View file

@ -166,8 +166,8 @@ impl ValueParser {
///
/// # Example
///
#[cfg_attr(not(unix), doc = " ```ignore")]
#[cfg_attr(unix, doc = " ```rust")]
/// ```rust
/// # #[cfg(unix)] {
/// # use clap::{Command, Arg, builder::ValueParser};
/// use std::ffi::OsString;
/// use std::os::unix::ffi::{OsStrExt,OsStringExt};
@ -187,6 +187,7 @@ impl ValueParser {
/// let arg: &OsString = m.get_one("arg")
/// .expect("required");
/// assert_eq!(arg.as_bytes(), &[0xe9]);
/// # }
/// ```
pub const fn os_string() -> Self {
Self(ValueParserInner::OsString)
@ -644,8 +645,8 @@ where
///
/// # Example
///
#[cfg_attr(not(feature = "error-context"), doc = " ```ignore")]
#[cfg_attr(feature = "error-context", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "error-context")] {
/// # use clap::error::ErrorKind;
/// # use clap::error::ContextKind;
/// # use clap::error::ContextValue;
@ -681,6 +682,7 @@ where
/// Ok(Custom(val))
/// }
/// }
/// # }
/// ```
pub trait TypedValueParser: Clone + Send + Sync + 'static {
/// Argument's value type

View file

@ -30,8 +30,8 @@ use std::ffi::OsString;
/// throughout the application representing the normalized values coming from
/// the CLI.
///
#[cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#[cfg_attr(feature = "derive", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "derive")] {
/// /// My super CLI
/// #[derive(clap::Parser)]
/// #[command(name = "demo")]
@ -43,6 +43,7 @@ use std::ffi::OsString;
/// #[arg(short, long)]
/// name: Option<String>,
/// }
/// # }
/// ```
///
/// The equivalent [`Command`] struct + `From` implementation:
@ -179,19 +180,20 @@ pub trait FromArgMatches: Sized {
/// Motivation: If our application had two CLI options, `--name
/// <STRING>` and the flag `--debug`, we may create a struct as follows:
///
#[cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#[cfg_attr(feature = "derive", doc = " ```no_run")]
/// ```rust
/// # #[cfg(feature = "derive")] {
/// struct Context {
/// name: String,
/// debug: bool
/// }
/// # }
/// ```
///
/// We then need to convert the `ArgMatches` that `clap` generated into our struct.
/// `from_arg_matches` serves as the equivalent of:
///
#[cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#[cfg_attr(feature = "derive", doc = " ```no_run")]
/// ```rust
/// # #[cfg(feature = "derive")] {
/// # use clap::ArgMatches;
/// # struct Context {
/// # name: String,
@ -205,6 +207,7 @@ pub trait FromArgMatches: Sized {
/// }
/// }
/// }
/// # }
/// ```
fn from_arg_matches(matches: &ArgMatches) -> Result<Self, Error>;
@ -213,19 +216,20 @@ pub trait FromArgMatches: Sized {
/// Motivation: If our application had two CLI options, `--name
/// <STRING>` and the flag `--debug`, we may create a struct as follows:
///
#[cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#[cfg_attr(feature = "derive", doc = " ```no_run")]
/// ```rust
/// # #[cfg(feature = "derive")] {
/// struct Context {
/// name: String,
/// debug: bool
/// }
/// # }
/// ```
///
/// We then need to convert the `ArgMatches` that `clap` generated into our struct.
/// `from_arg_matches_mut` serves as the equivalent of:
///
#[cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#[cfg_attr(feature = "derive", doc = " ```no_run")]
/// ```rust
/// # #[cfg(feature = "derive")] {
/// # use clap::ArgMatches;
/// # struct Context {
/// # name: String,
@ -239,6 +243,7 @@ pub trait FromArgMatches: Sized {
/// }
/// }
/// }
/// # }
/// ```
fn from_arg_matches_mut(matches: &mut ArgMatches) -> Result<Self, Error> {
Self::from_arg_matches(matches)
@ -267,8 +272,8 @@ pub trait FromArgMatches: Sized {
///
/// # Example
///
#[cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#[cfg_attr(feature = "derive", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "derive")] {
/// #[derive(clap::Parser)]
/// struct Args {
/// #[command(flatten)]
@ -280,6 +285,7 @@ pub trait FromArgMatches: Sized {
/// #[arg(long, short = 'v', action = clap::ArgAction::Count)]
/// verbose: u8,
/// }
/// # }
/// ```
pub trait Args: FromArgMatches + Sized {
/// Report the [`ArgGroup::id`][crate::ArgGroup::id] for this set of arguments
@ -313,8 +319,8 @@ pub trait Args: FromArgMatches + Sized {
///
/// # Example
///
#[cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#[cfg_attr(feature = "derive", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "derive")] {
/// #[derive(clap::Parser)]
/// struct Args {
/// #[command(subcommand)]
@ -326,6 +332,7 @@ pub trait Args: FromArgMatches + Sized {
/// Add,
/// Remove,
/// }
/// # }
/// ```
pub trait Subcommand: FromArgMatches + Sized {
/// Append to [`Command`] so it can instantiate `Self`.
@ -355,8 +362,8 @@ pub trait Subcommand: FromArgMatches + Sized {
///
/// # Example
///
#[cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#[cfg_attr(feature = "derive", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "derive")] {
/// #[derive(clap::Parser)]
/// struct Args {
/// #[arg(value_enum)]
@ -370,6 +377,7 @@ pub trait Subcommand: FromArgMatches + Sized {
/// Warning,
/// Error,
/// }
/// # }
/// ```
pub trait ValueEnum: Sized + Clone {
/// All possible argument values, in display order.

View file

@ -39,8 +39,8 @@ pub enum ErrorKind {
///
/// # Examples
///
#[cfg_attr(not(feature = "suggestions"), doc = " ```no_run")]
#[cfg_attr(feature = "suggestions", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "suggestions")] {
/// # use clap::{Command, Arg, error::ErrorKind, };
/// let result = Command::new("prog")
/// .subcommand(Command::new("config")
@ -50,6 +50,7 @@ pub enum ErrorKind {
/// .try_get_matches_from(vec!["prog", "confi"]);
/// assert!(result.is_err());
/// assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidSubcommand);
/// # }
/// ```
///
/// [`Subcommand`]: crate::Subcommand
@ -222,8 +223,8 @@ pub enum ErrorKind {
///
/// # Examples
///
#[cfg_attr(not(unix), doc = " ```ignore")]
#[cfg_attr(unix, doc = " ```")]
/// ```rust
/// # #[cfg(unix)] {
/// # use clap::{Command, Arg, error::ErrorKind, ArgAction};
/// # use std::os::unix::ffi::OsStringExt;
/// # use std::ffi::OsString;
@ -236,6 +237,7 @@ pub enum ErrorKind {
/// OsString::from_vec(vec![0xE9])]);
/// assert!(result.is_err());
/// assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidUtf8);
/// # }
/// ```
///
/// [`Arg::allow_invalid_utf8`]: crate::Arg::allow_invalid_utf8
@ -250,13 +252,14 @@ pub enum ErrorKind {
///
/// # Examples
///
#[cfg_attr(not(feature = "help"), doc = " ```ignore")]
#[cfg_attr(feature = "help", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "help")] {
/// # use clap::{Command, Arg, error::ErrorKind};
/// let result = Command::new("prog")
/// .try_get_matches_from(vec!["prog", "--help"]);
/// assert!(result.is_err());
/// assert_eq!(result.unwrap_err().kind(), ErrorKind::DisplayHelp);
/// # }
/// ```
DisplayHelp,

View file

@ -106,8 +106,8 @@ impl<F: ErrorFormatter> Error<F> {
///
/// # Example
///
#[cfg_attr(not(feature = "error-context"), doc = " ```ignore")]
#[cfg_attr(feature = "error-context", doc = " ```")]
/// ```rust
/// # #[cfg(feature = "error-context")] {
/// # use clap::error::ErrorKind;
/// # use clap::error::ContextKind;
/// # use clap::error::ContextValue;
@ -120,6 +120,7 @@ impl<F: ErrorFormatter> Error<F> {
/// err.insert(ContextKind::InvalidValue, ContextValue::String("bar".to_owned()));
///
/// err.print();
/// # }
/// ```
pub fn new(kind: ErrorKind) -> Self {
Self {

View file

@ -41,9 +41,10 @@
//! *(See also [feature flag reference][_features])*
//!
//! Then define your CLI in `main.rs`:
#![cfg_attr(not(feature = "derive"), doc = " ```ignore")]
#![cfg_attr(feature = "derive", doc = " ```no_run")]
//! ```rust
//! # #[cfg(feature = "derive")] {
#![doc = include_str!("../examples/demo.rs")]
//! # }
//! ```
//!
//! And try it out:

View file

@ -234,6 +234,7 @@ impl<'cmd, 'writer> HelpTemplate<'cmd, 'writer> {
}
/// Writes binary name of a Parser Object to the wrapped stream.
#[cfg(not(feature = "unstable-v5"))]
fn write_bin_name(&mut self) {
debug!("HelpTemplate::write_bin_name");

View file

@ -276,8 +276,8 @@ impl ArgMatches {
///
/// # Examples
///
#[cfg_attr(not(unix), doc = " ```ignore")]
#[cfg_attr(unix, doc = " ```")]
/// ```rust
/// # #[cfg(unix)] {
/// # use clap::{Command, arg, value_parser};
/// # use std::ffi::{OsStr,OsString};
/// # use std::os::unix::ffi::{OsStrExt,OsStringExt};
@ -297,6 +297,7 @@ impl ArgMatches {
/// assert_eq!(itr.next(), Some(OsStr::new("Hi")));
/// assert_eq!(itr.next(), Some(OsStr::from_bytes(&[0xe9, b'!'])));
/// assert_eq!(itr.next(), None);
/// # }
/// ```
/// [`Iterator`]: std::iter::Iterator
/// [`OsSt`]: std::ffi::OsStr
@ -324,8 +325,8 @@ impl ArgMatches {
///
/// # Examples
///
#[cfg_attr(not(unix), doc = " ```ignore")]
#[cfg_attr(unix, doc = " ```")]
/// ```rust
/// # #[cfg(unix)] {
/// # use clap::{Command, arg, value_parser, ArgAction, Arg};
/// # use std::ffi::{OsStr,OsString};
/// # use std::os::unix::ffi::{OsStrExt,OsStringExt};
@ -350,6 +351,7 @@ impl ArgMatches {
/// assert_eq!(itr.next(), Some(vec![OsStr::new("a"), OsStr::new("b")]));
/// assert_eq!(itr.next(), Some(vec![OsStr::new("c"), OsStr::from_bytes(&[0xe9, b'!'])]));
/// assert_eq!(itr.next(), None);
/// # }
/// ```
/// [`Iterator`]: std::iter::Iterator
/// [`OsStr`]: std::ffi::OsStr
@ -1508,8 +1510,8 @@ impl<'a, T: 'a> Default for ValuesRef<'a, T> {
///
/// # Examples
///
#[cfg_attr(not(unix), doc = " ```ignore")]
#[cfg_attr(unix, doc = " ```")]
/// ```rust
/// # #[cfg(unix)] {
/// # use clap::{Command, arg, value_parser};
/// use std::ffi::OsString;
/// use std::os::unix::ffi::{OsStrExt,OsStringExt};
@ -1527,6 +1529,7 @@ impl<'a, T: 'a> Default for ValuesRef<'a, T> {
/// .as_bytes(),
/// [b'H', b'i', b' ', 0xe9, b'!']
/// );
/// # }
/// ```
#[derive(Clone, Debug)]
pub struct RawValues<'a> {

View file

@ -14,12 +14,13 @@ pub enum ColorChoice {
///
/// # Examples
///
#[cfg_attr(not(feature = "color"), doc = " ```ignore")]
#[cfg_attr(feature = "color", doc = " ```no_run")]
/// ```rust
/// # #[cfg(feature = "color")] {
/// # use clap::{Command, ColorChoice};
/// Command::new("myprog")
/// .color(ColorChoice::Auto)
/// .get_matches();
/// # }
/// ```
Auto,
@ -31,12 +32,13 @@ pub enum ColorChoice {
///
/// # Examples
///
#[cfg_attr(not(feature = "color"), doc = " ```ignore")]
#[cfg_attr(feature = "color", doc = " ```no_run")]
/// ```rust
/// # #[cfg(feature = "color")] {
/// # use clap::{Command, ColorChoice};
/// Command::new("myprog")
/// .color(ColorChoice::Always)
/// .get_matches();
/// # }
/// ```
Always,
@ -48,12 +50,13 @@ pub enum ColorChoice {
///
/// # Examples
///
#[cfg_attr(not(feature = "color"), doc = " ```ignore")]
#[cfg_attr(feature = "color", doc = " ```no_run")]
/// ```rust
/// # #[cfg(feature = "color")] {
/// # use clap::{Command, ColorChoice};
/// Command::new("myprog")
/// .color(ColorChoice::Never)
/// .get_matches();
/// # }
/// ```
Never,
}