summaryrefslogtreecommitdiff
path: root/tests/test_autodoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_autodoc.py')
-rw-r--r--tests/test_autodoc.py44
1 files changed, 19 insertions, 25 deletions
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py
index c9a342f94..cefceb833 100644
--- a/tests/test_autodoc.py
+++ b/tests/test_autodoc.py
@@ -21,7 +21,7 @@ from six import PY3
from sphinx.ext.autodoc import (
AutoDirective, ModuleLevelDocumenter, cut_lines, between, ALL,
- merge_autodoc_default_flags
+ merge_autodoc_default_flags, Options
)
from sphinx.ext.autodoc.directive import DocumenterBridge, process_documenter_options
from sphinx.testing.util import SphinxTestApp, Struct # NOQA
@@ -79,7 +79,7 @@ def setup_test():
global options, directive
global processed_docstrings, processed_signatures
- options = Struct(
+ options = Options(
inherited_members = False,
undoc_members = False,
private_members = False,
@@ -757,44 +757,40 @@ def test_autodoc_imported_members(app):
@pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_special_members(app):
- # all special methods
- options = {"members": None,
+ # specific special methods
+ options = {"undoc-members": None,
+ "special-members": "__init__,__special1__"}
+ actual = do_autodoc(app, 'class', 'target.Class', options)
+ assert list(filter(lambda l: '::' in l, actual)) == [
+ '.. py:class:: Class(arg)',
+ ' .. py:method:: Class.__init__(arg)',
+ ' .. py:method:: Class.__special1__()',
+ ]
+
+ # combination with specific members
+ options = {"members": "attr,docattr",
"undoc-members": None,
- "special-members": None}
+ "special-members": "__init__,__special1__"}
actual = do_autodoc(app, 'class', 'target.Class', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Class(arg)',
' .. py:method:: Class.__init__(arg)',
- ' .. py:attribute:: Class.__module__',
' .. py:method:: Class.__special1__()',
- ' .. py:method:: Class.__special2__()',
' .. py:attribute:: Class.attr',
- ' .. py:attribute:: Class.descr',
' .. py:attribute:: Class.docattr',
- ' .. py:method:: Class.excludemeth()',
- ' .. py:attribute:: Class.inst_attr_comment',
- ' .. py:attribute:: Class.inst_attr_inline',
- ' .. py:attribute:: Class.inst_attr_string',
- ' .. py:attribute:: Class.mdocattr',
- ' .. py:method:: Class.meth()',
- ' .. py:classmethod:: Class.moore(a, e, f) -> happiness',
- ' .. py:attribute:: Class.prop',
- ROGER_METHOD,
- ' .. py:attribute:: Class.skipattr',
- ' .. py:method:: Class.skipmeth()',
- ' .. py:attribute:: Class.udocattr',
- ' .. py:method:: Class.undocmeth()'
]
- # specific special methods
+ # all special methods
options = {"members": None,
"undoc-members": None,
- "special-members": "__init__,__special1__"}
+ "special-members": None}
actual = do_autodoc(app, 'class', 'target.Class', options)
assert list(filter(lambda l: '::' in l, actual)) == [
'.. py:class:: Class(arg)',
' .. py:method:: Class.__init__(arg)',
+ ' .. py:attribute:: Class.__module__',
' .. py:method:: Class.__special1__()',
+ ' .. py:method:: Class.__special2__()',
' .. py:attribute:: Class.attr',
' .. py:attribute:: Class.descr',
' .. py:attribute:: Class.docattr',
@@ -1551,9 +1547,7 @@ def test_autodoc_default_options_with_values(app):
assert ' .. py:attribute:: EnumCls.val4' not in actual
# with :special-members:
- # Note that :members: must be *on* for :special-members: to work.
app.config.autodoc_default_options = {
- 'members': None,
'special-members': '__init__,__iter__',
}
actual = do_autodoc(app, 'class', 'target.CustomIter')