summaryrefslogtreecommitdiff
path: root/src/description.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/description.rs')
-rw-r--r--src/description.rs53
1 files changed, 38 insertions, 15 deletions
diff --git a/src/description.rs b/src/description.rs
index e6cd1cd..615b0c2 100644
--- a/src/description.rs
+++ b/src/description.rs
@@ -1,6 +1,6 @@
//! Reference entry description.
-use crate::informal_table::{Error as InformalTableError, InformalTable};
use crate::itemized_list::{Error as ItemizedListError, ItemizedList};
+use crate::table::{Error as TableError, Informal, Table};
use crate::variable_list::{Error as VariableListError, VariableList};
use crate::xml::element::{Element, Elements, FromElements, Tagged};
@@ -97,7 +97,7 @@ impl FromElements for Description
.unwrap_or_default(),
))),
"informaltable" => Some(
- InformalTable::from_elements(part_elem.child_elements())
+ Informal::from_elements(part_elem.child_elements())
.map(Part::InformalTable)
.map_err(Self::Error::InvalidInformalTable),
),
@@ -106,6 +106,11 @@ impl FromElements for Description
.map(Part::ItemizedList)
.map_err(Self::Error::InvalidItemizedList),
),
+ "table" => Some(
+ Table::from_elements(part_elem.child_elements())
+ .map(Part::Table)
+ .map_err(Self::Error::InvalidTable),
+ ),
"title" => None,
name => Some(Err(Self::Error::UnknownPartFound(name.to_string()))),
})
@@ -136,11 +141,15 @@ pub enum Error
/// Invalid informal table.
#[error("Invalid informal table")]
- InvalidInformalTable(#[source] InformalTableError),
+ InvalidInformalTable(#[source] TableError),
/// Invalid itemized list.
#[error("Invalid itemized list")]
InvalidItemizedList(#[source] ItemizedListError),
+
+ /// Invalid table.
+ #[error("Invalid table")]
+ InvalidTable(#[source] TableError),
}
/// Description part.
@@ -157,10 +166,13 @@ pub enum Part
ProgramListing(String),
/// Informal table.
- InformalTable(InformalTable),
+ InformalTable(Informal),
/// Itemized list.
ItemizedList(ItemizedList),
+
+ /// Table.
+ Table(Table),
}
/// Reference entry description paragraph.
@@ -258,13 +270,16 @@ pub enum ParagraphPart
ItemizedList(ItemizedList),
/// Informal table part.
- InformalTable(InformalTable),
+ InformalTable(Informal),
/// Paragraph part.
Paragraph(Paragraph),
/// Footnote part.
Footnote(Paragraph),
+
+ /// Table part.
+ Table(Table),
}
impl FromElements for ParagraphPart
@@ -300,11 +315,10 @@ impl ParagraphPart
"inlineequation" => Self::InlineEquation,
"programlisting" => Self::ProgramListing,
"citerefentry" => Self::Entry,
- "variablelist" | "itemizedlist" | "informaltable" | "para" | "footnote" => {
- |_| {
- unreachable!();
- }
- }
+ "variablelist" | "itemizedlist" | "informaltable" | "para" | "footnote"
+ | "table" => |_| {
+ unreachable!();
+ },
_ => {
return Err(<Self as FromElements>::Error::UnknownPart(
tagged_element.name().to_string(),
@@ -341,10 +355,8 @@ impl ParagraphPart
}
if tagged_element.name() == "informaltable" {
- let informal_table = InformalTable::from_elements(
- tagged_element.child_elements(),
- )
- .map_err(|err| ParagraphPartError::InvalidInformalTable(Box::new(err)))?;
+ let informal_table = Informal::from_elements(tagged_element.child_elements())
+ .map_err(|err| ParagraphPartError::InvalidInformalTable(Box::new(err)))?;
return Ok(Self::InformalTable(informal_table));
}
@@ -373,6 +385,13 @@ impl ParagraphPart
));
}
+ if tagged_element.name() == "table" {
+ let table = Table::from_elements(tagged_element.child_elements())
+ .map_err(|err| ParagraphPartError::InvalidInformalTable(Box::new(err)))?;
+
+ return Ok(Self::Table(table));
+ }
+
let text_element = tagged_element
.child_elements()
.get_first_text_element()
@@ -412,7 +431,7 @@ pub enum ParagraphPartError
/// Invalid informal table.
#[error("Invalid informal table")]
- InvalidInformalTable(#[source] Box<InformalTableError>),
+ InvalidInformalTable(#[source] Box<TableError>),
/// Invalid paragraph.
#[error("Invalid paragraph")]
@@ -421,4 +440,8 @@ pub enum ParagraphPartError
/// Invalid footnote.
#[error("Invalid footnote")]
InvalidFootnote(#[source] Box<ParagraphError>),
+
+ /// Invalid table.
+ #[error("Invalid table")]
+ InvalidTable(#[source] Box<TableError>),
}