diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-03-21 20:55:30 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-03-21 20:55:30 +0900 |
commit | f9753e30deaa2ba6824e624aaf7ec464279123e4 (patch) | |
tree | cf2eaf418c78f8bec1e4626c137423ccdd758f4c /tests/test_ext_apidoc.py | |
parent | d7a9c8638bf3fd54f3d0f3fe6f21118620bec238 (diff) | |
parent | ce3019821b1f805bc72dfe5ecef727419701c410 (diff) | |
download | sphinx-git-f9753e30deaa2ba6824e624aaf7ec464279123e4.tar.gz |
Merge branch '1.7'
Diffstat (limited to 'tests/test_ext_apidoc.py')
-rw-r--r-- | tests/test_ext_apidoc.py | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/tests/test_ext_apidoc.py b/tests/test_ext_apidoc.py index 836c20b04..d3d61d1e0 100644 --- a/tests/test_ext_apidoc.py +++ b/tests/test_ext_apidoc.py @@ -211,7 +211,7 @@ def test_trailing_underscore(make_app, apidoc): @pytest.mark.apidoc( coderoot='test-apidoc-pep420/a', - excludes=["b/c/d.py", "b/e/f.py"], + excludes=["b/c/d.py", "b/e/f.py", "b/e/__init__.py"], options=["--implicit-namespaces", "--separate"], ) def test_excludes(apidoc): @@ -224,6 +224,45 @@ def test_excludes(apidoc): @pytest.mark.apidoc( + coderoot='test-apidoc-pep420/a', + excludes=["b/e"], + options=["--implicit-namespaces", "--separate"], +) +def test_excludes_subpackage_should_be_skipped(apidoc): + """Subpackage exclusion should work.""" + outdir = apidoc.outdir + assert (outdir / 'conf.py').isfile() + assert (outdir / 'a.b.c.rst').isfile() # generated because not empty + assert not (outdir / 'a.b.e.f.rst').isfile() # skipped because 'b/e' subpackage is skipped + + +@pytest.mark.apidoc( + coderoot='test-apidoc-pep420/a', + excludes=["b/e/f.py"], + options=["--implicit-namespaces", "--separate"], +) +def test_excludes_module_should_be_skipped(apidoc): + """Module exclusion should work.""" + outdir = apidoc.outdir + assert (outdir / 'conf.py').isfile() + assert (outdir / 'a.b.c.rst').isfile() # generated because not empty + assert not (outdir / 'a.b.e.f.rst').isfile() # skipped because of empty after excludes + + +@pytest.mark.apidoc( + coderoot='test-apidoc-pep420/a', + excludes=[], + options=["--implicit-namespaces", "--separate"], +) +def test_excludes_module_should_not_be_skipped(apidoc): + """Module should be included if no excludes are used.""" + outdir = apidoc.outdir + assert (outdir / 'conf.py').isfile() + assert (outdir / 'a.b.c.rst').isfile() # generated because not empty + assert (outdir / 'a.b.e.f.rst').isfile() # skipped because of empty after excludes + + +@pytest.mark.apidoc( coderoot='test-root', options=[ '--doc-project', u'プロジェクト名', @@ -339,3 +378,29 @@ def extract_toc(path): toctree = rst[start_idx + len(toctree_start):end_idx] return toctree + + +@pytest.mark.apidoc( + coderoot='test-apidoc-subpackage-in-toc', + options=['--separate'] +) + + +def test_subpackage_in_toc(make_app, apidoc): + """Make sure that empty subpackages with non-empty subpackages in them + are not skipped (issue #4520) + """ + outdir = apidoc.outdir + assert (outdir / 'conf.py').isfile() + + assert (outdir / 'parent.rst').isfile() + with open(outdir / 'parent.rst') as f: + parent = f.read() + assert 'parent.child' in parent + + assert (outdir / 'parent.child.rst').isfile() + with open(outdir / 'parent.child.rst') as f: + parent_child = f.read() + assert 'parent.child.foo' in parent_child + + assert (outdir / 'parent.child.foo.rst').isfile() |