Skip to main content

Module metadata

Module metadata 

Source
Expand description

env.metadata[docname] — the document’s bibliographic field list, read as build metadata.

Port of MetadataCollector.process_doc (sphinx/environment/collectors/metadata.py:34). Sphinx reads a docinfo node, which docutils’ DocInfo transform (docutils/transforms/frontmatter.py) builds from a leading field list; this crate has no such transform yet, so the port reads that leading field_list directly. The two agree on what a field contributes — field_name.astext() -> field_body.astext() — which is all the consumers need (orphan, nocomments, tocdepth).

Deliberate omissions:

  • Sphinx pops the docinfo node out of the doctree; this leaves the field_list in place, because removing it is a doctree-shape change that belongs with the DocInfo transform itself.
  • The bibliographic special cases (authors, and the tocdepth int-coercion) are not applied: nothing reads them yet.

Known gap — a field list below a promoted document title is not seen. docutils runs DocTitle before DocInfo, so in a single-section document the section title is promoted to a document title and the field list that follows it still becomes docinfo. This crate applies no transforms at parse time (crate::rst, module header: “Transforms (doctitle promotion, …) are explicitly NOT applied here”), so such a document keeps its section wrapper and the field list never sits at document level for this port to find. Consequence: a document whose :orphan: marker follows its title is not exempted from the document isn't included in any toctree warning. title/subtitle are already in [is_pre_bibliographic], so this closes by itself the moment doctitle promotion lands — nothing here needs to change.

Functions§

document_metadata
The document’s metadata: field name -> field body text, empty when the document does not open with a field list.