-
Notifications
You must be signed in to change notification settings - Fork 141
Description
When using peer imports, autoapi seems to be generating its own duplicates in the files it generates, resulting in "duplicate object description" warnings. The warning message says "use :noindex: for one of them", but the problem is that autoapi is generating all of the relevant files, so it's not possible to do this.
The big problem, of course, isn't the warnings as much as the duplicate documentation that is being generated, making the resulting API docs rather a mess.
A complete (minimal) example follows, with 5 (very small) source files to illustrate the various facets of the problem.
# __init__.py
from .common import *
from .part1 import *
from .part2 import *
from .part3 import *
# common.py
class HandyClass:
def do_one(self, x):
print(x)
def do_two(self, x):
print(x + x)
# part1.py
from .common import HandyClass
class Part1Class(HandyClass):
def hello(self):
self.do_one('part 1')
print('hello')
# part2.py
from .common import HandyClass
class Part2Class:
def goodbye(self):
print('goodbye')
# part3.py
class Part3Class:
def aloha(self):
print('aloha')
After creating a docs structure with sphinx-quickstart and adding a minimal autoapi configuration, running make html
results in the following warnings in the console (with paths truncated by me for brevity here):
[...]/aatest/docs/source/autoapi/aatest/index.rst:46: WARNING: duplicate object description of aatest.HandyClass, other instance in autoapi/aatest/index, use :noindex: for one of them
[...]/aatest/docs/source/autoapi/aatest/index.rst:48: WARNING: duplicate object description of aatest.HandyClass.do_one, other instance in autoapi/aatest/index, use :noindex: for one of them
[...]/aatest/docs/source/autoapi/aatest/index.rst:51: WARNING: duplicate object description of aatest.HandyClass.do_two, other instance in autoapi/aatest/index, use :noindex: for one of them
[...]/aatest/docs/source/autoapi/aatest/index.rst:63: WARNING: duplicate object description of aatest.HandyClass, other instance in autoapi/aatest/index, use :noindex: for one of them
[...]/aatest/docs/source/autoapi/aatest/index.rst:65: WARNING: duplicate object description of aatest.HandyClass.do_one, other instance in autoapi/aatest/index, use :noindex: for one of them
[...]/aatest/docs/source/autoapi/aatest/index.rst:68: WARNING: duplicate object description of aatest.HandyClass.do_two, other instance in autoapi/aatest/index, use :noindex: for one of them
Notice that there is one "set" of warnings for each source file that imports HandyClass. That is, there are two sets of warnings because part1.py and part2.py both import from .common
, but not a third set because part3.py does not. Notice also that, although part2.py imports from .common
, it doesn't actually use it, so it's the existence of the import that's causing the issue.