Skip to main content

Module include

Module include 

Source
Expand description

The include module handles generated content (format specification §9). It finds the regions of a file, chooses the length and language tag of the code fence around each file-form include, builds the include graph, and works out the expected content of every generated block.

Structs§

DefinitionEntry
A DefinitionEntry is one line of a definition block.
Expected
An Expected holds what every generated block should hold.
Extraction
An Extraction is the text that extract returns, with the line of the file, counted from 1, of each of its lines.
Fenced
A Fenced is the source of an include block that holds a file, whole or one region of it, in a fence.

Enums§

RegionError
A RegionError reports a region marker that breaks the pairing of begin and end markers (SOKF_FORMAT_95, SOKF_FORMAT_112), and gives the name of the region and the number of the line.

Functions§

definition_pair
definition_pair returns the pair of the definition block of the file at path, which sokf would write as rendered and which holds written, both read as a part of a Markdown file under the file’s path, or its path with .md added where same-same doesn’t read its name as Markdown, such as an additional file /README (CLI-4_AC-112, CLI-4_AC-113).
expected
expected computes the expected content of every generated block.
expected_for
expected_for computes the expected content of the generated blocks of the files in only, or of every file when only is None. It expands the include targets of those files too. It reads the body of a summarised document from the disk when a file that depends on it needs the body (CACHE-3_AC-1).
extract
extract returns the lines of region in text, or of the whole file when region is None, with every marker line stripped. It returns Ok(None) when no region has that name. It joins regions that share a name in file order.
extract_lines
extract_lines returns what extract returns, with the line of the file of each line of the text.
includes_body
includes_body says whether an id-form include of target with fragment materialises the document’s body (SOKF_FORMAT_85, FORMAT-2_AC-5). An include with an empty fragment includes the body of any document, an include with no fragment includes the body of a document that isn’t an asset’s sidecar, and an include with a named fragment never includes the body.
index_pair
index_pair returns the pair of the index at path, which sokf would write as expected and which holds actual, both read as a whole Markdown file under the index’s path (CLI-4_AC-113).
knowledge_of_additional
knowledge_of_additional returns the knowledge in which the includes of an additional file resolve: the knowledge of its schema, or else the knowledge that holds the file.
labels_as_written
labels_as_written returns whether the definition block written holds the labels of entries as sokf writes them, in their order. Markdown matches a label whatever its case, so same-same reads a label written in another case as the same, which no formatter writes, and sokf compares the labels itself (CLI-4_AC-112).
pairs
pairs returns the pairs of the files in units, or of every file when units is None, and of each index in indexes. A block that holds its expected text gives no pair, so a pass whose blocks are current needs no comparison (CLI-4_AC-44).
path_link_label
path_link_label returns the canonical label of a path link in path, when the link points to a document or an asset of any store. When the fragment is the text of a key, the label uses the key’s slug instead. It also returns whether --fix writes the label. --fix writes the label of an inline link when the label resolves (SOKF_VALIDATION_24). It returns None for a link to any other file, for a link that ends with /, which names only a directory (SOKF_FORMAT_157), and for an image link whose target is not an asset.
render_definitions
render_definitions returns the text of the definition block for entries, or an empty string when there are no entries.