Skip to content

Commit

Permalink
Auto merge of #507 - kbknapp:issue-505, r=kbknapp
Browse files Browse the repository at this point in the history
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
  • Loading branch information
homu committed May 14, 2016
2 parents 0c6c4ad + 52ca650 commit 923117e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
30 changes: 30 additions & 0 deletions src/args/arg_matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,19 @@ impl<'a> ArgMatches<'a> {
// commit: be5e1fa3c26e351761b33010ddbdaf5f05dbcc33
// license: MIT - Copyright (c) 2015 The Rust Project Developers

/// An iterator for getting multiple values out of an argument via the `Arg::values_of` method.
///
/// # Examples
///
/// ```rust
/// # use clap::{App, Arg};
/// let m = App::new("myapp")
/// .arg(Arg::with_name("output")
/// .takes_value(true))
/// .get_matches_from(vec!["myapp", "something"]);
///
/// assert_eq!(m.value_of("output"), Some("something"));
/// ```
#[derive(Clone)]
#[allow(missing_debug_implementations)]
pub struct Values<'a> {
Expand Down Expand Up @@ -576,6 +589,23 @@ impl<'a, V> DoubleEndedIterator for Iter<'a, V> {
}
}

/// An iterator for getting multiple values out of an argument via the `Arg::values_of_os` method.
/// Usage of this iterator allows values which contain invalid UTF-8 code points unlike `Values`.
///
/// # Examples
///
/// ```ignore
/// # use clap::{App, Arg};
/// use std::ffi::OsString;
/// use std::os::unix::ffi::OsStrExt;
///
/// let m = App::new("utf8")
/// .arg(Arg::from_usage("<arg> 'some arg'"))
/// .get_matches_from(vec![OsString::from("myprog"),
/// // "Hi {0xe9}!"
/// 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'!']);
/// ```
#[derive(Clone)]
#[allow(missing_debug_implementations)]
pub struct OsValues<'a> {
Expand Down
2 changes: 1 addition & 1 deletion src/args/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub use self::arg::Arg;
pub use self::arg_matches::ArgMatches;
pub use self::arg_matches::{Values, OsValues, ArgMatches};
pub use self::arg_matcher::ArgMatcher;
pub use self::subcommand::SubCommand;
pub use self::arg_builder::{FlagBuilder, OptBuilder, PosBuilder};
Expand Down
1 change: 0 additions & 1 deletion src/args/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ impl Default for ArgFlags {
/// Various settings that apply to arguments and may be set, unset, and checked via getter/setter
/// methods `Arg::set`, `Arg::unset`, and `Arg::is_set`
#[derive(Debug, PartialEq, Copy, Clone)]
#[doc(hidden)]
pub enum ArgSettings {
/// The argument must be used
Required,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ extern crate vec_map;

#[cfg(feature = "yaml")]
pub use yaml_rust::YamlLoader;
pub use args::{Arg, ArgGroup, ArgMatches, ArgSettings, SubCommand};
pub use args::{Arg, ArgGroup, ArgMatches, ArgSettings, SubCommand, Values, OsValues};
pub use app::{App, AppSettings};
pub use fmt::Format;
pub use errors::{Error, ErrorKind, Result};
Expand Down

0 comments on commit 923117e

Please sign in to comment.