Skip to content

Conversation

@ZeroIntensity
Copy link
Member

@ZeroIntensity ZeroIntensity commented Nov 30, 2025

This adds a simple job requiring that any new public C APIs come with documentation, which should prevent things from slipping through the cracks each release.

IGNORED.pop(index)


def is_documented(name: str) -> bool:
Copy link
Member

Choose a reason for hiding this comment

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

I think is_documented is a little different from is present. Why not improve the check to include verifying it's a doc declaration, i.e. if it's in the text check it's on the same line as the c:func:: etc.?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that, but I decided that it was a case of "practicality beats purity". Running Sphinx or using a regular expression will make this significantly slower, and probably won't save us much in practice.

Copy link
Member

Choose a reason for hiding this comment

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

As a compromise, we could go ever simpler, just checking if :: and .. are in the same line as the API name.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hm, that may work, but the list in #141004 was created using a full-text search, not a search for :: or .., so there are probably some APIs that still need work. Let's finish the list in #141004 first, and then we can look into finding more edge cases.

ZeroIntensity and others added 2 commits November 30, 2025 19:26
@ZeroIntensity ZeroIntensity added needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels Dec 1, 2025
@ZeroIntensity
Copy link
Member Author

I plan on backporting this to prevent conflicts when things are removed from ignored_c_api.txt. Any objections?

@hugovk
Copy link
Member

hugovk commented Dec 1, 2025

No objection to backporting.

Copy link
Member

@StanFromIreland StanFromIreland left a comment

Choose a reason for hiding this comment

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

This currently picks up decelerations in comments, e.g. Py_OldFunction which is an example. This currently passes as the same example is used in the docs.

Edit: I wrote: ZeroIntensity#6

@ZeroIntensity
Copy link
Member Author

I assume that this is broken in strings too, for example: puts("PyAPI_FUNC(int) PySomething(void);"). There are plenty of ways to break the regular expressions.

We can't really get this to work perfectly without using an actual C parser. If those comments aren't causing problems for us, why bother?

@ZeroIntensity
Copy link
Member Author

To clarify: I agree with eventually adding better handling, I just don't think it should be done here. I'd like this script to be as close as possible to the script used to generate the list in #141004. We can expand on this in a later iteration.

@ZeroIntensity
Copy link
Member Author

I'm going to merge this. For changes regarding the mock C parsing here, please open a new issue and/or PR.

@ZeroIntensity ZeroIntensity enabled auto-merge (squash) December 4, 2025 02:49
@ZeroIntensity ZeroIntensity merged commit 1a7824a into python:main Dec 4, 2025
44 checks passed
@miss-islington-app
Copy link

Thanks @ZeroIntensity for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Sorry, @ZeroIntensity, I could not cleanly backport this to 3.14 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1a7824a927f0706300af7bfc182884a43e2f587a 3.14

@miss-islington-app
Copy link

Sorry, @ZeroIntensity, I could not cleanly backport this to 3.13 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker 1a7824a927f0706300af7bfc182884a43e2f587a 3.13

@bedevere-app
Copy link

bedevere-app bot commented Dec 4, 2025

GH-142247 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.14 bugs and security fixes label Dec 4, 2025
ZeroIntensity added a commit to ZeroIntensity/cpython that referenced this pull request Dec 4, 2025
…ntation (pythonGH-142102)

Co-authored-by: Hugo van Kemenade <[email protected]>
(cherry picked from commit 1a7824a)
ZeroIntensity added a commit to ZeroIntensity/cpython that referenced this pull request Dec 4, 2025
… documentation (pythonGH-142102)

(cherry picked from commit 1a7824a)

Co-authored-by: Peter Bierma <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Dec 4, 2025

GH-142248 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Dec 4, 2025
ZeroIntensity added a commit to ZeroIntensity/cpython that referenced this pull request Dec 4, 2025
…ntation (pythonGH-142102)

Co-authored-by: Hugo van Kemenade <[email protected]>
(cherry picked from commit 1a7824a)
ZeroIntensity added a commit to ZeroIntensity/cpython that referenced this pull request Dec 4, 2025
… documentation (pythonGH-142102)

(cherry picked from commit 1a7824a)

Co-authored-by: Peter Bierma <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
ZeroIntensity added a commit that referenced this pull request Dec 4, 2025
…entation (GH-142102) (GH-142247)

* gh-141004: Add a CI job ensuring that new C APIs include documentation (GH-142102)

Co-authored-by: Hugo van Kemenade <[email protected]>
(cherry picked from commit 1a7824a)

---------

Co-authored-by: Hugo van Kemenade <[email protected]>
StanFromIreland pushed a commit to StanFromIreland/cpython that referenced this pull request Dec 6, 2025
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.

3 participants