pub struct DocTree { /* private fields */ }Expand description
A container for the document tree. In addition to holding ownership of the tree (stored in a zipper), also contains metadata about the tree.
Implementations§
Source§impl DocTree
impl DocTree
Sourcepub fn write_to_larst(self, rustla_options: &ruSTLaOptions)
pub fn write_to_larst(self, rustla_options: &ruSTLaOptions)
A function that writes a rusTLa doctree into stdout or a file, depending on the given output option.
Source§impl DocTree
impl DocTree
Sourcepub fn perform_restructuredtext_transforms(self) -> Self
pub fn perform_restructuredtext_transforms(self) -> Self
Modifies self.tree with the known reStrucuturedText transforms.
Source§impl DocTree
§Walkers
Functions for walking to differents parts of the contained TreeZipper.
These include ID-based searches, as well as criteria related to the
contained data variant.
impl DocTree
§Walkers
Functions for walking to differents parts of the contained TreeZipper.
These include ID-based searches, as well as criteria related to the
contained data variant.
Sourcepub fn walk_to_root(self) -> Self
pub fn walk_to_root(self) -> Self
Walks to the root of the contained tree zipper.
Sourcepub fn walk(self, traversal_type: TraversalType) -> Self
pub fn walk(self, traversal_type: TraversalType) -> Self
The mother of all walkers. Performs a tree walk based on given TraversalType.
These include walking to a specific node id, but a reference to a TreeNodeType
might also be used in determining when to stop walking.
Source§impl DocTree
Document tree container methods
impl DocTree
Document tree container methods
Sourcepub fn n_of_nodes(&self) -> NodeId
pub fn n_of_nodes(&self) -> NodeId
Returns the value of the contnained node counter.
Sourcepub fn print_tree(&self)
pub fn print_tree(&self)
Mainly for debugging purposes. Prints the contaiend tree, focused on the current node.
Sourcepub fn node_count(&self) -> NodeId
pub fn node_count(&self) -> NodeId
Returns a copy of the current node count in the DocTree.
Sourcepub fn print_internal_labels(&self)
pub fn print_internal_labels(&self)
mainly for debugging purposes
Prints out the internal targe labels stored in self.hyperref_data currently being worked on.
Sourcepub fn focus_on_parent(self) -> Self
pub fn focus_on_parent(self) -> Self
Focuses self.tree on its parent node if there is one.
Sourcepub fn push_data_and_focus(self, node_data: TreeNodeType) -> Result<Self, Self>
pub fn push_data_and_focus(self, node_data: TreeNodeType) -> Result<Self, Self>
Creates a new node from given data, pushes it to the children of currently focused on node and focuses on the new node.
If this succeeds, also increments self.node_count.
Returns Result::{Ok(self), Err(self)}, depending on the success of this operation.
Sourcepub fn push_data(self, node_data: TreeNodeType) -> Result<Self, Self>
pub fn push_data(self, node_data: TreeNodeType) -> Result<Self, Self>
Creates a new node from given data and pushes it to the children of currently focused on node.
If this succeeds, also increments self.node_count.
Returns self in either Ok or an Err.
Sourcepub fn push_child(&mut self, node: TreeNode) -> Result<(), TreeNode>
pub fn push_child(&mut self, node: TreeNode) -> Result<(), TreeNode>
Pushes a new node to the children of the node currently focused on.
If the addition was successful, returns Ok(()), else returns the given node wrapped in an Err.
Sourcepub fn pop_child(&mut self) -> Option<TreeNode>
pub fn pop_child(&mut self) -> Option<TreeNode>
Removes the last child of the current node and returns in an Option.
Returns a shared reference to the current node .
Returns an optional shared reference to the current node’s children, if the exist.
Sourcepub fn mut_children(&mut self) -> Option<&mut Vec<TreeNode>>
pub fn mut_children(&mut self) -> Option<&mut Vec<TreeNode>>
Returns an optional mutable reference to the current node’s children, if the exist.
Retrieves a shared reference to the data of the currently focused on node.
Sourcepub fn mut_node_data(&mut self) -> &mut TreeNodeType
pub fn mut_node_data(&mut self) -> &mut TreeNodeType
Retrieves a shared reference to the data of the currently focused on node.
Sourcepub fn get_child_data(&self, index: usize) -> &TreeNodeType
pub fn get_child_data(&self, index: usize) -> &TreeNodeType
Retrieves a shared reference to the data of the given child of the current node.
pub fn n_of_children(&self) -> usize
Sourcepub fn get_mut_child_data(&mut self, index: usize) -> &mut TreeNodeType
pub fn get_mut_child_data(&mut self, index: usize) -> &mut TreeNodeType
Retrieves a mutable reference to the data of the given child of the current node.
Retrieves a shared reference to a given child.
Sourcepub fn mut_child(&mut self, index: usize) -> Option<&mut TreeNode>
pub fn mut_child(&mut self, index: usize) -> Option<&mut TreeNode>
Retrieves a shared reference to a given child.
Retrieves the node data of a sibling of the currently focused-on node with the given index.
Sourcepub fn index_in_parent(&self) -> Option<usize>
pub fn index_in_parent(&self) -> Option<usize>
Retrieves the index of the current node with respect to its parent.
Sourcepub fn append_children(&mut self, nodes: &mut Vec<TreeNode>)
pub fn append_children(&mut self, nodes: &mut Vec<TreeNode>)
Appends the nodes given in a given vector of nodes to the currently
focused on node in self.tree.
Sourcepub fn has_target_label(&self, label_to_be_inspected_for: &str) -> bool
pub fn has_target_label(&self, label_to_be_inspected_for: &str) -> bool
Checks whether the doctree already contains a hyperlink target with the given label.
Sourcepub fn has_reference_label(&self, label_to_be_inspected_for: &str) -> bool
pub fn has_reference_label(&self, label_to_be_inspected_for: &str) -> bool
Checks whether the doctree already contains a hyperlink reference with the given label.
Sourcepub fn current_node_id(&self) -> NodeId
pub fn current_node_id(&self) -> NodeId
Retrieves a copy of the node id currently focused on.
Sourcepub fn push_to_internal_target_stack(&mut self, label: String)
pub fn push_to_internal_target_stack(&mut self, label: String)
Pushes a given label to the chain of detected internal target labels. Once a non-internal target is encountered, this array of labels will be made to point to the newly detected node and cleared.
Sourcepub fn n_of_symbolic_footnotes(&self) -> u32
pub fn n_of_symbolic_footnotes(&self) -> u32
Returns the number of symbolic footnotes that have been entered into the doctree.
Sourcepub fn n_of_symbolic_footnote_refs(&self) -> u32
pub fn n_of_symbolic_footnote_refs(&self) -> u32
Returns the number of symbolic footnote references that have been entered into the doctree.
Sourcepub fn increment_symbolic_footnotes(&mut self)
pub fn increment_symbolic_footnotes(&mut self)
Increments symbolic footnote counter of the doctree by 1.
Sourcepub fn increment_symbolic_footnote_refs(&mut self)
pub fn increment_symbolic_footnote_refs(&mut self)
Increments symbolic footnote reference counter of the doctree by 1.
Sourcepub fn increment_anon_targets(&mut self)
pub fn increment_anon_targets(&mut self)
Increases the counter for anonymous targets entered into the doctree thus far by one.
Sourcepub fn increment_anon_references(&mut self)
pub fn increment_anon_references(&mut self)
Increases the counter for anonymous targets entered into the doctree thus far by one.
Sourcepub fn next_anon_target_n(&mut self) -> u32
pub fn next_anon_target_n(&mut self) -> u32
Increments the anon target counter and returns a copy of the result.
Sourcepub fn next_anon_reference_n(&mut self) -> u32
pub fn next_anon_reference_n(&mut self) -> u32
Increments the anon reference counter and returns a copy of the result.
Sourcepub fn next_anon_target_label(&mut self) -> String
pub fn next_anon_target_label(&mut self) -> String
Returns an allocated String representation of the next anonymous target label.
Sourcepub fn next_anon_reference_label(&mut self) -> String
pub fn next_anon_reference_label(&mut self) -> String
Returns an allocated String representation of the next anonymous reference label.
Returns a shared reference to self.targets.
Sourcepub fn mut_targets(&mut self) -> &mut HashMap<String, NodeId>
pub fn mut_targets(&mut self) -> &mut HashMap<String, NodeId>
Returns a mutable reference to self.targets.
Returns a shared reference to self.references.
Sourcepub fn mut_references(&mut self) -> &mut HashMap<String, Vec<NodeId>>
pub fn mut_references(&mut self) -> &mut HashMap<String, Vec<NodeId>>
Returns a mutable reference to self.references.
Sourcepub fn new_section_data(
&self,
title_text: &str,
section_style: SectionLineStyle,
) -> TreeNodeType
pub fn new_section_data( &self, title_text: &str, section_style: SectionLineStyle, ) -> TreeNodeType
Generates a new section node data container by comparing the given section_style to known styles
and corresponding levels via self.section_levels. If a section of such style already exists, the level of the section
is simply set to the level matching it. If not, the maximum known level is plus 1
is assigned to the section data.
Note that this function does not yet modify known section data or hyperref targets.
This is donw only if pushing the node data to the tree succeeds, and is handled
by the related methods.
Sourcepub fn add_section(
self,
title_text: &str,
section_style: SectionLineStyle,
) -> Self
pub fn add_section( self, title_text: &str, section_style: SectionLineStyle, ) -> Self
Adds a new section to the doctree, also taking care of adding the section title to the hyperref data of the tree, updating the section counter and mapping the section type to the appropriate section level.
Sourcepub fn walk_to_parent_section_level(self, level: usize) -> Self
pub fn walk_to_parent_section_level(self, level: usize) -> Self
Walks up the tree to a given section level.
Returns an Optional shared reference to the parent node.
Returns a shared reference to the data of the current node.
Returns an Optional shared reference to parent node data.
Sourcepub fn new_symbolic_footnote_label(&self) -> Option<String>
pub fn new_symbolic_footnote_label(&self) -> Option<String>
Generates a new symbolic footnote label, wrapped in an Option.
Does not increment the symbolic footnote counter,
as at the point of calling this function we have no information about whether the
insertion of the respective node into the doctree succeeded.
Sourcepub fn new_symbolic_footnote_ref_label(&self) -> Option<String>
pub fn new_symbolic_footnote_ref_label(&self) -> Option<String>
Generates a new symbolic footnote reference label, wrapped in an Option.
Does not increment the symbolic footnote counter,
as at the point of calling this function we have no information about whether the
insertion of the respective node into the doctree succeeded.
Sourcepub fn new_autonumber_footnote_label(&self) -> Option<String>
pub fn new_autonumber_footnote_label(&self) -> Option<String>
Generates a new footnote number based on existing footnote labels. Again, does not modify the doctree, as knowledge about node insertion success is nil at this point.
Sourcepub fn new_autonumber_footnote_ref_label(&self) -> Option<String>
pub fn new_autonumber_footnote_ref_label(&self) -> Option<String>
Generates a new footnote reference number based on existing footnote reference labels. Again, does not modify the doctree, as knowledge about node insertion success is nil at this point.