Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Docs: Add classes to C API return value annotations #117926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 16, 2024

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Apr 16, 2024

Currently light green is used for all return types

  • "Return value: Always NULL."
  • "Return value: New reference."
  • "Return value: Borrowed reference."

For example: https://docs.python.org/3/c-api/exceptions.html

Screenshots

image

image

image

A borrowed reference is not necessarily a "bad" thing, but we may want to use something other than green that indicates it's "good", to indicate they should be treated with care.

One option is yellow.

  1. These annotations are added in Doc/tools/extensions/c_annotations.py. The first step is to add CSS classes in this file.

  2. The light green colour is defined in https://github.com/python/python-docs-theme. The second step is to adjust the colours in the theme.

This PR also includes some light cleanup whilst we're touching this file, see commits.


📚 Documentation preview 📚: https://cpython-previews--117926.org.readthedocs.build/

@hugovk hugovk added skip issue skip news docs Documentation in the Doc dir labels Apr 16, 2024
Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@erlend-aasland erlend-aasland left a comment

Choose a reason for hiding this comment

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

Looks good

@hugovk hugovk enabled auto-merge (squash) April 16, 2024 15:44
@hugovk hugovk merged commit 3284b84 into python:main Apr 16, 2024
25 checks passed
@hugovk hugovk deleted the docs-c-api-return-value-classes branch April 16, 2024 15:56
@miss-islington-app
Copy link

Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 16, 2024
(cherry picked from commit 3284b84)

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

bedevere-app bot commented Apr 16, 2024

GH-117937 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Apr 16, 2024
hugovk added a commit that referenced this pull request Apr 16, 2024
#117937)

Docs: Add classes to C API return value annotations (GH-117926)
(cherry picked from commit 3284b84)

Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Nikita Sobolev <[email protected]>
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
@hugovk
Copy link
Member Author

hugovk commented Apr 17, 2024

Step two: python/python-docs-theme#188

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants