mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #7314 from garciparedes/3.x
Propagate maxdepth option through package documents
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
{%- macro toctree(docnames) -%}
|
||||
.. toctree::
|
||||
:maxdepth: {{ maxdepth }}
|
||||
{% for docname in docnames %}
|
||||
{{ docname }}
|
||||
{%- endfor %}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user