Skip to main content

Module dependencies

Module dependencies 

Source
Expand description

env.dependencies[docname] — the files a document is built from besides its own source, and the reason a build re-reads a document whose source never changed.

Port of the note_dependency half of Sphinx’s asset collectors (environment/collectors/asset.py:26-104, ImageCollector.process_doc) plus the path arithmetic it relies on, BuildEnvironment.relfn2path (environment/__init__.py:378-400). crate::env::BuildEnvironment::get_outdated_files is the consumer: a dependency that is missing, or newer than the time the document was read, makes the document outdated.

Scope. Sphinx notes a dependency for every file-inserting construct: images, figure, literalinclude, include, download, docutils.conf and the gettext catalogs. This crate covers images (figure builds one) by walking the doctree here, and — since wave 4.5 — include, whose targets arrive as parse-time records (crate::rst::RegistryExport::dependencies, the counterpart of docutils’ settings.record_dependencies harvested by sphinx’s DependenciesCollector). The remaining producers are a matter of calling note or extending the record stream from wherever their nodes are collected.

Deliberate omissions, each of which only costs a warning, never a wrong rebuild decision:

  • image file not readable: %s — Sphinx stats the image at read time and warns; here a missing image simply makes the document outdated on every build (the honest consequence of “a dependency is missing”), and nothing is said about it.
  • candidates — Sphinx expands foo.* into per-mimetype candidates and notes each. Nothing in this crate resolves candidates, so a * uri is noted as no dependency at all rather than as one file that does not exist and would peg the document to a re-read forever.

Functions§

note
env.note_dependency(filename): the absolute path a uri seen in docname refers to, or None when the uri names no local file.
process_doc
Record every file docname’s doctree pulls in, replacing whatever the previous read of that document left behind.