livery.workshop._fragments¶
livery.workshop._fragments ¶
The configuration a step owns, composed into the files the render writes.
A step record carries one fragment per rendered file it has
something to say in: its tables in pyproject.toml, its lines in
.vscode/settings.json, its .clang-tidy in each C or C++ package.
The render composes the base template with the registered fragments
in step-name order, so two machines write the same bytes, and the
drift gate judges the result. A fragment is jinja text rendered with
the same data the template reads. A project file's fragment applies
once per workspace, with per-package variation spelled inside it the
tool's own way; a package file's fragment applies in each package
whose set holds one of the extensions it names, the first step by
name winning when two have one. A fragment leaves the render
with its record: unregistering the step removes the section from the
next render, and a per-package file it wrote alone goes when its
bytes are the bytes the render last wrote.
Classes:
| Name | Description |
|---|---|
Fragment |
One step's configuration for one rendered file. |
Functions:
| Name | Description |
|---|---|
verify |
Refuse a fragment naming a file the render does not write. |
compose_project |
Each project file's composed fragments, by file, in step-name order. |
package_files |
The per-package files the registered steps' fragments render, sorted. |
package_fragment |
The fragment text a package holding extensions renders as file, and its step. |
compose_package |
file rendered for a package holding extensions; None when no step owns it. |
Attributes:
| Name | Type | Description |
|---|---|---|
PROJECT_FILES |
|
PROJECT_FILES
module-attribute
¶
Fragment
dataclass
¶
One step's configuration for one rendered file.
Attributes:
| Name | Type | Description |
|---|---|---|
file |
str
|
The rendered file, a project file relative to the root or a per-package file name. |
text |
str
|
The fragment's jinja text, rendered with the file's own render data. |
extensions |
tuple[str, ...]
|
For a per-package file, the extensions whose packages render it; empty for a project file. |
verify ¶
Refuse a fragment naming a file the render does not write.
Raises:
| Type | Description |
|---|---|
ValueError
|
naming the step, the file, and the files a fragment may address. |
Source code in packages/workshop/src/livery/workshop/_fragments.py
compose_project ¶
Each project file's composed fragments, by file, in step-name order.
A file no step has a fragment for maps to the empty string, so a
template's {{ fragments['...'] }} always resolves.
Source code in packages/workshop/src/livery/workshop/_fragments.py
package_files ¶
The per-package files the registered steps' fragments render, sorted.
A fragment that names extensions is rendered in each package whose set holds one, so the files a C or C++ package carries are the registered steps' to say, and leave with them.
Source code in packages/workshop/src/livery/workshop/_fragments.py
package_fragment ¶
The fragment text a package holding extensions renders as file, and its step.
The first step by name whose fragment names one of extensions wins; None when no step has one, which is what a withdrawn step looks like to the apply.
Source code in packages/workshop/src/livery/workshop/_fragments.py
compose_package ¶
file rendered for a package holding extensions; None when no step owns it.