sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

Namespaces packages more than one level deep are not rendered correctly using autodoc

Open michiel007 opened this issue 3 years ago • 1 comments

Describe the bug

When using a python project with native namespace, as per documentation https://packaging.python.org/namespace_packages, but with an extra namespace level like:

setup.py
setup.cfg
docs/
example_package/
    # No __init__.py here.
    middle_package/
        # No __init__.py here.
        subpackage_a/
            # Sub-packages have __init__.py.
            __init__.py
            test_a.py

When running:

sphinx-apidoc --implicit-namespaces --force -o docs/ ./example_package/

$(MAKE) -C docs html

sphinx-apidox is not putting the packages into the toc in the docs as expected. Giving a consistency fault in the sphinx-builder: checking consistency... ./example_pkg/docs/example_package.middle_package.rst: WARNING: document isn't included in any toctree

The output from sphinx-apidoc to example_package.rst:

example\_package namespace
==========================

.. py:module:: example_package

where the expected output is:

example\_package.middle\_package namespace
==========================================

.. py:module:: example_package

Subpackages
-----------

.. toctree::
   :maxdepth: 4

   example_package.middle_package

How to Reproduce

get project from github

git clone https://github.com/michiel007/example_pkg
cd example_pkg

create and setup virtual environment

python -m venv venv
source venv/bin/activate
python -m pip install -r requirements.txt

generate documentation

make docs

Expected behavior

No response

Your project

https://github.com/michiel007/example_pkg

Screenshots

No response

OS

ubuntu 20.04 LTS

Python version

3.8

Sphinx version

4.2.0

Sphinx extensions

sphinx.ext.autodoc

Extra tools

browser (optional)

Additional context

No response

michiel007 avatar Sep 27 '21 11:09 michiel007