Skip to main content

Module model

Module model 

Source
Expand description

The document model: the types that describe what a document is made of, how its parts are identified, and the option values set on it.

This module defines the data a document is described in, and nothing about how a document is processed. Its main concepts are these:

  • A document (Doc) is a set of trees of parsed nodes, built from one or more fragments (Fragment), each fragment being one piece of source as the parser delivered it.
  • Every node carries an element (ElementSpec), the value that says what the node means.
  • An element carries aspects: pieces of behavior attached to the element when a feature registers it, which the rest of the library reads back through trait objects (see elements and aspects).
  • Every node of a document has an address (NodeAddr), the key under which computed data about the node is stored.
  • Every entity registered with the library (a stage, a table, a capability, a feature, …) is identified by a dotted name (Name). An element has a dotted type name too, but it is identified by its element value, the allocation of its ElementSpec.
  • A document also carries the option values set on it when it was built (OptionValues).

See the document tree for an introduction, and the document model guide for the whole picture.

The library processes a document with the types of crate::core: stages, the registry, plans, runs and the store of computed data. This module uses none of them.

§The modules

  • names — dotted names, and one Rust type per kind of name (ElementName, CapName, …).
  • addr — TreeId and NodeAddr, the identifiers of a tree and of a node, under which computed data is stored per node.
  • element — ElementSpec, the AspectMap holding an element’s aspects, and the rule that two elements are the same when they are the same allocation.
  • aspects — the aspects that the standard features implement and read: block roles, reference points, reference sites, headings, content outside the surrounding text, what replaces a node in a copy of content, and whether a node is whitespace.
  • doc — fragments, a document’s content (its tree arena, traversal list and resolution map), the document itself, and the walk that defines document order.
  • assemble — assemble, which parses a document’s primary file together with the files it includes with \input into a document’s content.
  • options — option types, the values set for them on a document or on a render request, and how a stage reads them.
  • digest — Fnv1a64, the deterministic hasher behind every digest this crate computes, and digest_of.

§Position in the crate’s layers

The crate documentation orders the crate’s modules in layers, each using only the layers below it. This module and crate::lang form the bottom layer together:

{model, lang} < core < dump < stdlib < math_passthrough        layout standalone

The two modules share one layer because each one uses the other: a parsed node carries its element, so the language uses the model, and a fragment holds a tree typed by the language, so the model uses the language. Together they use nothing else of this crate.

Modules§

addr
The identifiers of a tree and of a node: TreeId and NodeAddr, the keys under which computed data is stored per node.
aspects
The aspects that the standard features implement and read: block roles, reference points, reference sites, headings, content outside the surrounding text, what replaces a node in a copy of content, and whether a node is whitespace.
assemble
Assembling the content of a document from its primary file and the files it includes with \input.
digest
The deterministic hasher behind every digest this crate computes (Fnv1a64), and digest_of, which digests any hashable value with it.
doc
Documents and fragments: the parsed source a document is made of, how its trees are placed, and the walk that defines document order.
element
Elements, which say what the nodes of a document mean, and the aspect map through which the rest of the library reads an element’s behavior.
names
Dotted names, which identify every entity registered with the library, and one Rust type per kind of name.
options
Option types: the typed values a feature lets a caller set on a document or on a render request, and how a stage reads them.