Skip to content

Commit

Permalink
Merge pull request #228 from epage/docs
Browse files Browse the repository at this point in the history
docs: Clean up doc cfgs
  • Loading branch information
epage authored Mar 27, 2023
2 parents a531c61 + 4a11ed7 commit 681bea8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
5 changes: 3 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ pub trait FinishIResult<I, O, E> {
///
/// # Example
///
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "std", doc = "```")]
/// ```rust
/// # #[cfg(feature = "std")] {
/// use winnow::prelude::*;
/// use winnow::character::hex_uint;
/// use winnow::error::Error;
Expand All @@ -69,6 +69,7 @@ pub trait FinishIResult<I, O, E> {
/// fn parse(value: &str) -> Result<Hex, Error<String>> {
/// hex_uint.map(Hex).parse_next(value).finish().map_err(Error::into_owned)
/// }
/// # }
/// ```
#[deprecated(since = "0.4.0", note = "Replaced with `Parser::parse`")]
fn finish(self) -> Result<O, E>;
Expand Down
40 changes: 24 additions & 16 deletions src/multi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use crate::Parser;
///
/// # Example
///
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "std", doc = "```")]
/// ```rust
/// # #[cfg(feature = "std")] {
/// # use winnow::{error::ErrMode, error::ErrorKind, error::Needed};
/// # use winnow::prelude::*;
/// use winnow::multi::many0;
Expand All @@ -38,6 +38,7 @@ use crate::Parser;
/// assert_eq!(parser("abc123"), Ok(("123", vec!["abc"])));
/// assert_eq!(parser("123123"), Ok(("123123", vec![])));
/// assert_eq!(parser(""), Ok(("", vec![])));
/// # }
/// ```
#[doc(alias = "skip_many")]
#[doc(alias = "repeated")]
Expand Down Expand Up @@ -87,8 +88,8 @@ where
///
/// # Example
///
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "std", doc = "```")]
/// ```rust
/// # #[cfg(feature = "std")] {
/// # use winnow::{error::ErrMode, error::{Error, ErrorKind}, error::Needed};
/// # use winnow::prelude::*;
/// use winnow::multi::many1;
Expand All @@ -102,6 +103,7 @@ where
/// assert_eq!(parser("abc123"), Ok(("123", vec!["abc"])));
/// assert_eq!(parser("123123"), Err(ErrMode::Backtrack(Error::new("123123", ErrorKind::Tag))));
/// assert_eq!(parser(""), Err(ErrMode::Backtrack(Error::new("", ErrorKind::Tag))));
/// # }
/// ```
#[doc(alias = "skip_many1")]
#[doc(alias = "repeated")]
Expand Down Expand Up @@ -150,8 +152,8 @@ where
///
/// # Example
///
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "std", doc = "```")]
/// ```rust
/// # #[cfg(feature = "std")] {
/// # use winnow::{error::ErrMode, error::{Error, ErrorKind}, error::Needed};
/// # use winnow::prelude::*;
/// use winnow::multi::many_till0;
Expand All @@ -166,6 +168,7 @@ where
/// assert_eq!(parser("123123end"), Err(ErrMode::Backtrack(Error::new("123123end", ErrorKind::Tag))));
/// assert_eq!(parser(""), Err(ErrMode::Backtrack(Error::new("", ErrorKind::Tag))));
/// assert_eq!(parser("abcendefg"), Ok(("efg", (vec!["abc"], "end"))));
/// # }
/// ```
pub fn many_till0<I, O, C, P, E, F, G>(mut f: F, mut g: G) -> impl Parser<I, (C, P), E>
where
Expand Down Expand Up @@ -212,8 +215,8 @@ where
///
/// # Example
///
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "std", doc = "```")]
/// ```rust
/// # #[cfg(feature = "std")] {
/// # use winnow::{error::ErrMode, error::ErrorKind, error::Needed};
/// # use winnow::prelude::*;
/// use winnow::multi::separated0;
Expand All @@ -228,6 +231,7 @@ where
/// assert_eq!(parser("abc|def"), Ok(("|def", vec!["abc"])));
/// assert_eq!(parser(""), Ok(("", vec![])));
/// assert_eq!(parser("def|abc"), Ok(("def|abc", vec![])));
/// # }
/// ```
#[doc(alias = "sep_by")]
#[doc(alias = "separated_list0")]
Expand Down Expand Up @@ -289,8 +293,8 @@ where
///
/// # Example
///
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "std", doc = "```")]
/// ```rust
/// # #[cfg(feature = "std")] {
/// # use winnow::{error::ErrMode, error::{Error, ErrorKind}, error::Needed};
/// # use winnow::prelude::*;
/// use winnow::multi::separated1;
Expand All @@ -305,6 +309,7 @@ where
/// assert_eq!(parser("abc|def"), Ok(("|def", vec!["abc"])));
/// assert_eq!(parser(""), Err(ErrMode::Backtrack(Error::new("", ErrorKind::Tag))));
/// assert_eq!(parser("def|abc"), Err(ErrMode::Backtrack(Error::new("def|abc", ErrorKind::Tag))));
/// # }
/// ```
#[doc(alias = "sep_by1")]
#[doc(alias = "separated_list1")]
Expand Down Expand Up @@ -484,8 +489,8 @@ where
///
/// # Example
///
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "std", doc = "```")]
/// ```rust
/// # #[cfg(feature = "std")] {
/// # use winnow::{error::ErrMode, error::ErrorKind, error::Needed};
/// # use winnow::prelude::*;
/// use winnow::multi::many_m_n;
Expand All @@ -500,6 +505,7 @@ where
/// assert_eq!(parser("123123"), Ok(("123123", vec![])));
/// assert_eq!(parser(""), Ok(("", vec![])));
/// assert_eq!(parser("abcabcabc"), Ok(("abc", vec!["abc", "abc"])));
/// # }
/// ```
#[doc(alias = "repeated")]
pub fn many_m_n<I, O, C, E, F>(min: usize, max: usize, mut parse: F) -> impl Parser<I, C, E>
Expand Down Expand Up @@ -554,8 +560,8 @@ where
///
/// # Example
///
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "std", doc = "```")]
/// ```rust
/// # #[cfg(feature = "std")] {
/// # use winnow::{error::ErrMode, error::{Error, ErrorKind}, error::Needed};
/// # use winnow::prelude::*;
/// use winnow::multi::count;
Expand All @@ -570,6 +576,7 @@ where
/// assert_eq!(parser("123123"), Err(ErrMode::Backtrack(Error::new("123123", ErrorKind::Tag))));
/// assert_eq!(parser(""), Err(ErrMode::Backtrack(Error::new("", ErrorKind::Tag))));
/// assert_eq!(parser("abcabcabc"), Ok(("abc", vec!["abc", "abc"])));
/// # }
/// ```
#[doc(alias = "skip_counskip_count")]
pub fn count<I, O, C, E, F>(mut f: F, count: usize) -> impl Parser<I, C, E>
Expand Down Expand Up @@ -1022,8 +1029,8 @@ where
///
/// # Example
///
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "std", doc = "```")]
/// ```rust
/// # #[cfg(feature = "std")] {
/// # use winnow::prelude::*;
/// # use winnow::{error::ErrMode, error::{Error, ErrorKind}, error::Needed};
/// # use winnow::prelude::*;
Expand All @@ -1047,6 +1054,7 @@ where
///
/// assert_eq!(parser(stream(b"\x02abcabcabc")), Ok((stream(b"abc"), vec![&b"abc"[..], &b"abc"[..]])));
/// assert_eq!(parser(stream(b"\x03123123123")), Err(ErrMode::Backtrack(Error::new(stream(b"123123123"), ErrorKind::Tag))));
/// # }
/// ```
pub fn length_count<I, O, C, N, E, F, G>(mut f: F, mut g: G) -> impl Parser<I, C, E>
where
Expand Down

0 comments on commit 681bea8

Please sign in to comment.