sphinx-doc / sphinx

The Sphinx documentation generator
https://www.sphinx-doc.org/
Other
6.6k stars 2.12k forks source link

maxdepth in package toctrees by sphinx-apidoc #2108

Open arski opened 9 years ago

arski commented 9 years ago

Hi,

I know sphinx-apidoc already has the -d option to set the maxdepth in the main modules TOC. However, I was wondering if this or another option could be used to add :maxdepth: to the toctree of each package, i.e. after https://github.com/sphinx-doc/sphinx/blob/470bac3d1c17f2728573f96c2864ab07918692d2/sphinx/apidoc.py#L109

Alternatively, how hard would it be to add a default maxdepth setting to Spinx itself, so that it would be configurable in conf.py?

Cheers

jluttine commented 8 years ago

Any workaround for this? The documentation generated with apidoc is a bit of a mess because it is not possible to adjust the depth of package toctrees. So a package page becomes full of submodules of subpackages of subpackages of subpackages.

sblask commented 7 years ago

I had the same problem and as I run sphinx-apidoc from a separate script anyway, I fix it like this:

# sphinx-apidoc doesn't allow setting maxdepth on subpackages
sed -i "s/.. toctree::/.. toctree::\n   :maxdepth: 1/g" ${SCRIPT_DIRECTORY}/_generated/*
# sphinx toctree is very indentation sensitive, make it uniform
sed -i "s/    /   /g" ${SCRIPT_DIRECTORY}/_generated/*