Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions sphinx_automodapi/tests/example_module/stdlib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
A module that imports objects from the standard library.
"""
from pathlib import Path
from datetime import time


__all__ = ['Path', 'time', 'add']


def add(a, b):
"""
Add two numbers
"""
return a + b
50 changes: 50 additions & 0 deletions sphinx_automodapi/tests/test_automodapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,56 @@ def test_am_replacer_skip(tmpdir):
assert result == am_replacer_skip_expected


am_replacer_skip_stdlib_str = """
This comes before

.. automodapi:: sphinx_automodapi.tests.example_module.stdlib
:skip: time
:skip: Path

This comes after
"""


am_replacer_skip_stdlib_expected = """
This comes before


sphinx_automodapi.tests.example_module.stdlib Module
----------------------------------------------------

.. automodule:: sphinx_automodapi.tests.example_module.stdlib

Functions
^^^^^^^^^

.. automodsumm:: sphinx_automodapi.tests.example_module.stdlib
:functions-only:
:toctree: api
:skip: time,Path


This comes after
""".format(empty='')


def test_am_replacer_skip_stdlib(tmpdir):
"""
Tests using the ":skip:" option in an ".. automodapi::"
that skips objects imported from the standard library.
"""

with open(tmpdir.join('index.rst').strpath, 'w') as f:
f.write(am_replacer_skip_stdlib_str.format(options=''))

run_sphinx_in_tmpdir(tmpdir)

with open(tmpdir.join('index.rst.automodapi').strpath) as f:
result = f.read()

assert result == am_replacer_skip_stdlib_expected


am_replacer_include_str = """
This comes before

Expand Down