From 06b54c0a1f32c7dd78287495f4cb135ce83cf958 Mon Sep 17 00:00:00 2001 From: Sergio Garcia Prado Date: Sat, 14 Mar 2020 22:19:27 +0100 Subject: [PATCH 1/2] * Propagated "maxdepth" recursively through package documents. --- sphinx/ext/apidoc.py | 1 + sphinx/templates/apidoc/package.rst_t | 1 + 2 files changed, 2 insertions(+) diff --git a/sphinx/ext/apidoc.py b/sphinx/ext/apidoc.py index a9196d3a6..23be0a00a 100644 --- a/sphinx/ext/apidoc.py +++ b/sphinx/ext/apidoc.py @@ -175,6 +175,7 @@ def create_package_file(root: str, master_package: str, subroot: str, py_files: 'separatemodules': opts.separatemodules, 'automodule_options': options, 'show_headings': not opts.noheadings, + 'maxdepth': opts.maxdepth, } text = ReSTRenderer([user_template_dir, template_dir]).render('package.rst_t', context) write_file(pkgname, text, opts) diff --git a/sphinx/templates/apidoc/package.rst_t b/sphinx/templates/apidoc/package.rst_t index ed9f669ea..8630a87b7 100644 --- a/sphinx/templates/apidoc/package.rst_t +++ b/sphinx/templates/apidoc/package.rst_t @@ -7,6 +7,7 @@ {%- macro toctree(docnames) -%} .. toctree:: + :maxdepth: {{ maxdepth }} {% for docname in docnames %} {{ docname }} {%- endfor %} From 11dbf61626a04310cf85cba5aada6442cb5c9e81 Mon Sep 17 00:00:00 2001 From: Sergio Garcia Prado Date: Sun, 15 Mar 2020 12:02:49 +0100 Subject: [PATCH 2/2] * Updated tests according to latest changes. --- tests/test_ext_apidoc.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/test_ext_apidoc.py b/tests/test_ext_apidoc.py index a37527a02..e8d923b71 100644 --- a/tests/test_ext_apidoc.py +++ b/tests/test_ext_apidoc.py @@ -121,15 +121,16 @@ def test_pep_0420_enabled_separate(make_app, apidoc): with open(outdir / 'a.b.c.rst') as f: rst = f.read() - assert ".. toctree::\n\n a.b.c.d\n" in rst + + assert ".. toctree::\n :maxdepth: 4\n\n a.b.c.d\n" in rst with open(outdir / 'a.b.e.rst') as f: rst = f.read() - assert ".. toctree::\n\n a.b.e.f\n" in rst + assert ".. toctree::\n :maxdepth: 4\n\n a.b.e.f\n" in rst with open(outdir / 'a.b.x.rst') as f: rst = f.read() - assert ".. toctree::\n\n a.b.x.y\n" in rst + assert ".. toctree::\n :maxdepth: 4\n\n a.b.x.y\n" in rst app = make_app('text', srcdir=outdir) app.build() @@ -485,6 +486,7 @@ def test_package_file(tempdir): "-----------\n" "\n" ".. toctree::\n" + " :maxdepth: 4\n" "\n" " testpkg.subpkg\n" "\n" @@ -546,6 +548,7 @@ def test_package_file_separate(tempdir): "----------\n" "\n" ".. toctree::\n" + " :maxdepth: 4\n" "\n" " testpkg.example\n" "\n"