Skip to content

Extract source annotation into its own modules - #62

Merged
cymbalrush merged 1 commit into
apple:mainfrom
cymbalrush:refactor/annotation-rendering
Aug 18, 2026
Merged

Extract source annotation into its own modules#62
cymbalrush merged 1 commit into
apple:mainfrom
cymbalrush:refactor/annotation-rendering

Conversation

@cymbalrush

Copy link
Copy Markdown
Contributor

Annotating a program means answering, per operation, "which source line is this, and what do I want to say about it". That splits into concerns worth owning separately: walking every operation including composite bodies, rendering a value as a table or a comment line, and placing a rendered annotation against a source line.

Each becomes its own module -- utils and annotations, alongside the existing table_writer -- with source_annotator composing them into a listing of a Python file carrying per-operation information.

Styling is expressed as rich style names rather than ANSI escapes, so colour is applied for a terminal and dropped for a file or in-memory stream. Writing the escapes unconditionally put them in the text of every saved listing, which a terminal renders and an editor shows as noise. No escape codes are written by hand anywhere in the package now, and an annotation is indented to match the line it describes rather than breaking at column zero.

Annotating a program means answering, per operation, "which source line is
this, and what do I want to say about it". That splits into concerns worth
owning separately: walking every operation including composite bodies,
rendering a value as a table or a comment line, and placing a rendered
annotation against a source line.

Each becomes its own module -- utils and annotations, alongside the existing
table_writer -- with source_annotator composing them into a listing of a
Python file carrying per-operation information.

Styling is expressed as rich style names rather than ANSI escapes, so colour
is applied for a terminal and dropped for a file or in-memory stream. Writing
the escapes unconditionally put them in the text of every saved listing, which
a terminal renders and an editor shows as noise. No escape codes are written
by hand anywhere in the package now, and an annotation is indented to match
the line it describes rather than breaking at column zero.

Two further consequences. The benchmarker had grown its own copies of the
location helpers, since there was nowhere shared to put them; it now imports
them, leaving one definition of each. And a debug info record can render
itself as a table, one row per operation and one column per metadata key,
with op_id split per dialect level so ids can be compared down a column.
@cymbalrush
cymbalrush merged commit 288722e into apple:main Aug 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants