Merge pull request #7358 from tk0miya/refactor_autodoc

refactor: autodoc: Remove needless spaces from blank line
This commit is contained in:
Takeshi KOMIYA 2020-03-22 17:55:32 +09:00 committed by GitHub
commit 91a22a3ecc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 252 additions and 249 deletions

View File

@ -270,7 +270,10 @@ class Documenter:
def add_line(self, line: str, source: str, *lineno: int) -> None: def add_line(self, line: str, source: str, *lineno: int) -> None:
"""Append one line of generated reST to the output.""" """Append one line of generated reST to the output."""
if line.strip(): # not a blank line
self.directive.result.append(self.indent + line, source, *lineno) self.directive.result.append(self.indent + line, source, *lineno)
else:
self.directive.result.append('', source, *lineno)
def resolve_name(self, modname: str, parents: Any, path: str, base: Any def resolve_name(self, modname: str, parents: Any, path: str, base: Any
) -> Tuple[str, List[str]]: ) -> Tuple[str, List[str]]:

View File

@ -361,7 +361,7 @@ def test_new_documenter(app):
' :module: target', ' :module: target',
'', '',
' documentation for the integer', ' documentation for the integer',
' ' '',
] ]
@ -420,7 +420,7 @@ def test_py_module(app, warning):
' :module: target', ' :module: target',
'', '',
' Function.', ' Function.',
' ' '',
] ]
assert ("don't know which module to import for autodocumenting 'Class.meth'" assert ("don't know which module to import for autodocumenting 'Class.meth'"
not in warning.getvalue()) not in warning.getvalue())
@ -435,7 +435,7 @@ def test_autodoc_decorator(app):
' :module: target.decorator', ' :module: target.decorator',
'', '',
' docstring for deco1', ' docstring for deco1',
' ' '',
] ]
actual = do_autodoc(app, 'decorator', 'target.decorator.deco2') actual = do_autodoc(app, 'decorator', 'target.decorator.deco2')
@ -445,7 +445,7 @@ def test_autodoc_decorator(app):
' :module: target.decorator', ' :module: target.decorator',
'', '',
' docstring for deco2', ' docstring for deco2',
' ' '',
] ]
@ -458,7 +458,7 @@ def test_autodoc_exception(app):
' :module: target', ' :module: target',
'', '',
' My custom exception.', ' My custom exception.',
' ' '',
] ]
@ -726,7 +726,7 @@ def test_autodoc_subclass_of_builtin_class(app):
' :module: target', ' :module: target',
'', '',
' Docstring.', ' Docstring.',
' ' '',
] ]
@ -740,23 +740,23 @@ def test_autodoc_inner_class(app):
' :module: target', ' :module: target',
'', '',
' Foo', ' Foo',
' ', '',
' ', '',
' .. py:class:: Outer.Inner', ' .. py:class:: Outer.Inner',
' :module: target', ' :module: target',
' ', '',
' Foo', ' Foo',
' ', '',
' ', '',
' .. py:method:: Outer.Inner.meth()', ' .. py:method:: Outer.Inner.meth()',
' :module: target', ' :module: target',
' ', '',
' Foo', ' Foo',
' ', '',
' ', '',
' .. py:attribute:: Outer.factory', ' .. py:attribute:: Outer.factory',
' :module: target', ' :module: target',
' ', '',
' alias of :class:`builtins.dict`' ' alias of :class:`builtins.dict`'
] ]
@ -767,13 +767,13 @@ def test_autodoc_inner_class(app):
' :module: target.Outer', ' :module: target.Outer',
'', '',
' Foo', ' Foo',
' ', '',
' ', '',
' .. py:method:: Inner.meth()', ' .. py:method:: Inner.meth()',
' :module: target.Outer', ' :module: target.Outer',
' ', '',
' Foo', ' Foo',
' ', '',
] ]
options['show-inheritance'] = True options['show-inheritance'] = True
@ -785,7 +785,7 @@ def test_autodoc_inner_class(app):
' Bases: :class:`target.Outer.Inner`', ' Bases: :class:`target.Outer.Inner`',
'', '',
' InnerChild docstring', ' InnerChild docstring',
' ' '',
] ]
@ -799,7 +799,7 @@ def test_autodoc_classmethod(app):
' :classmethod:', ' :classmethod:',
'', '',
' Inherited class method.', ' Inherited class method.',
' ' '',
] ]
@ -813,7 +813,7 @@ def test_autodoc_staticmethod(app):
' :staticmethod:', ' :staticmethod:',
'', '',
' Inherited static method.', ' Inherited static method.',
' ' '',
] ]
@ -827,19 +827,19 @@ def test_autodoc_descriptor(app):
'.. py:class:: Class', '.. py:class:: Class',
' :module: target.descriptor', ' :module: target.descriptor',
'', '',
' ', '',
' .. py:attribute:: Class.descr', ' .. py:attribute:: Class.descr',
' :module: target.descriptor', ' :module: target.descriptor',
' ', '',
' Descriptor instance docstring.', ' Descriptor instance docstring.',
' ', '',
' ', '',
' .. py:method:: Class.prop', ' .. py:method:: Class.prop',
' :module: target.descriptor', ' :module: target.descriptor',
' :property:', ' :property:',
' ', '',
' Property.', ' Property.',
' ' ''
] ]
@ -854,7 +854,7 @@ def test_autodoc_c_module(app):
" Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.", " Convert a time tuple to a string, e.g. 'Sat Jun 06 16:26:11 1998'.",
' When the time tuple is not present, current time as returned by localtime()', ' When the time tuple is not present, current time as returned by localtime()',
' is used.', ' is used.',
' ' '',
] ]
@ -946,7 +946,7 @@ def test_autodoc_module_scope(app):
' :value: <_io.StringIO object>', ' :value: <_io.StringIO object>',
'', '',
' should be documented as well - süß', ' should be documented as well - süß',
' ' '',
] ]
@ -962,7 +962,7 @@ def test_autodoc_class_scope(app):
' :value: <_io.StringIO object>', ' :value: <_io.StringIO object>',
'', '',
' should be documented as well - süß', ' should be documented as well - süß',
' ' '',
] ]
@ -976,16 +976,16 @@ def test_class_attributes(app):
'.. py:class:: AttCls', '.. py:class:: AttCls',
' :module: target', ' :module: target',
'', '',
' ', '',
' .. py:attribute:: AttCls.a1', ' .. py:attribute:: AttCls.a1',
' :module: target', ' :module: target',
' :value: hello world', ' :value: hello world',
' ', '',
' ', '',
' .. py:attribute:: AttCls.a2', ' .. py:attribute:: AttCls.a2',
' :module: target', ' :module: target',
' :value: None', ' :value: None',
' ' ''
] ]
@ -999,43 +999,43 @@ def test_instance_attributes(app):
' :module: target', ' :module: target',
'', '',
' Class with documented class and instance attributes.', ' Class with documented class and instance attributes.',
' ', '',
' ', '',
' .. py:attribute:: InstAttCls.ca1', ' .. py:attribute:: InstAttCls.ca1',
' :module: target', ' :module: target',
" :value: 'a'", " :value: 'a'",
' ', '',
' Doc comment for class attribute InstAttCls.ca1.', ' Doc comment for class attribute InstAttCls.ca1.',
' It can have multiple lines.', ' It can have multiple lines.',
' ', '',
' ', '',
' .. py:attribute:: InstAttCls.ca2', ' .. py:attribute:: InstAttCls.ca2',
' :module: target', ' :module: target',
" :value: 'b'", " :value: 'b'",
' ', '',
' Doc comment for InstAttCls.ca2. One line only.', ' Doc comment for InstAttCls.ca2. One line only.',
' ', '',
' ', '',
' .. py:attribute:: InstAttCls.ca3', ' .. py:attribute:: InstAttCls.ca3',
' :module: target', ' :module: target',
" :value: 'c'", " :value: 'c'",
' ', '',
' Docstring for class attribute InstAttCls.ca3.', ' Docstring for class attribute InstAttCls.ca3.',
' ', '',
' ', '',
' .. py:attribute:: InstAttCls.ia1', ' .. py:attribute:: InstAttCls.ia1',
' :module: target', ' :module: target',
' :value: None', ' :value: None',
' ', '',
' Doc comment for instance attribute InstAttCls.ia1', ' Doc comment for instance attribute InstAttCls.ia1',
' ', '',
' ', '',
' .. py:attribute:: InstAttCls.ia2', ' .. py:attribute:: InstAttCls.ia2',
' :module: target', ' :module: target',
' :value: None', ' :value: None',
' ', '',
' Docstring for instance attribute InstAttCls.ia2.', ' Docstring for instance attribute InstAttCls.ia2.',
' ' ''
] ]
# pick up arbitrary attributes # pick up arbitrary attributes
@ -1047,22 +1047,22 @@ def test_instance_attributes(app):
' :module: target', ' :module: target',
'', '',
' Class with documented class and instance attributes.', ' Class with documented class and instance attributes.',
' ', '',
' ', '',
' .. py:attribute:: InstAttCls.ca1', ' .. py:attribute:: InstAttCls.ca1',
' :module: target', ' :module: target',
" :value: 'a'", " :value: 'a'",
' ', '',
' Doc comment for class attribute InstAttCls.ca1.', ' Doc comment for class attribute InstAttCls.ca1.',
' It can have multiple lines.', ' It can have multiple lines.',
' ', '',
' ', '',
' .. py:attribute:: InstAttCls.ia1', ' .. py:attribute:: InstAttCls.ia1',
' :module: target', ' :module: target',
' :value: None', ' :value: None',
' ', '',
' Doc comment for instance attribute InstAttCls.ia1', ' Doc comment for instance attribute InstAttCls.ia1',
' ' ''
] ]
@ -1079,30 +1079,30 @@ def test_slots(app):
'.. py:class:: Bar()', '.. py:class:: Bar()',
' :module: target.slots', ' :module: target.slots',
'', '',
' ', '',
' .. py:attribute:: Bar.attr1', ' .. py:attribute:: Bar.attr1',
' :module: target.slots', ' :module: target.slots',
' ', '',
' docstring of attr1', ' docstring of attr1',
' ', '',
' ', '',
' .. py:attribute:: Bar.attr2', ' .. py:attribute:: Bar.attr2',
' :module: target.slots', ' :module: target.slots',
' ', '',
' docstring of instance attr2', ' docstring of instance attr2',
' ', '',
' ', '',
' .. py:attribute:: Bar.attr3', ' .. py:attribute:: Bar.attr3',
' :module: target.slots', ' :module: target.slots',
' ', '',
'', '',
'.. py:class:: Foo', '.. py:class:: Foo',
' :module: target.slots', ' :module: target.slots',
'', '',
' ', '',
' .. py:attribute:: Foo.attr', ' .. py:attribute:: Foo.attr',
' :module: target.slots', ' :module: target.slots',
' ', '',
] ]
@ -1117,39 +1117,39 @@ def test_enum_class(app):
' :module: target.enum', ' :module: target.enum',
'', '',
' this is enum class', ' this is enum class',
' ', '',
' ', '',
' .. py:method:: EnumCls.say_hello()', ' .. py:method:: EnumCls.say_hello()',
' :module: target.enum', ' :module: target.enum',
' ', '',
' a method says hello to you.', ' a method says hello to you.',
' ', '',
' ', '',
' .. py:attribute:: EnumCls.val1', ' .. py:attribute:: EnumCls.val1',
' :module: target.enum', ' :module: target.enum',
' :value: 12', ' :value: 12',
' ', '',
' doc for val1', ' doc for val1',
' ', '',
' ', '',
' .. py:attribute:: EnumCls.val2', ' .. py:attribute:: EnumCls.val2',
' :module: target.enum', ' :module: target.enum',
' :value: 23', ' :value: 23',
' ', '',
' doc for val2', ' doc for val2',
' ', '',
' ', '',
' .. py:attribute:: EnumCls.val3', ' .. py:attribute:: EnumCls.val3',
' :module: target.enum', ' :module: target.enum',
' :value: 34', ' :value: 34',
' ', '',
' doc for val3', ' doc for val3',
' ', '',
' ', '',
' .. py:attribute:: EnumCls.val4', ' .. py:attribute:: EnumCls.val4',
' :module: target.enum', ' :module: target.enum',
' :value: 34', ' :value: 34',
' ' ''
] ]
# checks for an attribute of EnumClass # checks for an attribute of EnumClass
@ -1161,7 +1161,7 @@ def test_enum_class(app):
' :value: 12', ' :value: 12',
'', '',
' doc for val1', ' doc for val1',
' ' ''
] ]
@ -1178,19 +1178,19 @@ def test_descriptor_class(app):
' :module: target.descriptor', ' :module: target.descriptor',
'', '',
' Descriptor class docstring.', ' Descriptor class docstring.',
' ', '',
' ', '',
' .. py:method:: CustomDataDescriptor.meth()', ' .. py:method:: CustomDataDescriptor.meth()',
' :module: target.descriptor', ' :module: target.descriptor',
' ', '',
' Function.', ' Function.',
' ', '',
'', '',
'.. py:class:: CustomDataDescriptor2(doc)', '.. py:class:: CustomDataDescriptor2(doc)',
' :module: target.descriptor', ' :module: target.descriptor',
'', '',
' Descriptor class with custom metaclass docstring.', ' Descriptor class with custom metaclass docstring.',
' ' '',
] ]
@ -1203,7 +1203,7 @@ def test_autofunction_for_callable(app):
' :module: target.callable', ' :module: target.callable',
'', '',
' A callable object that behaves like a function.', ' A callable object that behaves like a function.',
' ' '',
] ]
@ -1216,7 +1216,7 @@ def test_autofunction_for_method(app):
' :module: target.callable', ' :module: target.callable',
'', '',
' docstring of Callable.method().', ' docstring of Callable.method().',
' ' '',
] ]
@ -1233,39 +1233,39 @@ def test_abstractmethods():
'.. py:class:: Base', '.. py:class:: Base',
' :module: target.abstractmethods', ' :module: target.abstractmethods',
'', '',
' ', '',
' .. py:method:: Base.abstractmeth()', ' .. py:method:: Base.abstractmeth()',
' :module: target.abstractmethods', ' :module: target.abstractmethods',
' :abstractmethod:', ' :abstractmethod:',
' ', '',
' ', '',
' .. py:method:: Base.classmeth()', ' .. py:method:: Base.classmeth()',
' :module: target.abstractmethods', ' :module: target.abstractmethods',
' :abstractmethod:', ' :abstractmethod:',
' :classmethod:', ' :classmethod:',
' ', '',
' ', '',
' .. py:method:: Base.coroutinemeth()', ' .. py:method:: Base.coroutinemeth()',
' :module: target.abstractmethods', ' :module: target.abstractmethods',
' :abstractmethod:', ' :abstractmethod:',
' :async:', ' :async:',
' ', '',
' ', '',
' .. py:method:: Base.meth()', ' .. py:method:: Base.meth()',
' :module: target.abstractmethods', ' :module: target.abstractmethods',
' ', '',
' ', '',
' .. py:method:: Base.prop', ' .. py:method:: Base.prop',
' :module: target.abstractmethods', ' :module: target.abstractmethods',
' :abstractmethod:', ' :abstractmethod:',
' :property:', ' :property:',
' ', '',
' ', '',
' .. py:method:: Base.staticmeth()', ' .. py:method:: Base.staticmeth()',
' :module: target.abstractmethods', ' :module: target.abstractmethods',
' :abstractmethod:', ' :abstractmethod:',
' :staticmethod:', ' :staticmethod:',
' ' '',
] ]
@ -1282,25 +1282,25 @@ def test_partialfunction():
' :module: target.partialfunction', ' :module: target.partialfunction',
'', '',
' docstring of func1', ' docstring of func1',
' ', '',
'', '',
'.. py:function:: func2(b, c)', '.. py:function:: func2(b, c)',
' :module: target.partialfunction', ' :module: target.partialfunction',
'', '',
' docstring of func1', ' docstring of func1',
' ', '',
'', '',
'.. py:function:: func3(c)', '.. py:function:: func3(c)',
' :module: target.partialfunction', ' :module: target.partialfunction',
'', '',
' docstring of func3', ' docstring of func3',
' ', '',
'', '',
'.. py:function:: func4()', '.. py:function:: func4()',
' :module: target.partialfunction', ' :module: target.partialfunction',
'', '',
' docstring of func3', ' docstring of func3',
' ' '',
] ]
@ -1328,7 +1328,7 @@ def test_bound_method():
' :module: target.bound_method', ' :module: target.bound_method',
'', '',
' Method docstring', ' Method docstring',
' ', '',
] ]
@ -1350,29 +1350,29 @@ def test_coroutine():
'.. py:class:: AsyncClass', '.. py:class:: AsyncClass',
' :module: target.coroutine', ' :module: target.coroutine',
'', '',
' ', '',
' .. py:method:: AsyncClass.do_coroutine()', ' .. py:method:: AsyncClass.do_coroutine()',
' :module: target.coroutine', ' :module: target.coroutine',
' :async:', ' :async:',
' ', '',
' A documented coroutine function', ' A documented coroutine function',
' ', '',
' ', '',
' .. py:method:: AsyncClass.do_coroutine2()', ' .. py:method:: AsyncClass.do_coroutine2()',
' :module: target.coroutine', ' :module: target.coroutine',
' :async:', ' :async:',
' :classmethod:', ' :classmethod:',
' ', '',
' A documented coroutine classmethod', ' A documented coroutine classmethod',
' ', '',
' ', '',
' .. py:method:: AsyncClass.do_coroutine3()', ' .. py:method:: AsyncClass.do_coroutine3()',
' :module: target.coroutine', ' :module: target.coroutine',
' :async:', ' :async:',
' :staticmethod:', ' :staticmethod:',
' ', '',
' A documented coroutine staticmethod', ' A documented coroutine staticmethod',
' ', '',
] ]
@ -1384,21 +1384,21 @@ def test_partialmethod(app):
' :module: target.partialmethod', ' :module: target.partialmethod',
'', '',
' An example for partialmethod.', ' An example for partialmethod.',
' ', '',
' refs: https://docs.python.jp/3/library/functools.html#functools.partialmethod', ' refs: https://docs.python.jp/3/library/functools.html#functools.partialmethod',
' ', '',
' ', '',
' .. py:method:: Cell.set_alive()', ' .. py:method:: Cell.set_alive()',
' :module: target.partialmethod', ' :module: target.partialmethod',
' ', '',
' Make a cell alive.', ' Make a cell alive.',
' ', '',
' ', '',
' .. py:method:: Cell.set_state(state)', ' .. py:method:: Cell.set_state(state)',
' :module: target.partialmethod', ' :module: target.partialmethod',
' ', '',
' Update state of cell to *state*.', ' Update state of cell to *state*.',
' ', '',
] ]
options = {"members": None} options = {"members": None}
@ -1414,25 +1414,25 @@ def test_partialmethod_undoc_members(app):
' :module: target.partialmethod', ' :module: target.partialmethod',
'', '',
' An example for partialmethod.', ' An example for partialmethod.',
' ', '',
' refs: https://docs.python.jp/3/library/functools.html#functools.partialmethod', ' refs: https://docs.python.jp/3/library/functools.html#functools.partialmethod',
' ', '',
' ', '',
' .. py:method:: Cell.set_alive()', ' .. py:method:: Cell.set_alive()',
' :module: target.partialmethod', ' :module: target.partialmethod',
' ', '',
' Make a cell alive.', ' Make a cell alive.',
' ', '',
' ', '',
' .. py:method:: Cell.set_dead()', ' .. py:method:: Cell.set_dead()',
' :module: target.partialmethod', ' :module: target.partialmethod',
' ', '',
' ', '',
' .. py:method:: Cell.set_state(state)', ' .. py:method:: Cell.set_state(state)',
' :module: target.partialmethod', ' :module: target.partialmethod',
' ', '',
' Update state of cell to *state*.', ' Update state of cell to *state*.',
' ', '',
] ]
options = {"members": None, options = {"members": None,
@ -1455,48 +1455,48 @@ def test_autodoc_typed_instance_variables(app):
'.. py:class:: Class()', '.. py:class:: Class()',
' :module: target.typed_vars', ' :module: target.typed_vars',
'', '',
' ', '',
' .. py:attribute:: Class.attr1', ' .. py:attribute:: Class.attr1',
' :module: target.typed_vars', ' :module: target.typed_vars',
' :type: int', ' :type: int',
' :value: 0', ' :value: 0',
' ', '',
' ', '',
' .. py:attribute:: Class.attr2', ' .. py:attribute:: Class.attr2',
' :module: target.typed_vars', ' :module: target.typed_vars',
' :type: int', ' :type: int',
' :value: None', ' :value: None',
' ', '',
' ', '',
' .. py:attribute:: Class.attr3', ' .. py:attribute:: Class.attr3',
' :module: target.typed_vars', ' :module: target.typed_vars',
' :type: int', ' :type: int',
' :value: 0', ' :value: 0',
' ', '',
' ', '',
' .. py:attribute:: Class.attr4', ' .. py:attribute:: Class.attr4',
' :module: target.typed_vars', ' :module: target.typed_vars',
' :type: int', ' :type: int',
' :value: None', ' :value: None',
' ', '',
' attr4', ' attr4',
' ', '',
' ', '',
' .. py:attribute:: Class.attr5', ' .. py:attribute:: Class.attr5',
' :module: target.typed_vars', ' :module: target.typed_vars',
' :type: int', ' :type: int',
' :value: None', ' :value: None',
' ', '',
' attr5', ' attr5',
' ', '',
' ', '',
' .. py:attribute:: Class.attr6', ' .. py:attribute:: Class.attr6',
' :module: target.typed_vars', ' :module: target.typed_vars',
' :type: int', ' :type: int',
' :value: None', ' :value: None',
' ', '',
' attr6', ' attr6',
' ', '',
'', '',
'.. py:data:: attr1', '.. py:data:: attr1',
' :module: target.typed_vars', ' :module: target.typed_vars',
@ -1504,7 +1504,7 @@ def test_autodoc_typed_instance_variables(app):
" :value: ''", " :value: ''",
'', '',
' attr1', ' attr1',
' ', '',
'', '',
'.. py:data:: attr2', '.. py:data:: attr2',
' :module: target.typed_vars', ' :module: target.typed_vars',
@ -1512,7 +1512,7 @@ def test_autodoc_typed_instance_variables(app):
' :value: None', ' :value: None',
'', '',
' attr2', ' attr2',
' ', '',
'', '',
'.. py:data:: attr3', '.. py:data:: attr3',
' :module: target.typed_vars', ' :module: target.typed_vars',
@ -1520,7 +1520,7 @@ def test_autodoc_typed_instance_variables(app):
" :value: ''", " :value: ''",
'', '',
' attr3', ' attr3',
' ' '',
] ]
@ -1538,7 +1538,7 @@ def test_autodoc_Annotated(app):
' :module: target.annotated', ' :module: target.annotated',
'', '',
' docstring', ' docstring',
' ' '',
] ]
@ -1557,7 +1557,7 @@ def test_autodoc_for_egged_code(app):
' :value: 1', ' :value: 1',
'', '',
' constant on sample.py', ' constant on sample.py',
' ', '',
'', '',
'.. py:function:: hello(s)', '.. py:function:: hello(s)',
' :module: sample', ' :module: sample',
@ -1580,7 +1580,7 @@ def test_singledispatch():
' :module: target.singledispatch', ' :module: target.singledispatch',
'', '',
' A function for general use.', ' A function for general use.',
' ' '',
] ]
@ -1599,13 +1599,13 @@ def test_singledispatchmethod():
' :module: target.singledispatchmethod', ' :module: target.singledispatchmethod',
'', '',
' docstring', ' docstring',
' ', '',
' ', '',
' .. py:method:: Foo.meth(arg, kwarg=None)', ' .. py:method:: Foo.meth(arg, kwarg=None)',
' Foo.meth(arg: int, kwarg=None)', ' Foo.meth(arg: int, kwarg=None)',
' Foo.meth(arg: str, kwarg=None)', ' Foo.meth(arg: str, kwarg=None)',
' :module: target.singledispatchmethod', ' :module: target.singledispatchmethod',
' ', '',
' A method for general use.', ' A method for general use.',
' ' '',
] ]

