diff --git a/CHANGES b/CHANGES index 44ff0c0e7a..5c75a1d62d 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 b7380e8a04..2229c311b4 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 d6c45c2680..ff057f0d8c 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"