Merge pull request #7314 from garciparedes/3.x

Propagate maxdepth option through package documents
This commit is contained in:
Takeshi KOMIYA
2020-03-15 22:18:28 +09:00
committed by GitHub
3 changed files with 8 additions and 3 deletions

View File

@@ -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)

View File

@@ -7,6 +7,7 @@
{%- macro toctree(docnames) -%}
.. toctree::
:maxdepth: {{ maxdepth }}
{% for docname in docnames %}
{{ docname }}
{%- endfor %}

View File

@@ -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"