View File

@ -31,49 +31,49 @@ def test_autoclass_content_class(app):
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having no __init__, no __new__', ' A class having no __init__, no __new__',
' ', '',
'', '',
'.. py:class:: B()', '.. py:class:: B()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having __init__(no docstring), no __new__', ' A class having __init__(no docstring), no __new__',
' ', '',
'', '',
'.. py:class:: C()', '.. py:class:: C()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having __init__, no __new__', ' A class having __init__, no __new__',
' ', '',
'', '',
'.. py:class:: D', '.. py:class:: D',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having no __init__, __new__(no docstring)', ' A class having no __init__, __new__(no docstring)',
' ', '',
'', '',
'.. py:class:: E', '.. py:class:: E',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having no __init__, __new__', ' A class having no __init__, __new__',
' ', '',
'', '',
'.. py:class:: F()', '.. py:class:: F()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having both __init__ and __new__', ' A class having both __init__ and __new__',
' ', '',
'', '',
'.. py:class:: G()', '.. py:class:: G()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class inherits __init__ without docstring.', ' A class inherits __init__ without docstring.',
' ', '',
'', '',
'.. py:class:: H()', '.. py:class:: H()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class inherits __new__ without docstring.', ' A class inherits __new__ without docstring.',
' ' '',
] ]
@ -91,49 +91,49 @@ def test_autoclass_content_init(app):
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having no __init__, no __new__', ' A class having no __init__, no __new__',
' ', '',
'', '',
'.. py:class:: B()', '.. py:class:: B()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having __init__(no docstring), no __new__', ' A class having __init__(no docstring), no __new__',
' ', '',
'', '',
'.. py:class:: C()', '.. py:class:: C()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' __init__ docstring', ' __init__ docstring',
' ', '',
'', '',
'.. py:class:: D', '.. py:class:: D',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having no __init__, __new__(no docstring)', ' A class having no __init__, __new__(no docstring)',
' ', '',
'', '',
'.. py:class:: E', '.. py:class:: E',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' __new__ docstring', ' __new__ docstring',
' ', '',
'', '',
'.. py:class:: F()', '.. py:class:: F()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' __init__ docstring', ' __init__ docstring',
' ', '',
'', '',
'.. py:class:: G()', '.. py:class:: G()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' __init__ docstring', ' __init__ docstring',
' ', '',
'', '',
'.. py:class:: H()', '.. py:class:: H()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' __new__ docstring', ' __new__ docstring',
' ' '',
] ]
@ -151,59 +151,59 @@ def test_autoclass_content_both(app):
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having no __init__, no __new__', ' A class having no __init__, no __new__',
' ', '',
'', '',
'.. py:class:: B()', '.. py:class:: B()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having __init__(no docstring), no __new__', ' A class having __init__(no docstring), no __new__',
' ', '',
'', '',
'.. py:class:: C()', '.. py:class:: C()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having __init__, no __new__', ' A class having __init__, no __new__',
' ', '',
' __init__ docstring', ' __init__ docstring',
' ', '',
'', '',
'.. py:class:: D', '.. py:class:: D',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having no __init__, __new__(no docstring)', ' A class having no __init__, __new__(no docstring)',
' ', '',
'', '',
'.. py:class:: E', '.. py:class:: E',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having no __init__, __new__', ' A class having no __init__, __new__',
' ', '',
' __new__ docstring', ' __new__ docstring',
' ', '',
'', '',
'.. py:class:: F()', '.. py:class:: F()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class having both __init__ and __new__', ' A class having both __init__ and __new__',
' ', '',
' __init__ docstring', ' __init__ docstring',
' ', '',
'', '',
'.. py:class:: G()', '.. py:class:: G()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class inherits __init__ without docstring.', ' A class inherits __init__ without docstring.',
' ', '',
' __init__ docstring', ' __init__ docstring',
' ', '',
'', '',
'.. py:class:: H()', '.. py:class:: H()',
' :module: target.autoclass_content', ' :module: target.autoclass_content',
'', '',
' A class inherits __new__ without docstring.', ' A class inherits __new__ without docstring.',
' ', '',
' __new__ docstring', ' __new__ docstring',
' ' '',
] ]
@ -217,7 +217,7 @@ def test_autodoc_inherit_docstrings(app):
' :module: target.inheritance', ' :module: target.inheritance',
'', '',
' Inherited function.', ' Inherited function.',
' ' '',
] ]
# disable autodoc_inherit_docstrings # disable autodoc_inherit_docstrings
@ -240,38 +240,38 @@ def test_autodoc_docstring_signature(app):
'.. py:class:: DocstringSig', '.. py:class:: DocstringSig',
' :module: target', ' :module: target',
'', '',
' ', '',
' .. py:method:: DocstringSig.meth(FOO, BAR=1) -> BAZ', ' .. py:method:: DocstringSig.meth(FOO, BAR=1) -> BAZ',
' :module: target', ' :module: target',
' ', '',
' First line of docstring', ' First line of docstring',
' ', '',
' rest of docstring', ' rest of docstring',
' ', '',
' ', '',
' .. py:method:: DocstringSig.meth2()', ' .. py:method:: DocstringSig.meth2()',
' :module: target', ' :module: target',
' ', '',
' First line, no signature', ' First line, no signature',
' Second line followed by indentation::', ' Second line followed by indentation::',
' ', '',
' indented line', ' indented line',
' ', '',
' ', '',
' .. py:method:: DocstringSig.prop1', ' .. py:method:: DocstringSig.prop1',
' :module: target', ' :module: target',
' :property:', ' :property:',
' ', '',
' First line of docstring', ' First line of docstring',
' ', '',
' ', '',
' .. py:method:: DocstringSig.prop2', ' .. py:method:: DocstringSig.prop2',
' :module: target', ' :module: target',
' :property:', ' :property:',
' ', '',
' First line of docstring', ' First line of docstring',
' Second line of docstring', ' Second line of docstring',
' ' '',
] ]
# disable autodoc_docstring_signature # disable autodoc_docstring_signature
@ -282,41 +282,41 @@ def test_autodoc_docstring_signature(app):
'.. py:class:: DocstringSig', '.. py:class:: DocstringSig',
' :module: target', ' :module: target',
'', '',
' ', '',
' .. py:method:: DocstringSig.meth()', ' .. py:method:: DocstringSig.meth()',
' :module: target', ' :module: target',
' ', '',
' meth(FOO, BAR=1) -> BAZ', ' meth(FOO, BAR=1) -> BAZ',
' First line of docstring', ' First line of docstring',
' ', '',
' rest of docstring', ' rest of docstring',
' ', '',
' ', '',
' ', '',
' .. py:method:: DocstringSig.meth2()', ' .. py:method:: DocstringSig.meth2()',
' :module: target', ' :module: target',
' ', '',
' First line, no signature', ' First line, no signature',
' Second line followed by indentation::', ' Second line followed by indentation::',
' ', '',
' indented line', ' indented line',
' ', '',
' ', '',
' .. py:method:: DocstringSig.prop1', ' .. py:method:: DocstringSig.prop1',
' :module: target', ' :module: target',
' :property:', ' :property:',
' ', '',
' DocstringSig.prop1(self)', ' DocstringSig.prop1(self)',
' First line of docstring', ' First line of docstring',
' ', '',
' ', '',
' .. py:method:: DocstringSig.prop2', ' .. py:method:: DocstringSig.prop2',
' :module: target', ' :module: target',
' :property:', ' :property:',
' ', '',
' First line of docstring', ' First line of docstring',
' Second line of docstring', ' Second line of docstring',
' ' '',
] ]
@ -397,13 +397,13 @@ def test_autoclass_content_and_docstring_signature_both(app):
' :module: target.docstring_signature', ' :module: target.docstring_signature',
'', '',
' B(foo, bar, baz)', ' B(foo, bar, baz)',
' ', '',
'', '',
'.. py:class:: C(foo, bar)', '.. py:class:: C(foo, bar)',
' :module: target.docstring_signature', ' :module: target.docstring_signature',
'', '',
' C(foo, bar, baz)', ' C(foo, bar, baz)',
' ', '',
'', '',
'.. py:class:: D(foo, bar, baz)', '.. py:class:: D(foo, bar, baz)',
' :module: target.docstring_signature', ' :module: target.docstring_signature',
@ -439,25 +439,25 @@ def test_mocked_module_imports(app, warning):
' :module: target.need_mocks', ' :module: target.need_mocks',
'', '',
' TestAutodoc docstring.', ' TestAutodoc docstring.',
' ', '',
' ', '',
' .. py:method:: TestAutodoc.decoratedMethod()', ' .. py:method:: TestAutodoc.decoratedMethod()',
' :module: target.need_mocks', ' :module: target.need_mocks',
' ', '',
' TestAutodoc::decoratedMethod docstring', ' TestAutodoc::decoratedMethod docstring',
' ', '',
'', '',
'.. py:function:: decoratedFunction()', '.. py:function:: decoratedFunction()',
' :module: target.need_mocks', ' :module: target.need_mocks',
'', '',
' decoratedFunction docstring', ' decoratedFunction docstring',
' ', '',
'', '',
'.. py:function:: func(arg: missing_module.Class)', '.. py:function:: func(arg: missing_module.Class)',
' :module: target.need_mocks', ' :module: target.need_mocks',
'', '',
' a function takes mocked object as an argument', ' a function takes mocked object as an argument',
' ' '',
] ]
assert warning.getvalue() == '' assert warning.getvalue() == ''
@ -476,22 +476,22 @@ def test_autodoc_typehints_signature(app):
'.. py:class:: Math(s: str, o: object = None)', '.. py:class:: Math(s: str, o: object = None)',
' :module: target.typehints', ' :module: target.typehints',
'', '',
' ', '',
' .. py:method:: Math.decr(a: int, b: int = 1) -> int', ' .. py:method:: Math.decr(a: int, b: int = 1) -> int',
' :module: target.typehints', ' :module: target.typehints',
' ', '',
' ', '',
' .. py:method:: Math.horse(a: str, b: int) -> None', ' .. py:method:: Math.horse(a: str, b: int) -> None',
' :module: target.typehints', ' :module: target.typehints',
' ', '',
' ', '',
' .. py:method:: Math.incr(a: int, b: int = 1) -> int', ' .. py:method:: Math.incr(a: int, b: int = 1) -> int',
' :module: target.typehints', ' :module: target.typehints',
' ', '',
' ', '',
' .. py:method:: Math.nothing() -> None', ' .. py:method:: Math.nothing() -> None',
' :module: target.typehints', ' :module: target.typehints',
' ', '',
'', '',
'.. py:function:: complex_func(arg1: str, arg2: List[int], arg3: Tuple[int, ' '.. py:function:: complex_func(arg1: str, arg2: List[int], arg3: Tuple[int, '
'Union[str, Unknown]] = None, *args: str, **kwargs: str) -> None', 'Union[str, Unknown]] = None, *args: str, **kwargs: str) -> None',
@ -526,22 +526,22 @@ def test_autodoc_typehints_none(app):
'.. py:class:: Math(s, o=None)', '.. py:class:: Math(s, o=None)',
' :module: target.typehints', ' :module: target.typehints',
'', '',
' ', '',
' .. py:method:: Math.decr(a, b=1)', ' .. py:method:: Math.decr(a, b=1)',
' :module: target.typehints', ' :module: target.typehints',
' ', '',
' ', '',
' .. py:method:: Math.horse(a, b)', ' .. py:method:: Math.horse(a, b)',
' :module: target.typehints', ' :module: target.typehints',
' ', '',
' ', '',
' .. py:method:: Math.incr(a, b=1)', ' .. py:method:: Math.incr(a, b=1)',
' :module: target.typehints', ' :module: target.typehints',
' ', '',
' ', '',
' .. py:method:: Math.nothing()', ' .. py:method:: Math.nothing()',
' :module: target.typehints', ' :module: target.typehints',
' ', '',
'', '',
'.. py:function:: complex_func(arg1, arg2, arg3=None, *args, **kwargs)', '.. py:function:: complex_func(arg1, arg2, arg3=None, *args, **kwargs)',
' :module: target.typehints', ' :module: target.typehints',

View File

@ -44,7 +44,7 @@ def test_cut_lines(app):
' :module: target.process_docstring', ' :module: target.process_docstring',
'', '',
' second line', ' second line',
' ' '',
] ]
@ -60,7 +60,7 @@ def test_between(app):
' :module: target.process_docstring', ' :module: target.process_docstring',
'', '',
' second line', ' second line',
' ' '',
] ]
@ -77,5 +77,5 @@ def test_between_exclude(app):
'', '',
' first line', ' first line',
' third line', ' third line',
' ' '',
] ]

View File

@ -40,7 +40,7 @@ def test_private_field_and_private_members(app):
' :module: target.private', ' :module: target.private',
'', '',
' private_function is a docstring().', ' private_function is a docstring().',
' ', '',
' :meta private:', ' :meta private:',
' ' '',
] ]