Remove util
This commit is contained in:
parent
af49a83034
commit
135f4861ff
|
@ -2,7 +2,7 @@ mod description;
|
|||
mod return_type;
|
||||
mod url;
|
||||
|
||||
use crate::{md_parser, parser::util, types};
|
||||
use crate::{md_parser, types};
|
||||
pub use return_type::ReturnType;
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
@ -74,8 +74,13 @@ impl ApiMethod {
|
|||
}
|
||||
|
||||
impl md_parser::TokenTree {
|
||||
fn find_content_starts_with(&self, content: &str) -> Option<String> {
|
||||
util::find_content_starts_with(&self.content, content)
|
||||
fn find_content_starts_with(&self, starts_with: &str) -> Option<String> {
|
||||
self.content.iter().find_map(|row| match row {
|
||||
md_parser::MdContent::Text(content) if content.starts_with(starts_with) => {
|
||||
Some(content.into())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
md_parser::{self, MdContent},
|
||||
md_parser,
|
||||
parser::{types, ReturnTypeParameter},
|
||||
};
|
||||
|
||||
|
@ -47,12 +47,7 @@ impl md_parser::TokenTree {
|
|||
}
|
||||
|
||||
fn is_list(&self) -> bool {
|
||||
self.content
|
||||
.iter()
|
||||
.find_map(|row| match row {
|
||||
MdContent::Text(text) if text.starts_with("The response is a") => Some(text),
|
||||
_ => None,
|
||||
})
|
||||
self.find_content_starts_with("The response is a")
|
||||
.map(|found| found.contains("array"))
|
||||
.unwrap_or_else(|| false)
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use crate::{md_parser, parser::util};
|
||||
use crate::md_parser;
|
||||
|
||||
impl md_parser::TokenTree {
|
||||
pub fn get_method_url(&self) -> String {
|
||||
const START: &str = "Name: ";
|
||||
|
||||
util::find_content_starts_with(&self.content, START)
|
||||
self.find_content_starts_with(START)
|
||||
.map(|text| text.trim_start_matches(START).trim_matches('`').to_string())
|
||||
.expect("Could find method url")
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
use regex::Regex;
|
||||
|
||||
use crate::{md_parser, parser::util};
|
||||
use crate::md_parser;
|
||||
|
||||
impl md_parser::TokenTree {
|
||||
pub fn get_group_url(&self) -> String {
|
||||
let row = util::find_content_contains(&self.content, "API methods are under")
|
||||
let row = self
|
||||
.find_content_contains("API methods are under")
|
||||
.expect("Could not find api method");
|
||||
|
||||
let re = Regex::new(r#"All (?:\w+\s?)+ API methods are under "(\w+)", e.g."#)
|
||||
|
@ -13,4 +14,13 @@ impl md_parser::TokenTree {
|
|||
let res = re.captures(&row).expect("Failed find capture");
|
||||
res[1].to_string()
|
||||
}
|
||||
|
||||
fn find_content_contains(&self, contains: &str) -> Option<String> {
|
||||
self.content.iter().find_map(|row| match row {
|
||||
md_parser::MdContent::Text(content) if content.contains(contains) => {
|
||||
Some(content.into())
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::{md_parser, types};
|
||||
|
||||
mod group;
|
||||
mod util;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ReturnTypeParameter {
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
use crate::md_parser::MdContent;
|
||||
|
||||
pub fn find_content_starts_with(content: &[MdContent], starts_with: &str) -> Option<String> {
|
||||
content.iter().find_map(|row| match row {
|
||||
MdContent::Text(content) if content.starts_with(starts_with) => Some(content.into()),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn find_content_contains(content: &[MdContent], contains: &str) -> Option<String> {
|
||||
content.iter().find_map(|row| match row {
|
||||
MdContent::Text(content) if content.contains(contains) => Some(content.into()),
|
||||
_ => None,
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user