pythonpython-sphinxsphinx-apidoc

Sphinx ignores py-file starting with a _ in filename


I am playing around with Sphinx 4.4.0 in a test project. I use sphinx.ext.autodoc and sphinx-apidoc.

But not all py files are recognized. It seams like that files with a starting _ in filename are ignored (e.g. _mypackage.py). But i am not sure if that character is the cause or something else.

Are you aware of an option to modify that behavior?

This is the project structure

sphinx_versuch
├── docs
│   ├── make.bat
│   ├── Makefile
│   └── source
│       ├── conf.py
│       ├── index.rst
│       ├── modules.rst
│       ├── mypackage.rst
│       ├── _static
│       └── _templates
├── LICENSE
├── README.md
├── src
│   ├── mypackage
│   │   ├── a.py
│   │   ├── b.py
│   │   ├── __init__.py
│   │   └── _mypackage.py
│   ├── setup.cfg
│   └── setup.py
└── tests
    ├── __init__.py
    ├── test_a.py
    ├── test_b.py
    └── test_mypackage.py

Solution

  • The option --private or -P for sphinx-apidoc make sure that private files (which start with an underscore by convention) are included also.

    See also https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html#cmdoption-sphinx-apidoc-P