summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-09-04 22:07:28 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2021-09-04 22:44:04 +0900
commit223d615011808282de2ff552a21c09153ab84316 (patch)
tree586b9fe0f4dad501f736ef2965a3ece26d185d2a
parent6c38f68dae221e8cfc70c137974b8b88bd3baaab (diff)
downloadsphinx-git-223d615011808282de2ff552a21c09153ab84316.tar.gz
Fix #9608: apidoc: module is not described if implicit namespace package
To make implicit namespace packages referencable, this outputs empty module definitions for them.
-rw-r--r--CHANGES2
-rw-r--r--sphinx/templates/apidoc/package.rst_t4
-rw-r--r--tests/test_ext_apidoc.py2
3 files changed, 8 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index c7e781de8..5d31ebcef 100644
--- a/CHANGES
+++ b/CHANGES
@@ -25,6 +25,8 @@ Features added
Bugs fixed
----------
+* #9608: apidoc: apidoc does not generate a module definition for implicit
+ namespace package
* #9487: autodoc: typehint for cached_property is not shown
* #9509: autodoc: AttributeError is raised on failed resolving typehints
* #9518: autodoc: autodoc_docstring_signature does not effect to ``__init__()``
diff --git a/sphinx/templates/apidoc/package.rst_t b/sphinx/templates/apidoc/package.rst_t
index b7380e8a0..2229c311b 100644
--- a/sphinx/templates/apidoc/package.rst_t
+++ b/sphinx/templates/apidoc/package.rst_t
@@ -19,6 +19,10 @@
{{- [pkgname, "package"] | join(" ") | e | heading }}
{% endif %}
+{%- if is_namespace %}
+.. py:module:: {{ pkgname }}
+{% endif %}
+
{%- if modulefirst and not is_namespace %}
{{ automodule(pkgname, automodule_options) }}
{% endif %}
diff --git a/tests/test_ext_apidoc.py b/tests/test_ext_apidoc.py
index d6c45c268..ff057f0d8 100644
--- a/tests/test_ext_apidoc.py
+++ b/tests/test_ext_apidoc.py
@@ -635,6 +635,8 @@ def test_namespace_package_file(tempdir):
assert content == ("testpkg namespace\n"
"=================\n"
"\n"
+ ".. py:module:: testpkg\n"
+ "\n"
"Submodules\n"
"----------\n"
"\n"