Skip to content

docs: add annotated-code-block functionality to RST examples#384

Open
jsstevenson wants to merge 2 commits intov1from
code-comment-annotations
Open

docs: add annotated-code-block functionality to RST examples#384
jsstevenson wants to merge 2 commits intov1from
code-comment-annotations

Conversation

@jsstevenson
Copy link
Contributor

@jsstevenson jsstevenson commented Dec 31, 2025

I find the "examples" pages pretty hard to read. Each annotation is one long line, and you have to scroll well outside of the viewport to read an invididual note. I guess you could just go click the link to read the source YAML directly, but you lose the benefits of syntax highlighting (and you're still reading single, long lines -- text wrap was invented for a reason!)

Screenshot 2026-02-04 at 4 45 46 PM

There's a material-mkdocs plugin that adds little annotation tooltips which make this information more digestible, but there's no such equivalent for Sphinx as far as I can tell. So, I had ChatGPT make a very simple one.

Disclosure: This was basically vibe-coded (which was an adventure in itself) and then edited for cleanliness afterwards.

Basically, for a code block that you want tooltipped, you use an annotated-code-block instead, and it converts all trailing comments into tooltips. See an example here.

Screenshot 2025-12-31 at 12 46 06 PM Screenshot 2025-12-31 at 12 46 02 PM

There are some limitations, which I've noted in the extension module, but for these specific pages I think it works pretty well.

ALSO

  • Fixed YAML indentation in the examples, there was one column missing a second space
  • Autoformat docs/source/conf.py for readability

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.

1 participant