Skip to content

Commit 1a62f31

Browse files
djhoeseAA-Turner
andauthored
Fix apidoc extension not setting default header/package name (#13391)
Co-authored-by: Adam Turner <9087854+aa-turner@users.noreply.github.com>
1 parent 13d2899 commit 1a62f31

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

AUTHORS.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Contributors
4545
* Daniel Eades -- improved static typing
4646
* Daniel Hahler -- testing and CI improvements
4747
* Daniel Pizetta -- inheritance diagram improvements
48-
* Dave Hoese -- ``sphinx.ext.viewcode`` bug fix
48+
* Dave Hoese -- ``sphinx.ext.viewcode`` and ``sphinx.ext.apidoc`` bug fixes
4949
* Dave Kuhlman -- original LaTeX writer
5050
* Dimitri Papadopoulos Orfanos -- linting and spelling
5151
* Dmitry Shachnev -- modernisation and reproducibility

CHANGES.rst

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Bugs fixed
1818

1919
* #13392: Fix argument type for ``jieba.load_userdict()``.
2020
* #13402: Ensure inline ``<script>`` tags are written exactly once.
21+
* #13391: apidoc: Fix TOC file not having a title.
22+
Patch by Dave Hoese.
2123

2224
Testing
2325
-------

sphinx/ext/apidoc/_extension.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ def _parse_module_options(
217217
dest_dir=dest_path,
218218
module_path=module_path,
219219
exclude_pattern=exclude_patterns,
220-
automodule_options=automodule_options,
221220
max_depth=max_depth,
222221
quiet=True,
223222
follow_links=bool_options['follow_links'],
@@ -226,6 +225,8 @@ def _parse_module_options(
226225
no_headings=bool_options['no_headings'],
227226
module_first=bool_options['module_first'],
228227
implicit_namespaces=bool_options['implicit_namespaces'],
228+
automodule_options=automodule_options,
229+
header=module_path.name,
229230
)
230231

231232

tests/test_extensions/test_ext_apidoc.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -782,13 +782,14 @@ def test_sphinx_extension(app: SphinxTestApp) -> None:
782782
app.build()
783783
assert app.warning.getvalue() == ''
784784

785-
assert set((app.srcdir / 'generated').iterdir()) == {
786-
app.srcdir / 'generated' / 'modules.rst',
787-
app.srcdir / 'generated' / 'my_package.rst',
788-
}
789-
assert 'show-inheritance' not in (
790-
app.srcdir / 'generated' / 'my_package.rst'
791-
).read_text(encoding='utf8')
785+
toc_file = app.srcdir / 'generated' / 'modules.rst'
786+
pkg_file = app.srcdir / 'generated' / 'my_package.rst'
787+
assert set((app.srcdir / 'generated').iterdir()) == {toc_file, pkg_file}
788+
modules_content = toc_file.read_text(encoding='utf8')
789+
assert modules_content == (
790+
'src\n===\n\n.. toctree::\n :maxdepth: 3\n\n my_package\n'
791+
)
792+
assert 'show-inheritance' not in pkg_file.read_text(encoding='utf8')
792793
assert (app.outdir / 'generated' / 'my_package.html').is_file()
793794

794795
# test a re-build

0 commit comments

Comments
 (0)