Skip to content

gh-134918: Fix and improve doctest's documentation #134919

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 1 commit into from
May 31, 2025

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented May 30, 2025

@serhiy-storchaka serhiy-storchaka requested review from tim-one and a team May 30, 2025 08:35
@serhiy-storchaka serhiy-storchaka added docs Documentation in the Doc dir skip news needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 30, 2025
@github-project-automation github-project-automation bot moved this to Todo in Docs PRs May 30, 2025
@serhiy-storchaka
Copy link
Member Author

@tim-one, please look at the floating point examples.

@@ -1940,7 +1939,7 @@ several options for organizing tests:
containing test cases for the named topics. These functions can be included in
the same file as the module, or separated out into a separate test file.

* Define a ``__test__`` dictionary mapping from regression test topics to
* Define a :attr:`~module.__test__` dictionary mapping from regression test topics to
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a Sphinx cross-reference? Seems like it shouldn't; I wouldn't think module.__test__ is a valid cross-ref target within the Python docs.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, interesting, I see how that's set up now, thanks.

Isn't this an "off-label" (no pun intended) use of attribute, though? I would expect this to be implemented using a label. It seems odd that an attribute would link to something other than the API docs for (in this case) what would be module.__test__.

I see the benefit here, in that it results in __test__ being monospace-formatted. But it seems like a semantic mismatch to me.

Copy link
Member

Choose a reason for hiding this comment

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

We can say that this attribute may or may not exist, and dunder names are technically reserved for the language so I'm ok with this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, I'm good with it.

Copy link
Member Author

@serhiy-storchaka serhiy-storchaka May 30, 2025

Choose a reason for hiding this comment

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

Yet one benefit is adding "__test__ (module attribute)" in the index.

@serhiy-storchaka serhiy-storchaka merged commit 3c66e59 into python:main May 31, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from Todo to Done in Docs PRs May 31, 2025
@miss-islington-app
Copy link

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

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 31, 2025
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request May 31, 2025
@bedevere-app
Copy link

bedevere-app bot commented May 31, 2025

GH-134966 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 May 31, 2025
@bedevere-app
Copy link

bedevere-app bot commented May 31, 2025

GH-134967 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 May 31, 2025
@serhiy-storchaka serhiy-storchaka deleted the doctest-docs branch May 31, 2025 09:04
serhiy-storchaka added a commit that referenced this pull request May 31, 2025
serhiy-storchaka added a commit that referenced this pull request May 31, 2025
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 news
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants