Skip to main content

BuildEnvironment

Struct BuildEnvironment 

Source
pub struct BuildEnvironment {
Show 20 fields pub version: u32, pub root_doc: String, pub all_docs: BTreeMap<String, u64>, pub dependencies: BTreeMap<String, BTreeSet<PathBuf>>, pub included: BTreeMap<String, BTreeSet<String>>, pub reread_always: BTreeSet<String>, pub metadata: BTreeMap<String, BTreeMap<String, String>>, pub titles: BTreeMap<String, Node>, pub longtitles: BTreeMap<String, Node>, pub tocs: BTreeMap<String, Node>, pub toc_num_entries: BTreeMap<String, u32>, pub toc_secnumbers: BTreeMap<String, BTreeMap<String, Vec<u32>>>, pub toc_fignumbers: BTreeMap<String, BTreeMap<String, BTreeMap<String, Vec<u32>>>>, pub toctree_includes: BTreeMap<String, Vec<String>>, pub files_to_rebuild: BTreeMap<String, BTreeSet<String>>, pub glob_toctrees: BTreeSet<String>, pub numbered_toctrees: BTreeSet<String>, pub std: StdDomainData, pub py: PyDomainData, pub index_entries: BTreeMap<String, Vec<IndexEntryRecord>>,
}
Expand description

Persistent build-state record: the subset of Sphinx’s BuildEnvironment attributes this wave’s read-and-resolve phase populates. See the module doc comment for the persistence protocol.

Fields§

§version: u32

Format version of this serialized record. BuildEnvironment::save always stamps ENV_VERSION here; BuildEnvironment::load discards (returns None for) anything else.

§root_doc: String

Sphinx’s config.root_doc: the document every whole-project walk of the toctree graph starts from (toctree::collect_relations) and the one document toctree::check_consistency never calls an orphan. Empty in a BuildEnvironment::default; the build stamps it from the configuration.

§all_docs: BTreeMap<String, u64>

docname -> read time, in microseconds since the Unix epoch.

§dependencies: BTreeMap<String, BTreeSet<PathBuf>>

docname -> absolute paths the document depends on (via include, literalinclude, etc.).

§included: BTreeMap<String, BTreeSet<String>>

docname -> docnames it textually includes (docutils include).

§reread_always: BTreeSet<String>

docnames that must always be re-read (e.g. they use today/now).

§metadata: BTreeMap<String, BTreeMap<String, String>>

docname -> its bibliographic field list (:orphan:, :tocdepth:, …), per metadata::document_metadata.

§titles: BTreeMap<String, Node>§longtitles: BTreeMap<String, Node>§tocs: BTreeMap<String, Node>

docname -> that document’s local table of contents, doctree-shaped (a bullet_list node, mirroring Sphinx’s env.tocs).

§toc_num_entries: BTreeMap<String, u32>§toc_secnumbers: BTreeMap<String, BTreeMap<String, Vec<u32>>>

docname -> (anchorname -> section-number tuple). anchorname is '' for a document’s own top entry, else '#<id>'.

§toc_fignumbers: BTreeMap<String, BTreeMap<String, BTreeMap<String, Vec<u32>>>>

docname -> (figtype -> (figure id -> figure-number tuple)).

§toctree_includes: BTreeMap<String, Vec<String>>

docname -> docnames its toctree(s) directly include.

§files_to_rebuild: BTreeMap<String, BTreeSet<String>>

included-docname -> docnames whose toctree includes it (the reverse of toctree_includes; used to know what to rebuild when a doc changes).

§glob_toctrees: BTreeSet<String>§numbered_toctrees: BTreeSet<String>§std: StdDomainData§py: PyDomainData

The python domain’s registries (domaindata['py']), insertion- ordered — see PyDomainData for why the order is data.

§index_entries: BTreeMap<String, Vec<IndexEntryRecord>>

docname -> its .. index:: entries, in document order.

Implementations§

Source§

impl BuildEnvironment

Source

pub fn load(cache_dir: &Path) -> Option<Self>

Load a previously saved environment from <cache_dir>/env.bin.

Returns None if the file is missing, fails to decode, or was written by a different ENV_VERSION — in every case the caller’s correct fallback is a fresh BuildEnvironment::default, exactly like Sphinx discarding an incompatible environment.pickle.

Source

pub fn save(&mut self, cache_dir: &Path) -> Result<()>

Save this environment to <cache_dir>/env.bin, creating cache_dir if needed. Always stamps ENV_VERSION into the persisted bytes (regardless of self.version’s current in-memory value), so callers never need to remember to set it before saving.

The in-memory version is only updated once the write has actually succeeded: a failed save must not leave the caller holding an environment that claims to have been written at the current version.

Source

pub fn get_outdated_files( &self, found: &BTreeSet<String>, config_changed: bool, times: &FileTimes<'_>, ) -> Outdated

Split found — the documents the project currently has — into what this build must read, and what it must forget.

Port of BuildEnvironment.get_outdated_files (environment/__init__.py:521-554) together with the two steps Builder.read wraps around it (builders/__init__.py:477-491): a changed configuration re-reads everything, and adding or removing any file re-reads every document with a globbed toctree, whose entry list depends on which files exist rather than on its own text.

Sphinx’s env-get-outdated event — an extension’s chance to add its own outdated documents — has no counterpart here; there are no extensions with read-phase state yet.

Source

pub fn clear_doc(&mut self, docname: &str)

Remove every trace of docname from the environment — the Rust mirror of Sphinx’s BuildEnvironment.clear_doc plus every EnvironmentCollector.clear_doc/Domain.clear_doc that fires alongside it via the env-purge-doc event (Sphinx dispatches these separately; here they’re one method since there’s no event bus). See environment/__init__.py:412 (base), environment/collectors/ toctree.py:30 (toctree fields + files_to_rebuild), environment/collectors/title.py:23 (titles/longtitles), environment/collectors/dependencies.py:24 (dependencies), environment/collectors/metadata.py:22 (metadata), domains/std/__init__.py:896 (std domain), domains/index.py:41 (index entries).

Source

pub fn snapshot(&self) -> JsonValue

A deterministic JSON view of this environment, shaped to line up with the env_differential oracle fixture (tests/env_differential.rs, tests/fixtures/env_differential.json) so later tasks can diff straight against it. std.objects/std.progoptions use tuple keys, which serde_json cannot serialize as map keys directly, so those (and index_entries, whose main: bool must become the oracle’s literal "main"/"" string) are hand-converted into the fixture’s list/tuple shapes rather than derived via a blanket to_value(self).

Trait Implementations§

Source§

impl Clone for BuildEnvironment

Source§

fn clone(&self) -> BuildEnvironment

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BuildEnvironment

Source§

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

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

impl Default for BuildEnvironment

Source§

fn default() -> BuildEnvironment

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

impl<'de> Deserialize<'de> for BuildEnvironment

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for BuildEnvironment

Source§

fn eq(&self, other: &BuildEnvironment) -> 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 BuildEnvironment

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 StructuralPartialEq for BuildEnvironment

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.