topmark.processors.builtins.cblock¶
topmark / processors / builtins / cblock
Header processor for C-like block comments: / ... / with per-line *.
This is ideal for CSS and friends (SCSS, Less, Stylus), and works for any format that accepts C-style block comments (SQL, Solidity, etc.).
Layout example:
/ * topmark:start * * project : TopMark * file : styles.css * ... * * topmark:end /
We emit the wrapper lines '/' and '/' and render inner lines as '* ...'.
CBlockHeaderProcessor ¶
Bases: BlockCommentMixin, HeaderProcessor
Processor for C-style block comment headers (uses BlockCommentMixin).
Source code in src/topmark/processors/builtins/cblock.py
line_has_directive ¶
Check whether a line contains the directive with the expected affixes.
This method is used by get_header_bounds() to locate header start/end markers.
Subclasses may override this method for more flexible or format-specific matching.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
str
|
The line of text to check (whitespace is trimmed internally). |
required |
directive
|
str
|
The directive string to look for. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
otherwise |
Source code in src/topmark/processors/builtins/cblock.py
prepare_header_for_insertion ¶
prepare_header_for_insertion(
*,
original_lines,
insert_index,
rendered_header_lines,
newline_style,
)
Ensure sensible padding around the header.
- At top-of-file: no leading blank; ensure >=1 trailing blank unless next line is blank/EOF.
- After preceding content: ensure exactly one leading blank; ensure >=1 trailing blank.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original_lines
|
list[str]
|
The original file lines. |
required |
insert_index
|
int
|
Line index at which the header will be inserted. |
required |
rendered_header_lines
|
list[str]
|
The header lines to insert. |
required |
newline_style
|
str
|
Newline style ( |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Possibly modified header lines to insert at |