Open
Description
Describe the bug
I get WARNING: duplicate object description of [...], other instance in[...], use :noindex: for one of them
If
- A class is included in two
__all__
s which do not belong to the module where the class is defined, sphinx-apidoc
's option--separate
/-e
is used.
This is not a problem for functions, only for classes.
How to Reproduce
Minimal method:
Say you have a directory structure
.
├── mainpackage
│ ├── __init__.py
│ └── subpackage
│ ├── __init__.py
│ └── module_in_subpackage.py
└── docs
With the following file contents:
mainpackage/subpackage/module_in_subpackage.py
:
class MyClass:
pass
def my_func():
pass
mainpackage/subpackage/__init__.py
:
from .module_in_subpackage import MyClass, my_func
__all__ = ['MyClass', 'my_func']
mainpackage/__init__.py
:
from .subpackage.module_in_subpackage import MyClass, my_func
__all__ = ['MyClass', 'my_func']
Now run, in .
:
sphinx-apidoc -F -e -o docs/ mainpackage/
PYTHONPATH=/absolute/path/to/./:$PATH make -C docs/ html
You should get the warning, but only for the class and not for the function.
This example can also be found on my github at https://github.com/KendrickLamarck/sphinxbugtest.
Environment Information
Platform: darwin; (macOS-12.6-arm64-arm-64bit)
Python version: 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)])
Python implementation: CPython
Sphinx version: 5.3.0
Docutils version: 0.19
Jinja2 version: 3.1.2
Sphinx extensions
['sphinx.ext.autodoc']
Additional context
No response