Skip to content

Commit e3e8cbb

Browse files
committed
pythongh-134895: Add sphinx-codeautolink to doc build
1 parent a05433f commit e3e8cbb

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

Doc/_static/sphinx-codeautolink.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
Style autolinks from Python example code to reference documentation
3+
(https://sphinx-codeautolink.readthedocs.io/en/latest/examples.html#custom-link-styles)
4+
*/
5+
6+
.sphinx-codeautolink-a {
7+
text-decoration-style: solid !important;
8+
text-decoration-color: #aaa;
9+
}
10+
.sphinx-codeautolink-a:hover {
11+
text-decoration-color: black;
12+
}

Doc/conf.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'sphinx.ext.coverage',
3737
'sphinx.ext.doctest',
3838
'sphinx.ext.extlinks',
39+
'sphinx_codeautolink',
3940
]
4041

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

408+
# Additional CSS files.
409+
html_css_files = ["sphinx-codeautolink.css"]
410+
407411
# Output file base name for HTML help builder.
408412
htmlhelp_basename = 'python' + release.replace('.', '')
409413

@@ -413,6 +417,25 @@
413417
# Split pot files one per reST file
414418
gettext_compact = False
415419

420+
# Options for automatic links from code examples to reference documentation.
421+
# (https://sphinx-codeautolink.readthedocs.io/)
422+
codeautolink_warn_on_missing_inventory = False
423+
codeautolink_warn_on_failed_resolve = False
424+
codeautolink_custom_blocks = {
425+
# https://sphinx-codeautolink.readthedocs.io/en/latest/examples.html#doctest-code-blocks
426+
"pycon3": "sphinx_codeautolink.clean_pycon",
427+
}
428+
429+
suppress_warnings = [
430+
# "codeautolink",
431+
"codeautolink.import_star",
432+
"codeautolink.match_block",
433+
"codeautolink.match_name",
434+
"codeautolink.parse_block",
435+
"config.cache",
436+
]
437+
438+
416439
# Options for LaTeX output
417440
# ------------------------
418441

Doc/constraints.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ sphinxcontrib-serializinghtml<3
2222

2323
# Direct dependencies of Jinja2 (Jinja is a dependency of Sphinx, see above)
2424
MarkupSafe<3
25+
26+
# Direct dependencies of the sphinx-codeautolink extension
27+
beautifulsoup4<4.13.4

Doc/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ blurb
1313

1414
sphinxext-opengraph~=0.9.0
1515
sphinx-notfound-page~=1.0.0
16+
sphinx-codeautolink~=0.17.4
1617

1718
# The theme used by the documentation is stored separately, so we need
1819
# to install that as well.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add sphinx-codeautolink extension for reference links in code examples.
2+
Patch by Colin Marquardt.

0 commit comments

Comments
 (0)