Skip to content

Commit 52ca650

Browse files
committed
docs: makes all publicly available types viewable in docs
Some types weren't viewable in the docs, such as `Values`, `OsValues`, and `ArgSettings`. All these types should now be browsable in the docs page. Relates to #505
1 parent 0c6c4ad commit 52ca650

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

src/args/arg_matches.rs

+30
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,19 @@ impl<'a> ArgMatches<'a> {
506506
// commit: be5e1fa3c26e351761b33010ddbdaf5f05dbcc33
507507
// license: MIT - Copyright (c) 2015 The Rust Project Developers
508508

509+
/// An iterator for getting multiple values out of an argument via the `Arg::values_of` method.
510+
///
511+
/// # Examples
512+
///
513+
/// ```rust
514+
/// # use clap::{App, Arg};
515+
/// let m = App::new("myapp")
516+
/// .arg(Arg::with_name("output")
517+
/// .takes_value(true))
518+
/// .get_matches_from(vec!["myapp", "something"]);
519+
///
520+
/// assert_eq!(m.value_of("output"), Some("something"));
521+
/// ```
509522
#[derive(Clone)]
510523
#[allow(missing_debug_implementations)]
511524
pub struct Values<'a> {
@@ -576,6 +589,23 @@ impl<'a, V> DoubleEndedIterator for Iter<'a, V> {
576589
}
577590
}
578591

592+
/// An iterator for getting multiple values out of an argument via the `Arg::values_of_os` method.
593+
/// Usage of this iterator allows values which contain invalid UTF-8 code points unlike `Values`.
594+
///
595+
/// # Examples
596+
///
597+
/// ```ignore
598+
/// # use clap::{App, Arg};
599+
/// use std::ffi::OsString;
600+
/// use std::os::unix::ffi::OsStrExt;
601+
///
602+
/// let m = App::new("utf8")
603+
/// .arg(Arg::from_usage("<arg> 'some arg'"))
604+
/// .get_matches_from(vec![OsString::from("myprog"),
605+
/// // "Hi {0xe9}!"
606+
/// OsString::from_vec(vec![b'H', b'i', b' ', 0xe9, b'!'])]);
607+
/// assert_eq!(&*m.value_of_os("arg").unwrap().as_bytes(), [b'H', b'i', b' ', 0xe9, b'!']);
608+
/// ```
579609
#[derive(Clone)]
580610
#[allow(missing_debug_implementations)]
581611
pub struct OsValues<'a> {

src/args/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
pub use self::arg::Arg;
2-
pub use self::arg_matches::ArgMatches;
2+
pub use self::arg_matches::{Values, OsValues, ArgMatches};
33
pub use self::arg_matcher::ArgMatcher;
44
pub use self::subcommand::SubCommand;
55
pub use self::arg_builder::{FlagBuilder, OptBuilder, PosBuilder};

src/args/settings.rs

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ impl Default for ArgFlags {
4646
/// Various settings that apply to arguments and may be set, unset, and checked via getter/setter
4747
/// methods `Arg::set`, `Arg::unset`, and `Arg::is_set`
4848
#[derive(Debug, PartialEq, Copy, Clone)]
49-
#[doc(hidden)]
5049
pub enum ArgSettings {
5150
/// The argument must be used
5251
Required,

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ extern crate vec_map;
417417

418418
#[cfg(feature = "yaml")]
419419
pub use yaml_rust::YamlLoader;
420-
pub use args::{Arg, ArgGroup, ArgMatches, ArgSettings, SubCommand};
420+
pub use args::{Arg, ArgGroup, ArgMatches, ArgSettings, SubCommand, Values, OsValues};
421421
pub use app::{App, AppSettings};
422422
pub use fmt::Format;
423423
pub use errors::{Error, ErrorKind, Result};

0 commit comments

Comments
 (0)