Skip to content

Commit

Permalink
Fix doctest formatting
Browse files Browse the repository at this point in the history
Also add a doc link
  • Loading branch information
Scripter17 committed Oct 20, 2024
1 parent 451817f commit 844234c
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 89 deletions.
2 changes: 0 additions & 2 deletions src/types/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ pub enum Rule {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// Rule::Repeat {
Expand Down Expand Up @@ -191,7 +190,6 @@ pub enum Rule {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// Rule::Normal {
Expand Down
34 changes: 0 additions & 34 deletions src/types/rules/conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// Condition::Error.satisfied_by(&job_state.to_view()).unwrap_err();
Expand Down Expand Up @@ -62,7 +61,6 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::Not(Box::new(Condition::Always)).satisfied_by(&job_state.to_view()).unwrap(), false);
Expand All @@ -78,7 +76,6 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::All(vec![Condition::Always, Condition::Always]).satisfied_by(&job_state.to_view()).unwrap(), true );
Expand All @@ -100,7 +97,6 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::Any(vec![Condition::Always, Condition::Always]).satisfied_by(&job_state.to_view()).unwrap(), true );
Expand Down Expand Up @@ -142,7 +138,6 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::TreatErrorAsPass(Box::new(Condition::Always)).satisfied_by(&job_state.to_view()).unwrap(), true );
Expand All @@ -154,7 +149,6 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::TreatErrorAsFail(Box::new(Condition::Always)).satisfied_by(&job_state.to_view()).unwrap(), true );
Expand All @@ -170,7 +164,6 @@ pub enum Condition {
/// ```
/// # use url_cleaner::types::*;
/// # use url::Url;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::TryElse{r#try: Box::new(Condition::Always), r#else: Box::new(Condition::Always)}.satisfied_by(&job_state.to_view()).unwrap(), true );
Expand Down Expand Up @@ -202,9 +195,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url::Url;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// *job_state.url = Url::parse("https://example.com" ).unwrap();
Expand All @@ -227,9 +218,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url::Url;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// *job_state.url = Url::parse("https://example.com" ).unwrap();
Expand All @@ -248,9 +237,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url::Url;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// *job_state.url = Url::parse("https://example.com" ).unwrap();
Expand All @@ -272,11 +259,8 @@ pub enum Condition {
/// # Examples
/// ```
/// # use std::collections::HashSet;
///
/// # use url::Url;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::HostIsOneOf(HashSet::from_iter([ "example.com".to_string(), "example2.com".to_string()])).satisfied_by(&job_state.to_view()).unwrap(), true );
Expand All @@ -296,9 +280,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url::Url;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// *job_state.url = Url::parse("https://example.com" ).unwrap();
Expand Down Expand Up @@ -345,9 +327,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url::Url;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// *job_state.url = Url::parse("https://example.com" ).unwrap();
Expand All @@ -373,9 +353,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url::Url;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// *job_state.url = Url::parse("https://example.com" ).unwrap();
Expand Down Expand Up @@ -410,9 +388,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url::Url;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// *job_state.url = Url::parse("https://example.com?a=2&b=3").unwrap();
Expand All @@ -429,9 +405,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url::Url;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
///
Expand All @@ -456,7 +430,6 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::PartIs{part: UrlPart::Username , value: None}.satisfied_by(&job_state.to_view()).unwrap(), false);
Expand All @@ -480,7 +453,6 @@ pub enum Condition {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::PartContains {part: UrlPart::Domain, value: "ple".into(), r#where: StringLocation::Anywhere}.satisfied_by(&job_state.to_view()).unwrap(), true );
Expand Down Expand Up @@ -512,9 +484,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use std::collections::HashMap;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// // Putting this in the `job_state!` call doesn't work???`
Expand All @@ -538,9 +508,7 @@ pub enum Condition {
/// # Examples
/// ```
/// # use std::collections::HashSet;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// // Putting this in the `job_state!` call doesn't work???`
Expand Down Expand Up @@ -596,7 +564,6 @@ pub enum Condition {
/// ```
/// # use url_cleaner::types::*;
/// # use url_cleaner::glue::CommandConfig;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(Condition::CommandExists (CommandConfig::from("/usr/bin/true" )).satisfied_by(&job_state.to_view()).unwrap(), true );
Expand All @@ -612,7 +579,6 @@ pub enum Condition {
/// ```
/// # use url_cleaner::types::*;
/// # use url_cleaner::glue::CommandConfig;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert!(Condition::CommandExitStatus {command: CommandConfig::from("/usr/bin/true" ), expected: 0}.satisfied_by(&job_state.to_view()).is_ok_and(|x| x==true ));
Expand Down
21 changes: 5 additions & 16 deletions src/types/rules/mappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ pub enum Mapper {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state; url = "https://example.com";);
/// url_cleaner::job_state!(job_state;);
///
/// Mapper::All(vec![Mapper::SetHost("2.com".to_string()), Mapper::Error]).apply(&mut job_state).unwrap_err();
/// assert_eq!(job_state.url.domain(), Some("example.com"));
Expand All @@ -77,8 +76,7 @@ pub enum Mapper {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state; url = "https://example.com";);
/// url_cleaner::job_state!(job_state;);
///
/// Mapper::AllNoRevert(vec![Mapper::SetHost("3.com".to_string()), Mapper::Error, Mapper::SetHost("4.com".to_string())]).apply(&mut job_state).unwrap_err();
/// assert_eq!(job_state.url.domain(), Some("3.com"));
Expand All @@ -89,8 +87,7 @@ pub enum Mapper {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state; url = "https://example.com";);
/// url_cleaner::job_state!(job_state;);
///
/// Mapper::AllIgnoreError(vec![Mapper::SetHost("5.com".to_string()), Mapper::Error, Mapper::SetHost("6.com".to_string())]).apply(&mut job_state).unwrap();
/// assert_eq!(job_state.url.domain(), Some("6.com"));
Expand Down Expand Up @@ -157,8 +154,7 @@ pub enum Mapper {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state; url = "https://example.com";);
/// url_cleaner::job_state!(job_state;);
///
/// Mapper::TryElse {r#try: Box::new(Mapper::None ), r#else: Box::new(Mapper::None )}.apply(&mut job_state).unwrap ();
/// Mapper::TryElse {r#try: Box::new(Mapper::None ), r#else: Box::new(Mapper::Error)}.apply(&mut job_state).unwrap ();
Expand All @@ -177,8 +173,7 @@ pub enum Mapper {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state; url = "https://example.com";);
/// url_cleaner::job_state!(job_state;);
///
/// Mapper::FirstNotError(vec![Mapper::SetHost("1.com".to_string()), Mapper::SetHost("2.com".to_string())]).apply(&mut job_state).unwrap();
/// assert_eq!(job_state.url.domain(), Some("1.com"));
Expand All @@ -201,9 +196,7 @@ pub enum Mapper {
/// # Examples
/// ```
/// # use std::collections::hash_set::HashSet;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state; url = "https://example.com?a=2&b=3&c=4&d=5";);
///
/// Mapper::RemoveQueryParams(HashSet::from(["a".to_string()])).apply(&mut job_state).unwrap();
Expand All @@ -219,9 +212,7 @@ pub enum Mapper {
/// # Examples
/// ```
/// # use std::collections::hash_set::HashSet;
///
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state; url = "https://example.com?a=2&b=3";);
///
/// Mapper::AllowQueryParams(HashSet::from(["a".to_string()])).apply(&mut job_state).unwrap();
Expand Down Expand Up @@ -299,7 +290,6 @@ pub enum Mapper {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state; url = "https://abc.example.com";);
///
/// Mapper::MovePart{from: UrlPart::Subdomain, to: UrlPart::BeforePathSegment(0)}.apply(&mut job_state).unwrap();
Expand Down Expand Up @@ -353,7 +343,6 @@ pub enum Mapper {
/// ```
/// # use reqwest::header::HeaderMap;
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state; url = "https://t.co/H8IF8DHSFL";);
///
/// Mapper::ExpandRedirect{headers: HeaderMap::default(), http_client_config_diff: None}.apply(&mut job_state).unwrap();
Expand Down
5 changes: 0 additions & 5 deletions src/types/string_matcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ pub enum StringMatcher {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(StringMatcher::Contains {r#where: StringLocation::Start, value: "utm_".into()}.satisfied_by("utm_abc", &job_state.to_view()).unwrap(), true);
Expand All @@ -114,7 +113,6 @@ pub enum StringMatcher {
/// ```
/// # use url_cleaner::types::*;
/// # use url_cleaner::glue::RegexParts;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(StringMatcher::Regex(RegexParts::new("a.c").unwrap().try_into().unwrap()).satisfied_by("axc", &job_state.to_view()).unwrap(), true);
Expand All @@ -126,7 +124,6 @@ pub enum StringMatcher {
/// # use url_cleaner::types::*;
/// # use url_cleaner::glue::GlobWrapper;
/// # use std::str::FromStr;
///
/// url_cleaner::job_state!(job_state;);
///
/// assert_eq!(StringMatcher::Glob(GlobWrapper::from_str("a*c").unwrap()).satisfied_by("aabcc", &job_state.to_view()).unwrap(), true);
Expand Down Expand Up @@ -203,7 +200,6 @@ pub enum StringMatcher {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// let matcher = StringMatcher::SegmentsStartWith {
Expand All @@ -228,7 +224,6 @@ pub enum StringMatcher {
/// # Examples
/// ```
/// # use url_cleaner::types::*;
///
/// url_cleaner::job_state!(job_state;);
///
/// let matcher = StringMatcher::SegmentsEndWith {
Expand Down
Loading

0 comments on commit 844234c

Please sign in to comment.