DocTree

Struct DocTree 

Source
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

Source

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

Source

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.

Source

pub fn walk_to_root(self) -> Self

Walks to the root of the contained tree zipper.

Source

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

Source

pub fn new(doc_name: PathBuf) -> Self

A DocTree constructor.

Source

pub fn n_of_nodes(&self) -> NodeId

Returns the value of the contnained node counter.

Source

pub fn print_tree(&self)

Mainly for debugging purposes. Prints the contaiend tree, focused on the current node.

Source

pub fn node_count(&self) -> NodeId

Returns a copy of the current node count in the DocTree.

Source

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.

Source

pub fn focus_on_parent(self) -> Self

Focuses self.tree on its parent node if there is one.

Source

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.

Source

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.

Source

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.

Source

pub fn pop_child(&mut self) -> Option<TreeNode>

Removes the last child of the current node and returns in an Option.

Source

pub fn shared_node(&self) -> &TreeNode

Returns a shared reference to the current node .

Source

pub fn mut_node(&mut self) -> &mut TreeNode

Returns a shared reference to the current node .

Source

pub fn shared_children(&self) -> Option<&Vec<TreeNode>>

Returns an optional shared reference to the current node’s children, if the exist.

Source

pub fn mut_children(&mut self) -> Option<&mut Vec<TreeNode>>

Returns an optional mutable reference to the current node’s children, if the exist.

Source

pub fn shared_node_data(&self) -> &TreeNodeType

Retrieves a shared reference to the data of the currently focused on node.

Source

pub fn mut_node_data(&mut self) -> &mut TreeNodeType

Retrieves a shared reference to the data of the currently focused on node.

Source

pub fn get_child_data(&self, index: usize) -> &TreeNodeType

Retrieves a shared reference to the data of the given child of the current node.

Source

pub fn n_of_children(&self) -> usize

Source

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.

Source

pub fn shared_child(&self, index: usize) -> Option<&TreeNode>

Retrieves a shared reference to a given child.

Source

pub fn mut_child(&mut self, index: usize) -> Option<&mut TreeNode>

Retrieves a shared reference to a given child.

Source

pub fn shared_sibling_data(&self, sibling_index: usize) -> Option<&TreeNodeType>

Retrieves the node data of a sibling of the currently focused-on node with the given index.

Source

pub fn index_in_parent(&self) -> Option<usize>

Retrieves the index of the current node with respect to its parent.

Source

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.

Source

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.

Source

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.

Source

pub fn current_node_id(&self) -> NodeId

Retrieves a copy of the node id currently focused on.

Source

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.

Source

pub fn n_of_symbolic_footnotes(&self) -> u32

Returns the number of symbolic footnotes that have been entered into the doctree.

Source

pub fn n_of_symbolic_footnote_refs(&self) -> u32

Returns the number of symbolic footnote references that have been entered into the doctree.

Source

pub fn increment_symbolic_footnotes(&mut self)

Increments symbolic footnote counter of the doctree by 1.

Source

pub fn increment_symbolic_footnote_refs(&mut self)

Increments symbolic footnote reference counter of the doctree by 1.

Source

pub fn increment_anon_targets(&mut self)

Increases the counter for anonymous targets entered into the doctree thus far by one.

Source

pub fn increment_anon_references(&mut self)

Increases the counter for anonymous targets entered into the doctree thus far by one.

Source

pub fn next_anon_target_n(&mut self) -> u32

Increments the anon target counter and returns a copy of the result.

Source

pub fn next_anon_reference_n(&mut self) -> u32

Increments the anon reference counter and returns a copy of the result.

Source

pub fn next_anon_target_label(&mut self) -> String

Returns an allocated String representation of the next anonymous target label.

Source

pub fn next_anon_reference_label(&mut self) -> String

Returns an allocated String representation of the next anonymous reference label.

Source

pub fn shared_targets(&self) -> &HashMap<String, NodeId>

Returns a shared reference to self.targets.

Source

pub fn mut_targets(&mut self) -> &mut HashMap<String, NodeId>

Returns a mutable reference to self.targets.

Source

pub fn shared_references(&self) -> &HashMap<String, Vec<NodeId>>

Returns a shared reference to self.references.

Source

pub fn mut_references(&mut self) -> &mut HashMap<String, Vec<NodeId>>

Returns a mutable reference to self.references.

Source

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.

Source

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.

Source

pub fn walk_to_parent_section_level(self, level: usize) -> Self

Walks up the tree to a given section level.

Source

pub fn shared_parent_ref(&self) -> Option<&TreeZipper>

Returns an Optional shared reference to the parent node.

Source

pub fn shared_data(&self) -> &TreeNodeType

Returns a shared reference to the data of the current node.

Source

pub fn shared_parent_data(&self) -> Option<&TreeNodeType>

Returns an Optional shared reference to parent node data.

Source

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.

Source

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.

Source

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.

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.