Skip to main content

Document

Struct Document 

Source
#[non_exhaustive]
pub struct Document<'a> { pub header: Option<Header<'a>>, pub attributes: DocumentAttributes<'a>, pub blocks: Vec<Block<'a>>, pub footnotes: Vec<Footnote<'a>>, pub toc_entries: Vec<TocEntry<'a>>, pub references: HashMap<&'a str, Reference<'a>>, pub location: Location, }
Expand description

A Document represents the root of an AsciiDoc document.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§header: Option<Header<'a>>§attributes: DocumentAttributes<'a>

Effective end-of-header values. Later accepted changes are ordered Block::DocumentAttribute nodes and do not update this snapshot.

§blocks: Vec<Block<'a>>§footnotes: Vec<Footnote<'a>>§toc_entries: Vec<TocEntry<'a>>§references: HashMap<&'a str, Reference<'a>>

Cross-reference targets keyed by id, for O(1) <<id>> resolution. Covers sections, blocks, explicit inline anchors, and IDs on formatted inline spans; collected during parsing. toc_entries remains the ordered list used to render the table of contents. An empty key supplies the document title or label when a reference addresses the document top. Like toc_entries and footnotes, this is not serialized.

§location: Location

Implementations§

Source§

impl Document<'_>

Source

pub fn renumber_sections(&mut self)

Reassign section numbers from the current section tree.

Parsing does this automatically. Call it after changing the section tree or a section’s numbering policy. Existing cross-reference targets and table-of-contents entries receive the new numbers, but this method does not add, remove, or reorder those entries.

Automatic cross-references select the signifier for the target’s current category from their original source-position attributes. Explicit CrossReference::set_signifier overrides are preserved.

Source

pub fn renumber_captions(&mut self)

Reassign every automatic caption ordinal, numbering a block’s content before the block itself as asciidoctor does.

Parsing does this already. Call it after reordering or removing blocks, changing titles, or inserting a block whose metadata.caption has been set. A caller-built block whose metadata.caption is None stays unnumbered: nothing knows the document attributes at a source position it never had, so a converter’s own fallback owns it.

Source

pub fn highest_caption_number(&self, kind: CaptionKind) -> u32

The highest caption ordinal assigned to any block of kind, or 0 when none carries one.

A converter that renders a title the parser never numbered — one on a caller-built block, or added after parsing — should start its own counter here, so its numbers cannot collide with the parser’s.

Trait Implementations§

Source§

impl<'a> Debug for Document<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for Document<'a>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a> PartialEq for Document<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Document<'_>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> StructuralPartialEq for Document<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Document<'a>

§

impl<'a> RefUnwindSafe for Document<'a>

§

impl<'a> Send for Document<'a>

§

impl<'a> Sync for Document<'a>

§

impl<'a> Unpin for Document<'a>

§

impl<'a> UnsafeUnpin for Document<'a>

§

impl<'a> UnwindSafe for Document<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more