10000 add one more validation that non-local names get skipped · astropy/sphinx-automodapi@a9177d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit a9177d4

Browse files
committed
add one more validation that non-local names get skipped
1 parent b355d30 commit a9177d4

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

sphinx_automodapi/tests/test_automodapi.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,56 @@ def test_am_replacer_skip_stdlib(tmpdir):
378378
assert result == am_replacer_skip_stdlib_expected
379379

380380

381+
am_replacer_include_stdlib_str = """
382+
This comes before
383+
384+
.. automodapi:: sphinx_automodapi.tests.example_module.stdlib
385+
:include: add
386+
:allowed-package-names: pathlib, datetime, sphinx_automodapi
387+
388+
This comes after
389+
"""
390+
391+
am_replacer_include_stdlib_expected = """
392+
This comes before
393+
394+
395+
sphinx_automodapi.tests.example_module.stdlib Module
396+
----------------------------------------------------
397+
398+
.. automodule:: sphinx_automodapi.tests.example_module.stdlib
399+
400+
Functions
401+
^^^^^^^^^
402+
403+
.. automodsumm:: sphinx_automodapi.tests.example_module.stdlib
404+
:functions-only:
405+
:toctree: api
406+
:skip: Path,time
407+
:allowed-package-names: pathlib,datetime,sphinx_automodapi
408+
409+
410+
This comes after
411+
""".format(empty='')
412+
413+
414+
def test_am_replacer_include_stdlib(tmpdir):
415+
"""
416+
Tests using the ":include: option in an ".. automodapi::"
417+
in the presence of objects imported from the standard library.
418+
"""
419+
420+
with open(tmpdir.join('index.rst').strpath, 'w') as f:
421+
f.write(am_replacer_include_stdlib_str.format(options=''))
422+
423+
run_sphinx_in_tmpdir(tmpdir)
424+
425+
with open(tmpdir.join('index.rst.automodapi').strpath) as f:
426+
result = f.read()
427+
428+
assert result == am_replacer_include_stdlib_expected
429+
430+
381431
am_replacer_include_str = """
382432
This comes before
383433

0 commit comments

Comments
 (0)
0