Skip to content

gh-156870: Add common Stable ABI notes for tables of definitions - #156871

Open
encukou wants to merge 9 commits into
python:mainfrom
encukou:manual-stable-abi-notes
Open

gh-156870: Add common Stable ABI notes for tables of definitions#156871
encukou wants to merge 9 commits into
python:mainfrom
encukou:manual-stable-abi-notes

Conversation

@encukou

@encukou encukou commented Sep 3, 2026

Copy link
Copy Markdown
Member

Add two directives:

  • .. stable-abi-note:: adds a note with similar formatting as the auto-generated notes (not exact; that can be fixed in CSS which is in a different repo)
  • .. omit-stable-abi-notes:: a block in which autogenerated notes are omitted

Apply that to the tables of exceptions & iteration types.

(This PR has lots of indentation changes; hide them with ?w=1 in GitHub or -w on the Git command line.)

@read-the-docs-community

read-the-docs-community Bot commented Sep 3, 2026

Copy link
Copy Markdown

@picnixz picnixz changed the title gh-156870: Ad common stable abi notes for tables of definitions gh-156870: Add common stable abi notes for tables of definitions Sep 3, 2026
@picnixz picnixz changed the title gh-156870: Add common stable abi notes for tables of definitions gh-156870: Add common Stable ABI notes for tables of definitions Sep 3, 2026

@StanFromIreland StanFromIreland left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be broken, we've lost all notes looking at the preview:

Image

Comment thread Doc/tools/extensions/c_annotations.py Outdated
# in a 'c_annotations' attribute.
ancestor = node
while ancestor:
if 'omit-stable-abi-note' not in ancestor.get(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skip the note if any ancestor has 'omit-stable-abi-note'

Is this not inverted, it's skipped if it's absent?

Comment thread Doc/tools/extensions/c_annotations.py Outdated
[],
):
break
ancestor = node.parent

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be ancestor.parent?

Comment thread Doc/tools/extensions/c_annotations.py
Comment thread Doc/tools/extensions/c_annotations.py Outdated
# no skip; add the annotation
annotation = _stable_abi_annotation(record)
node.insert(0, annotation)
node.setdefault("classes", []).append('ADDED-HERE')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leftover from debugging I presume?

@encukou

encukou commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

Yes, thanks to the catch. That was not the code I meant to send.
Sorry for the noise!

Comment thread Doc/c-api/exceptions.rst Outdated

These pointers are part of the :ref:`Stable ABI <stable>` since the
version in the *S.ABI* column (or since 3.2 when *S.ABI* is empty).
Exceptions marked N/A are *not* part of Stable ABI.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Exceptions marked N/A are *not* part of Stable ABI.
Exceptions marked N/A are *not* part of the Stable ABI.

Comment thread Doc/c-api/iterator.rst
* :py:class:`zip`
.. stable-abi-note::

These pointers are part of the :ref:`Stable ABI <stable>`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These pointers are part of the :ref:`Stable ABI <stable>`.
These types are part of the :ref:`Stable ABI <stable>`.

I think it's more suitable here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to be a bit more specific here: make it clear I'm not referring to the C types (PyObject/PyTypeObject).

ancestor = ancestor.parent
else:
# no skip; add the annotation
annotation = _stable_abi_annotation(record)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach seems a bit fragile and wasteful, we already have the Stable ABI data, but we're duplicating it with hand-written tables. Can we at least assert it matches stable_abi_data?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't found a good way to do the assert.

I think this automation is a good tool -- it probably prevented a bunch of mistakes -- but where it has subpar results, we shouldn't be afraid to drop it and fall bask to writing things manually, like everywhere else in the docs.

If we start seeing many "S.ABI" columns, maybe we should automate that, but I don't think we're there yet.

Comment thread Doc/tools/extensions/c_annotations.py
Comment thread Doc/tools/extensions/c_annotations.py Outdated
has_content = True

def run(self) -> list[nodes.Node]:
node = nodes.Element() # Anonymous container for parsing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we note use SphinxDirective.parse_content_to_nodes to simplify a little?

Comment thread Doc/tools/extensions/c_annotations.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants