2021-01-27 10:57:46 -06:00
|
|
|
"""Test the autodoc extension."""
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
from .test_ext_autodoc import do_autodoc
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.sphinx('html', testroot='ext-autodoc',
|
|
|
|
confoverrides={'autodoc_preserve_defaults': True})
|
|
|
|
def test_preserve_defaults(app):
|
2022-04-18 11:33:56 -05:00
|
|
|
color = "0xFFFFFF"
|
2021-10-30 10:26:03 -05:00
|
|
|
|
2021-01-27 10:57:46 -06:00
|
|
|
options = {"members": None}
|
|
|
|
actual = do_autodoc(app, 'module', 'target.preserve_defaults', options)
|
|
|
|
assert list(actual) == [
|
|
|
|
'',
|
|
|
|
'.. py:module:: target.preserve_defaults',
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
'.. py:class:: Class()',
|
|
|
|
' :module: target.preserve_defaults',
|
|
|
|
'',
|
|
|
|
' docstring',
|
|
|
|
'',
|
|
|
|
'',
|
2022-05-07 05:52:25 -05:00
|
|
|
' .. py:method:: Class.clsmeth(name: str = CONSTANT, sentinel: ~typing.Any = '
|
|
|
|
'SENTINEL, now: ~datetime.datetime = datetime.now(), color: int = %s, *, '
|
|
|
|
'kwarg1, kwarg2=%s) -> None' % (color, color),
|
|
|
|
' :module: target.preserve_defaults',
|
|
|
|
' :classmethod:',
|
|
|
|
'',
|
|
|
|
' docstring',
|
|
|
|
'',
|
|
|
|
'',
|
2022-01-01 04:37:42 -06:00
|
|
|
' .. py:method:: Class.meth(name: str = CONSTANT, sentinel: ~typing.Any = '
|
2022-04-02 02:55:48 -05:00
|
|
|
'SENTINEL, now: ~datetime.datetime = datetime.now(), color: int = %s, *, '
|
|
|
|
'kwarg1, kwarg2=%s) -> None' % (color, color),
|
2021-01-27 10:57:46 -06:00
|
|
|
' :module: target.preserve_defaults',
|
|
|
|
'',
|
|
|
|
' docstring',
|
|
|
|
'',
|
|
|
|
'',
|
2022-01-01 04:37:42 -06:00
|
|
|
'.. py:function:: foo(name: str = CONSTANT, sentinel: ~typing.Any = SENTINEL, '
|
2022-04-02 02:55:48 -05:00
|
|
|
'now: ~datetime.datetime = datetime.now(), color: int = %s, *, kwarg1, '
|
|
|
|
'kwarg2=%s) -> None' % (color, color),
|
2021-01-27 10:57:46 -06:00
|
|
|
' :module: target.preserve_defaults',
|
|
|
|
'',
|
|
|
|
' docstring',
|
|
|
|
'',
|
|
|
|
]
|