@@ -327,6 +327,107 @@ def test_am_replacer_skip(tmpdir):
327327 assert result == am_replacer_skip_expected
328328
329329
330+ am_replacer_skip_stdlib_str = """
331+ This comes before
332+
333+ .. automodapi:: sphinx_automodapi.tests.example_module.stdlib
334+ :skip: time
335+ :skip: Path
336+
337+ This comes after
338+ """
339+
340+
341+ am_replacer_skip_stdlib_expected = """
342+ This comes before
343+
344+
345+ sphinx_automodapi.tests.example_module.stdlib Module
346+ ----------------------------------------------------
347+
348+ .. automodule:: sphinx_automodapi.tests.example_module.stdlib
349+
350+ Functions
351+ ^^^^^^^^^
352+
353+ .. automodsumm:: sphinx_automodapi.tests.example_module.stdlib
354+ :functions-only:
355+ :toctree: api
356+ :skip: time,Path
357+
358+
359+ This comes after
360+ """ .format (empty = '' )
361+
362+
363+ def test_am_replacer_skip_stdlib (tmpdir ):
364+ """
365+ Tests using the ":skip:" option in an ".. automodapi::"
366+ that skips objects imported from the standard library.
367+ This is a regression test for #141
368+ """
369+
370+ with open (tmpdir .join ('index.rst' ).strpath , 'w' ) as f :
371+ f .write (am_replacer_skip_stdlib_str .format (options = '' ))
372+
373+ run_sphinx_in_tmpdir (tmpdir )
374+
375+ with open (tmpdir .join ('index.rst.automodapi' ).strpath ) as f :
376+ result = f .read ()
377+
378+ assert result == am_replacer_skip_stdlib_expected
379+
380+
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+
330431am_replacer_include_str = """
331432This comes before
332433
0 commit comments