Documents as modules¶
documents
¶
Documents compiled as modules: the units of the documentation gate.
Every Markdown document of the documentation is checked by compiling the
modules it contains, as document_units reads them from its fenced blocks
(scan_blocks):
- the document's cumulative blocks (unmarked ones in a literate
.qvr.mdmodule, and those markedcumulativeorqiec-cumulative) form one module, its tangle; - each block marked
standaloneorqiec, and each unmarked block of an ordinary document, is a module of its own; - a block that includes a corpus file compiles that file, its imports found as that file's own package finds them;
- the blocks marked
file PATHare the files of one package, written to their paths below a fresh root and each checked as a module of that package, the wayqvr checkchecks a file; - a block marked
refused "TEXT"is a module that must be refused, with a diagnostic whose message containsTEXT; compile: falsefragments and example fences are not modules (an example is a test of the document's module, run byqvr test).
A unit's source keeps every block line on its document line and blanks
every other line, so a diagnostic names the document's own line. A unit
compiles through the module system, with the document's directory as the
root its imports are found below; a unit holding a qiec block also has
its flat program lowered through the exact QVR to QIEC route.
UnitRoute
¶
How a unit is compiled: as a module through the categorical compiler, lowered through the exact QVR to QIEC route, as the files of a package, or as a module the compiler must refuse.
PackageFile
didactic-model
¶
Bases: Model
One file of a document's package.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
Its path below the package root, such as
TYPE:
|
source
|
Its source, with its block's lines on their document lines.
TYPE:
|
DocumentUnit
didactic-model
¶
DocumentUnit(*, document: str, line: int, blocks: tuple[int, ...], routes: tuple[UnitRoute, ...], source: str, include: str = '', files: tuple[PackageFile, ...] = (), refusal: str = '')
Bases: Model
One module a document contains.
| PARAMETER | DESCRIPTION |
|---|---|
document
|
The document's path.
TYPE:
|
line
|
The fence line of the unit's first block.
TYPE:
|
blocks
|
The fence lines of every block the unit compiles.
TYPE:
|
routes
|
How the unit is compiled; each route is checked.
TYPE:
|
source
|
The unit's QVR source.
TYPE:
|
include
|
The corpus file an include block compiles, or empty.
TYPE:
|
files
|
The files of a package unit, or empty.
TYPE:
|
refusal
|
The text the diagnostic of a refused unit contains, or empty.
TYPE:
|
label
property
¶
The unit's name in diagnostics.
| RETURNS | DESCRIPTION |
|---|---|
str
|
|
DocumentError
¶
Bases: ValueError
A unit of a document that does not compile, located at its document.
document_units
¶
document_units(path: str | Path, text: str | None = None) -> tuple[DocumentUnit, ...]
The modules a document contains.
| PARAMETER | DESCRIPTION |
|---|---|
path
|
The document; a name ending in
TYPE:
|
text
|
Its text; read from
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
tuple[DocumentUnit, ...]
|
Its cumulative module first (when it has cumulative blocks), then its package (when it has file blocks), then its other units in document order. |
| RAISES | DESCRIPTION |
|---|---|
OSError
|
If the document or an included file cannot be read. |
ValueError
|
If two file blocks name one path. |
Source code in src/quivers/literate/documents.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
compile_unit
¶
compile_unit(unit: DocumentUnit) -> None
Compile one unit of a document along each of its routes.
| PARAMETER | DESCRIPTION |
|---|---|
unit
|
The unit.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
DocumentError
|
If the unit does not parse, resolve, or compile on a route; the message names the document and the unit's first block, and the underlying error (which names the document's line) is its cause. |