Skip to content

Conversation

@hugovk
Copy link
Member

@hugovkhugovk 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/

Copy link
Member

@sobolevnsobolevn 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-aaslanderlend-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

@hugovkhugovk enabled auto-merge (squash) April 16, 2024 15:44
@hugovkhugovk merged commit 3284b84 into python:mainApr 16, 2024
@hugovkhugovk 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

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

@bedevere-appbedevere-appbot 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
MemberAuthor

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

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docsDocumentation in the Doc dirskip issueskip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@hugovk@sobolevn@erlend-aasland