build_output.OutputBuilder
convert.build_output.OutputBuilder(
python_blocks,
*,
lint_non_exec,
yaml_eval_default,
preserve_line_count,
spacing_rules,
)Base class for building Python output from parsed document metadata.
Contains methods shared by LintOutputBuilder and FormatOutputBuilder.
Attributes
| Name | Type | Description |
|---|---|---|
| python_blocks | list[dict] | Metadata for Python code blocks. |
| lint_non_exec | bool | Whether to lint non-executed chunks. |
| yaml_eval_default | bool | Document-level default for execute.eval. |
| preserve_line_count | bool | Whether to preserve source line count in the output. |
| spacing_rules | bool | Whether to add noqa spacing suppressions for lint output. |
| py_lines | list[str] | Output buffer to populate. |
Methods
| Name | Description |
|---|---|
| handle_annotations | Remove in-line quarto code annotations (and any whitespace prior). |
| handle_includes | Comment line if it contains Quarto include syntax. |
| should_process_block | Determine whether a given Python block should be processed. |
handle_annotations
convert.build_output.OutputBuilder.handle_annotations(line)Remove in-line quarto code annotations (and any whitespace prior).
These include: - #<< used by shafayetShafee’s line-highlight extension. - # <n> used by Quarto code annotations (e.g., # <1>).
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| line | str | The line to process. | required |
Returns
| Name | Type | Description |
|---|---|---|
| str | The line with trailing whitespace and any “#<<” at the end removed. |
handle_includes
convert.build_output.OutputBuilder.handle_includes(line)Comment line if it contains Quarto include syntax.
Include syntax is: {{< include ... >}}.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| line | str | The line to process. | required |
Returns
| Name | Type | Description |
|---|---|---|
| str | The input line, but commented if it had quarto include syntax. |
should_process_block
convert.build_output.OutputBuilder.should_process_block(block)Determine whether a given Python block should be processed.
This combines global settings (lint_non_exec), the block’s active/inactive status, any chunk-level eval options, and the default YAML execute.eval value.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| block | dict | Metadata dictionary describing a Python code block. | required |
Returns
| Name | Type | Description |
|---|---|---|
| bool | True if the block should be included in linting, False otherwise. |