Extract source annotation into its own modules - #62
Merged
Conversation
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.
gokulkrishna98
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.