Refactor Parser::parse_item_doc

This patch simplifies the Parser::parse_item_doc function by collecting
all members before pushing them into the member groups.
This commit is contained in:
Robin Krahl 2020-08-17 10:44:49 +02:00
parent 93575ab452
commit 1e9da34694
No known key found for this signature in database
GPG Key ID: 8E9B0870524F69D8

View File

@ -77,25 +77,17 @@ impl Parser {
doc.description = description.map(From::from); doc.description = description.map(From::from);
doc.definition = definition.map(From::from); doc.definition = definition.map(From::from);
let (ty, groups) = get_variants(&self.document, name)?; let members = vec![
if !groups.is_empty() { get_variants(&self.document, name)?,
doc.groups.push((ty, groups)); get_fields(&self.document, name)?,
} get_assoc_types(&self.document, name)?,
let (ty, groups) = get_fields(&self.document, name)?; get_methods(&self.document, name)?,
if !groups.is_empty() { get_implementations(&self.document, name)?,
doc.groups.push((ty, groups)); ];
} for (ty, groups) in members.into_iter() {
let (ty, groups) = get_assoc_types(&self.document, name)?; if !groups.is_empty() {
if !groups.is_empty() { doc.groups.push((ty, groups));
doc.groups.push((ty, groups)); }
}
let (ty, groups) = get_methods(&self.document, name)?;
if !groups.is_empty() {
doc.groups.push((ty, groups));
}
let (ty, groups) = get_implementations(&self.document, name)?;
if !groups.is_empty() {
doc.groups.push((ty, groups));
} }
Ok(doc) Ok(doc)