Move more functionality
This commit is contained in:
parent
bc8d014bc3
commit
f430e82b7a
|
@ -33,17 +33,7 @@ impl md_parser::TokenTree {
|
||||||
let parameters = table
|
let parameters = table
|
||||||
.rows
|
.rows
|
||||||
.iter()
|
.iter()
|
||||||
.map(|parameter| ReturnTypeParameter {
|
.map(|parameter| parameter.to_return_type_parameter(&types))
|
||||||
name: parameter.columns[0].clone(),
|
|
||||||
description: parameter.columns[2].clone(),
|
|
||||||
return_type: types::Type::from(
|
|
||||||
¶meter.columns[1],
|
|
||||||
¶meter.columns[0],
|
|
||||||
Some(parameter.columns[2].clone()),
|
|
||||||
&types,
|
|
||||||
)
|
|
||||||
.unwrap_or_else(|| panic!("Failed to parse type {}", ¶meter.columns[1])),
|
|
||||||
})
|
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
Some(ReturnType {
|
Some(ReturnType {
|
||||||
|
@ -74,14 +64,12 @@ impl md_parser::TokenTree {
|
||||||
// is empty
|
// is empty
|
||||||
content_it.next();
|
content_it.next();
|
||||||
if let Some(md_parser::MdContent::Table(table)) = content_it.next() {
|
if let Some(md_parser::MdContent::Table(table)) = content_it.next() {
|
||||||
let enum_types = to_type_descriptions(table);
|
|
||||||
|
|
||||||
let name = content
|
let name = content
|
||||||
.trim_start_matches(POSSIBLE_VALUES_OF)
|
.trim_start_matches(POSSIBLE_VALUES_OF)
|
||||||
.replace('`', "")
|
.replace('`', "")
|
||||||
.replace(':', "");
|
.replace(':', "");
|
||||||
|
|
||||||
output.insert(name, types::TypeDescription { values: enum_types });
|
output.insert(name, table.to_type_description());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,9 +79,15 @@ impl md_parser::TokenTree {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_type_descriptions(table: &md_parser::Table) -> Vec<types::TypeDescriptions> {
|
impl md_parser::Table {
|
||||||
table
|
pub fn to_type_description(&self) -> types::TypeDescription {
|
||||||
.rows
|
types::TypeDescription {
|
||||||
|
values: self.to_type_descriptions(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_type_descriptions(&self) -> Vec<types::TypeDescriptions> {
|
||||||
|
self.rows
|
||||||
.iter()
|
.iter()
|
||||||
.map(|row| types::TypeDescriptions {
|
.map(|row| types::TypeDescriptions {
|
||||||
value: row.columns[0].to_string(),
|
value: row.columns[0].to_string(),
|
||||||
|
@ -101,3 +95,25 @@ fn to_type_descriptions(table: &md_parser::Table) -> Vec<types::TypeDescriptions
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl md_parser::TableRow {
|
||||||
|
fn to_return_type_parameter(
|
||||||
|
&self,
|
||||||
|
types: &HashMap<String, types::TypeDescription>,
|
||||||
|
) -> ReturnTypeParameter {
|
||||||
|
let columns = &self.columns;
|
||||||
|
|
||||||
|
ReturnTypeParameter {
|
||||||
|
name: columns[0].clone(),
|
||||||
|
description: columns[2].clone(),
|
||||||
|
return_type: types::Type::from(
|
||||||
|
&columns[1],
|
||||||
|
&columns[0],
|
||||||
|
Some(columns[2].clone()),
|
||||||
|
types,
|
||||||
|
)
|
||||||
|
.unwrap_or_else(|| panic!("Failed to parse type {}", &columns[1])),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user