As posted here: https://stackoverflow.com/questions/51881692/how-can-i-use-sphinx-with-subpackages-without-duplicating-everything?
I have the following package structure as a minimal example (for convenience, all is uploaded here <https://github.com/themightyoarfish/sphinx-mwe-so>): .├── sphinx│ ├── build│ ├── Makefile│ └── source│ ├── conf.py│ ├── index.rst│ └── train.rst└── train ├── __init__.py └── train.py When writing Python packages, one must specifiy the __all__ constant in the __init__.py of any package in order for Sphinx to be able to map a reference such as train.DatasetMeta to train.train.DatasetMeta or similar. However, sphinx-apidoc generates the following sections for these packages: train package============= Submodules---------- train.train module------------------ .. automodule:: train.train :members: :undoc-members: :show-inheritance: Module contents--------------- .. automodule:: train :members: :undoc-members: :show-inheritance: Which duplicates the entire documentation as it contains .. automodule:: module.file as well as .. automodule:: module, which refer to the same thing. Removing either of these sections results in undefined reference warnings (turned into errors when using -n to SPHINXOPTS). sphinx_test/train/train.py:docstring of train.DatasetMeta:1:py:class reference target not found: train.train.DatasetMeta How can I solve this? *train/train.py* from collections import namedtuple class DatasetMeta(namedtuple('DatasetMeta', ['dataset', 'num_classes', 'shape'])): @property def size(self): '''int: Number of examples in the dataset''' return self.shape[0] *train/__init__.py* from .train import * __all__ = ['DatasetMeta'] *sphinx/source/conf.py* import osimport sys sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('../../')) project = 'test' copyright = '' author = '' version = '' release = '0' extensions = [ 'sphinx.ext.autodoc',] source_suffix = '.rst' master_doc = 'index' I just cannot figure out what the logic is here. -- You received this message because you are subscribed to the Google Groups "sphinx-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sphinx-users. For more options, visit https://groups.google.com/d/optout.
