Side annotations on a page without a table of contents
This page shows side annotations on a page that has no table of contents. The text stays in Starlight’s content column. A side annotation block with lines too long for that column spreads over the free space on each side. Then it shows the notes beside the code. Make the window narrower to see the notes move under the block.
This block needs a width of 800 px:
with path.open(newline="", encoding="utf-8") as fh:
- Note 1, for line 7:
newline=""lets the CSV reader handle line ends. - Note 2, for line 8: Skips rows with no status.
- Note 3, for line 12: Counts the orders for each status.
This block needs a width of 1000 px:
from orders import count_by_status
counts = count_by_status(orders) items = sorted(counts.items(), key=lambda item: item[1], reverse=True) out.write_text("\n".join(f"{status:<{width}} {n:>6}" for status, n in items))- Note 1, for line 6:
*makeswidtha keyword argument. - Note 2, for line 8: The largest counts come first.
- Note 3, for line 9: One line for each status, in columns.
The lines of this block fit the content column, so the block stays in line with the text: