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:
"""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)
else:
self.directive.result.append('', source, *lineno)
def resolve_name(self, modname: str, parents: Any, path: str, base: Any
) -> Tuple[str, List[str]]:

View File

@ -361,7 +361,7 @@ def test_new_documenter(app):
' :module: target',
'',
' documentation for the integer',
' '
'',
]
@ -420,7 +420,7 @@ def test_py_module(app, warning):
' :module: target',
'',
' Function.',
' '
'',
]
assert ("don't know which module to import for autodocumenting 'Class.meth'"
not in warning.getvalue())
@ -435,7 +435,7 @@ def test_autodoc_decorator(app):
' :module: target.decorator',
'',
' docstring for deco1',
' '
'',
]
actual = do_autodoc(app, 'decorator', 'target.decorator.deco2')
@ -445,7 +445,7 @@ def test_autodoc_decorator(app):
' :module: target.decorator',
'',
' docstring for deco2',
' '
'',
]
@ -458,7 +458,7 @@ def test_autodoc_exception(app):
' :module: target',
'',
' My custom exception.',
' '
'',
]
@ -726,7 +726,7 @@ def test_autodoc_subclass_of_builtin_class(app):
' :module: target',
'',
' Docstring.',
' '
'',
]
@ -785,7 +785,7 @@ def test_autodoc_inner_class(app):
' Bases: :class:`target.Outer.Inner`',
'',
' InnerChild docstring',
' '
'',
]
@ -799,7 +799,7 @@ def test_autodoc_classmethod(app):
' :classmethod:',
'',
' Inherited class method.',
' '
'',
]
@ -813,7 +813,7 @@ def test_autodoc_staticmethod(app):
' :staticmethod:',
'',
' Inherited static method.',
' '
'',
]
@ -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'.",
' When the time tuple is not present, current time as returned by localtime()',
' is used.',
' '
'',
]
@ -946,7 +946,7 @@ def test_autodoc_module_scope(app):
' :value: <_io.StringIO object>',
'',
' should be documented as well - süß',
' '
'',
]
@ -962,7 +962,7 @@ def test_autodoc_class_scope(app):
' :value: <_io.StringIO object>',
'',
' should be documented as well - süß',
' '
'',
]
@ -1190,7 +1190,7 @@ def test_descriptor_class(app):
' :module: target.descriptor',
'',
' Descriptor class with custom metaclass docstring.',
' '
'',
]
@ -1203,7 +1203,7 @@ def test_autofunction_for_callable(app):
' :module: target.callable',
'',
' A callable object that behaves like a function.',
' '
'',
]
@ -1216,7 +1216,7 @@ def test_autofunction_for_method(app):
' :module: target.callable',
'',
' docstring of Callable.method().',
' '
'',
]
@ -1265,7 +1265,7 @@ def test_abstractmethods():
' :module: target.abstractmethods',
' :abstractmethod:',
' :staticmethod:',
' '
'',
]
@ -1300,7 +1300,7 @@ def test_partialfunction():
' :module: target.partialfunction',
'',
' docstring of func3',
' '
'',
]
@ -1520,7 +1520,7 @@ def test_autodoc_typed_instance_variables(app):
" :value: ''",
'',
' attr3',
' '
'',
]
@ -1538,7 +1538,7 @@ def test_autodoc_Annotated(app):
' :module: target.annotated',
'',
' docstring',
' '
'',
]
@ -1580,7 +1580,7 @@ def test_singledispatch():
' :module: target.singledispatch',
'',
' A function for general use.',
' '
'',
]
@ -1607,5 +1607,5 @@ def test_singledispatchmethod():
' :module: target.singledispatchmethod',
'',
' A method for general use.',
' '
'',
]

View File

@ -73,7 +73,7 @@ def test_autoclass_content_class(app):
' :module: target.autoclass_content',
'',
' A class inherits __new__ without docstring.',
' '
'',
]
@ -133,7 +133,7 @@ def test_autoclass_content_init(app):
' :module: target.autoclass_content',
'',
' __new__ docstring',
' '
'',
]
@ -203,7 +203,7 @@ def test_autoclass_content_both(app):
' A class inherits __new__ without docstring.',
'',
' __new__ docstring',
' '
'',
]
@ -217,7 +217,7 @@ def test_autodoc_inherit_docstrings(app):
' :module: target.inheritance',
'',
' Inherited function.',
' '
'',
]
# disable autodoc_inherit_docstrings
@ -271,7 +271,7 @@ def test_autodoc_docstring_signature(app):
'',
' First line of docstring',
' Second line of docstring',
' '
'',
]
# disable autodoc_docstring_signature
@ -316,7 +316,7 @@ def test_autodoc_docstring_signature(app):
'',
' First line of docstring',
' Second line of docstring',
' '
'',
]
@ -457,7 +457,7 @@ def test_mocked_module_imports(app, warning):
' :module: target.need_mocks',
'',
' a function takes mocked object as an argument',
' '
'',
]
assert warning.getvalue() == ''

View File

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

View File

@ -42,5 +42,5 @@ def test_private_field_and_private_members(app):
' private_function is a docstring().',
'',
' :meta private:',
' '
'',
]