Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-134895: Add sphinx-codeautolink to doc build#134896

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
cmarqu wants to merge2 commits intopython:main
base:main
Choose a base branch
Loading
fromcmarqu:gh-134895

Conversation

cmarqu
Copy link

@cmarqucmarqu commentedMay 29, 2025
edited
Loading

This PR adds thehttps://sphinx-codeautolink.readthedocs.io/ Sphinx extension to the documentation build process. In their own words, it

makes code examples clickable by inserting links from individual code elements to the corresponding reference documentation

In my opinion, it is quite helpful for documentation readers to be able to immediately jump from e.g. tutorial code usinglogging.getLogger (<-- points to the PR doc build that shows the linking) to its reference description.

A bit of discussion has happened inhttps://discuss.python.org/t/add-the-sphinx-codeautolink-extension-to-doc-build-process/80814, back when the extension was not as robust and featureful as nowadays.
As said there, the styling of these extra links can be as unobtrusive as we want them.

Code examples that are parseable and self-contained (i.e. have all their imports) will have clickable objects.

Examples that are made up of parts that build on each other can also be supported with some extra markup (not part of this PR).
Missing imports can be annotated "invisibly" (not part of this PR).

Also, in the current state of the documentation, not all code examples thatcould be parseable actuallyare.
#133906 would fix a number of these.

Other examples would benefit from using.. code-block:: with an explicit language set instead of:: so that special handling forpycon (clean_pycon) could kick in. Right now, these places are producing a warning that is handled viasuppress_warnings.

Speaking ofsuppress_warnings, it containsconfig.cache because of
WARNING: cannot cache unpickleable configuration value: 'codeautolink_custom_blocks' (because it contains a function, class, or module object) [config.cache], which is indeed set to the functionclean_pycon.


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

@StanFromIreland
Copy link
Contributor

Is it possible for the text to not be underlined, it seems quite weird now for code examples to have link style highlighting:

image

@cmarqu
Copy link
Author

@StanFromIreland It is absolutely possible to style the links in any way we want, but for reviewing theeffect of the extension (i.e., what it links and what it doesn't), it is helpful to have styling where the links stand out.

I'll amend the styling in this PR after more comments have come in.

@cmarqu
Copy link
Author

cmarqu commentedMay 30, 2025
edited
Loading

I also have an old all-in-one branch around that fixes most of the warnings in the ReST sources:main...cmarqu:cpython:feat/add-sphinx-codeautolink; to get a feeling of what that would entail.

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

@picnixzpicnixzpicnixz left review comments

@AA-TurnerAA-TurnerAwaiting requested review from AA-TurnerAA-Turner is a code owner

@hugovkhugovkAwaiting requested review from hugovkhugovk is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@cmarqu@StanFromIreland@picnixz

[8]ページ先頭

©2009-2025 Movatter.jp