topmark.pipeline.steps.builder¶
topmark / pipeline / steps / builder
Builder step for TopMark pipeline.
This step computes the field dictionaries that will later be rendered into a
TopMark header. It derives built-in fields from the filesystem (e.g., file,
file_relpath) and merges them with
FrozenConfig.field_values, then selects only
those keys listed in FrozenConfig.header_fields.
Outputs
ctx.views.build.builtins: the derived built-in field mapping.ctx.views.build.selected: the filtered/merged mapping to be rendered by the renderer.ctx.status.generation: set toGENERATED(orNO_FIELDSwhen no fields are configured).
Notes
This step does not render text. The renderer consumes ctx.views.build.selected
and produces the final lines/block in ctx.views.render.
BuilderStep ¶
Bases: BaseStep
Compute field dictionaries for rendering a TopMark header.
Derives built-in fields from the filesystem, merges with configured values,
and selects only configured header fields. Produces a BuilderView.
Axes written
- generation
Sets
- GenerationStatus: {PENDING, GENERATED, NO_FIELDS}
Source code in src/topmark/pipeline/steps/builder.py
may_proceed ¶
Determine if processing can proceed to the build step.
Return whether the builder has the prerequisites to compute field values.
The builder should run whenever content is available, even for empty-like
images. Empty-file insertion policy is a mutation concern and is handled
later by planner/updater logic via
allow_insert_into_empty_like(),
not by may_proceed().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
ProcessingContext
|
The processing context for the current file. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the builder can compute header field values for this context. |
Source code in src/topmark/pipeline/steps/builder.py
run ¶
Build the field dictionaries used to render a TopMark header.
This step analyzes the processing context and configuration to compute: * derived built-in fields based on the file path; and * the final field mapping to be rendered (subset/overrides as per config).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
ProcessingContext
|
The current processing context containing file info, configuration, and status. |
required |
Mutations
ctx.views.build.builtins: built-in field mapping.ctx.views.build.selected: selected/merged field mapping.ctx.status.generation: updated toGENERATEDorNO_FIELDS.
Notes
Diagnostic messages are added if unknown header fields are referenced in
FrozenConfig.header_fields or when built-ins are overridden by
FrozenConfig.field_values.
Path semantics
file_pathisctx.pathas provided by config resolution. It may be relative or absolute depending on how the file was discovered.file_abspathis computed from the logical header path and is therefore an absolute, normalized path. In stdin mode this means it reflects the logicalstdin_filename, not the materialized temporary file path.file_relpathandrelpathare computed by callingcompute_relpath(file_path, relative_to). Note that this uses the originalfile_path(notfile_path.resolve()), so the relative path is derived from the discovery spelling.relative_todefaults toPath.cwd()when no explicit root is configured. IfFrozenConfig.relative_tois set, it is resolved to an absolute path viaPath(config.relative_to).resolve().relpathbecomes "." at repo root.
This behavior intentionally keeps file_relpath stable for common cases
like running TopMark from the repository root (so pyproject.toml yields
file_relpath = "pyproject.toml"). If you need file_relpath computed
relative to a specific root, set FrozenConfig.relative_to (via config or CLI/API
overrides).
Source code in src/topmark/pipeline/steps/builder.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 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 | |
hint ¶
Attach generation hints (non-binding).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
ProcessingContext
|
The processing context. |
required |