Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Doc/_static/sphinx-codeautolink.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Style autolinks from Python example code to reference documentation
(https://sphinx-codeautolink.readthedocs.io/en/latest/examples.html#custom-link-styles)
*/

.sphinx-codeautolink-a {
text-decoration-style: solid !important;
text-decoration-color: #aaa;
}
.sphinx-codeautolink-a:hover {
text-decoration-color: black;
}
24 changes: 24 additions & 0 deletions Doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'sphinx.ext.coverage',
'sphinx.ext.doctest',
'sphinx.ext.extlinks',
'sphinx_codeautolink',
]

# Skip if downstream redistributors haven't installed them
Expand Down Expand Up @@ -404,6 +405,9 @@
# Additional static files.
html_static_path = ['_static', 'tools/static']

# Additional CSS files.
html_css_files = ["sphinx-codeautolink.css"]

# Output file base name for HTML help builder.
htmlhelp_basename = 'python' + release.replace('.', '')

Expand All @@ -413,6 +417,26 @@
# Split pot files one per reST file
gettext_compact = False

# Options for automatic links from code examples to reference documentation.
# (https://sphinx-codeautolink.readthedocs.io/)
# codeautolink_warn_on_missing_inventory = False
# codeautolink_warn_on_failed_resolve = False
codeautolink_custom_blocks = {
# https://sphinx-codeautolink.readthedocs.io/en/latest/reference.html#cleanup-functions
"pycon": "sphinx_codeautolink.clean_pycon",
}

suppress_warnings = [
# https://sphinx-codeautolink.readthedocs.io/en/latest/reference.html#warning-types
# "codeautolink",
"codeautolink.import_star",
"codeautolink.match_block",
"codeautolink.match_name",
"codeautolink.parse_block",
"config.cache",
]


# Options for LaTeX output
# ------------------------

Expand Down
3 changes: 3 additions & 0 deletions Doc/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ sphinxcontrib-serializinghtml<3

# Direct dependencies of Jinja2 (Jinja is a dependency of Sphinx, see above)
MarkupSafe<3

# Direct dependencies of the sphinx-codeautolink extension
beautifulsoup4<4.13.4
1 change: 1 addition & 0 deletions Doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ blurb

sphinxext-opengraph~=0.9.0
sphinx-notfound-page~=1.0.0
sphinx-codeautolink~=0.17.4

# The theme used by the documentation is stored separately, so we need
# to install that as well.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Add sphinx-codeautolink extension for reference links in code examples.
Patch by Colin Marquardt.
Loading