Skip to content

Commit f4ff164

Browse files
committed
Update docs.
1 parent db9343d commit f4ff164

File tree

5 files changed

+47
-2
lines changed

5 files changed

+47
-2
lines changed

doc-source/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
'sphinxcontrib.toctree_plus',
5656
'seed_intersphinx_mapping',
5757
'sphinx.ext.autosectionlabel',
58+
'patched_autosummary',
5859
]
5960

6061
sphinxemoji_style = 'twemoji'
@@ -125,3 +126,6 @@
125126
"__hash__",
126127
]),
127128
}
129+
130+
131+
set_type_checking_flag = True

doc-source/patched_autosummary.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# stdlib
2+
import re
3+
from typing import Any, Dict, List, Tuple
4+
5+
# 3rd party
6+
import sphinx
7+
from sphinx.application import Sphinx
8+
from sphinx.ext.autosummary import Autosummary
9+
10+
11+
class PatchedAutosummary(Autosummary):
12+
"""
13+
Pretty table containing short signatures and summaries of functions etc.
14+
15+
Patched version of :class:`sphinx.ext.autosummary.Autosummary` to fix issue where
16+
the module name is sometimes duplicated.
17+
18+
I.e. ``foo.bar.baz()`` became ``foo.bar.foo.bar.baz()``, which of course doesn't exist
19+
and so resulted in a broken link.
20+
"""
21+
22+
def import_by_name(self, name: str, prefixes: List[str]) -> Tuple[str, Any, Any, str]:
23+
real_name, obj, parent, modname = super().import_by_name(name=name, prefixes=prefixes)
24+
real_name = re.sub(rf"((?:{modname}\.)+)", f"{modname}.", real_name)
25+
return real_name, obj, parent, modname
26+
27+
28+
def setup(app: Sphinx) -> Dict[str, Any]:
29+
app.setup_extension('sphinx.ext.autosummary')
30+
app.add_directive('autosummary', PatchedAutosummary, override=True)
31+
32+
return {
33+
'version': f"{sphinx.__display_version__}-patched-autosummary-0",
34+
'parallel_read_safe': True,
35+
}

doc-source/requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
autodocsumm>=0.2.0
2-
default_values>=0.0.9
2+
default_values>=0.0.10
33
domdf_sphinx_theme>=0.1.0
44
extras_require>=0.2.0
5-
pandas>=1.0.0
65
seed_intersphinx_mapping>=0.1.1
76
sphinx>=3.0.3
87
sphinx-copybutton>=0.2.12

repo_helper.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ yapf_exclude:
4949

5050
manifest_additional:
5151
- "include domdf_python_tools/google-10000-english-no-swears.txt"
52+
53+
sphinx_conf_epilogue:
54+
- set_type_checking_flag = True

tox.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ rst-roles =
170170
wikipedia
171171
rst:role
172172
rst:dir
173+
pull
174+
issue
173175
rst-directives =
174176
envvar
175177
exception
@@ -179,6 +181,8 @@ rst-directives =
179181
versionchanged
180182
rest-example
181183
extras-require
184+
literalinclude
185+
autoclass
182186
per-file-ignores =
183187
tests/*: D100 D101 D102 D103 D104 D106 D201 D204 D207 D208 D209 D210 D211 D212 D213 D214 D215 D300 D301 D400 D402 D403 D404 D415 D417 DALL000
184188
pytest-parametrize-names-type = csv

0 commit comments

Comments
 (0)