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 supplied when the processing context was bootstrapped. In normal file-list processing this is TopMark's canonical processing path, not necessarily the original CLI/config spelling. Lower-level callers may still pass a symlink spelling directly; the builder canonicalizes filesystem metadata again.- For regular filesystem input,
file,file_relpath, andfile_abspathare derived from the canonical filesystem spelling of the resolved processing target. Symlink spelling is not preserved in generated header metadata. This keeps repeated runs idempotent when a symlink and its target are both selected, and avoids casing-only metadata drift on case-insensitive filesystems. - In stdin mode,
file,file_relpath, andfile_abspathare derived from the logicalstdin_filename, not the materialized temporary file path. file_relpathandrelpathare computed by callingcompute_relpath(header_path, relative_to)and serialized withformat_header_metadata_path().relative_todefaults toPath.cwd()when no explicit root is configured. IfFrozenConfig.relative_tois set and exists on disk, it is canonicalized before relative paths are computed.relpathbecomes "." at repo root.
Header metadata path fields are serialized with POSIX separators on all
platforms. 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). User-supplied path spelling is not treated as header metadata once a
regular filesystem path has been successfully resolved.
Source code in src/topmark/pipeline/steps/builder.py
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 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | |
hint ¶
Attach generation hints (non-binding).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ctx
|
ProcessingContext
|
The processing context. |
required |