Merge pull request #6471 from tk0miya/6447_revert_undoc_module_level_variables

Revert "Fix #1063: autodoc: automodule directive handles undocumented module level variables"
This commit is contained in:
Takeshi KOMIYA 2019-06-10 22:25:21 +09:00 committed by GitHub
commit 1eb8e0145c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 4 additions and 39 deletions

View File

@ -7,6 +7,8 @@ Dependencies
Incompatible changes Incompatible changes
-------------------- --------------------
* #6447: autodoc: Stop to generate document for undocumented module variables
Deprecated Deprecated
---------- ----------

View File

@ -549,10 +549,8 @@ class Documenter:
if self.analyzer: if self.analyzer:
attr_docs = self.analyzer.find_attr_docs() attr_docs = self.analyzer.find_attr_docs()
tagorder = self.analyzer.tagorder
else: else:
attr_docs = {} attr_docs = {}
tagorder = {}
# process members and determine which to skip # process members and determine which to skip
for (membername, member) in members: for (membername, member) in members:
@ -582,13 +580,12 @@ class Documenter:
membername in self.options.special_members: membername in self.options.special_members:
keep = has_doc or self.options.undoc_members keep = has_doc or self.options.undoc_members
elif (namespace, membername) in attr_docs: elif (namespace, membername) in attr_docs:
has_doc = bool(attr_docs[namespace, membername])
if want_all and membername.startswith('_'): if want_all and membername.startswith('_'):
# ignore members whose name starts with _ by default # ignore members whose name starts with _ by default
keep = has_doc and self.options.private_members keep = self.options.private_members
else: else:
# keep documented attributes # keep documented attributes
keep = has_doc keep = True
isattr = True isattr = True
elif want_all and membername.startswith('_'): elif want_all and membername.startswith('_'):
# ignore members whose name starts with _ by default # ignore members whose name starts with _ by default
@ -597,8 +594,6 @@ class Documenter:
else: else:
# ignore undocumented members if :undoc-members: is not given # ignore undocumented members if :undoc-members: is not given
keep = has_doc or self.options.undoc_members keep = has_doc or self.options.undoc_members
# module top level item or not
isattr = membername in tagorder
# give the user a chance to decide whether this member # give the user a chance to decide whether this member
# should be skipped # should be skipped
@ -1296,10 +1291,6 @@ class DataDocumenter(ModuleLevelDocumenter):
return self.get_attr(self.parent or self.object, '__module__', None) \ return self.get_attr(self.parent or self.object, '__module__', None) \
or self.modname or self.modname
def get_doc(self, encoding=None, ignore=1):
# type: (str, int) -> List[List[str]]
return []
class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type: ignore class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type: ignore
""" """

View File

@ -1,4 +0,0 @@
#: docstring for CONSTANT1
CONSTANT1 = ""
CONSTANT2 = ""

View File

@ -1689,30 +1689,6 @@ def test_partialmethod(app):
assert list(actual) == expected assert list(actual) == expected
@pytest.mark.usefixtures('setup_test')
def test_module_variables():
options = {"members": None,
"undoc-members": True}
actual = do_autodoc(app, 'module', 'target.module', options)
assert list(actual) == [
'',
'.. py:module:: target.module',
'',
'',
'.. py:data:: CONSTANT1',
' :module: target.module',
" :annotation: = ''",
'',
' docstring for CONSTANT1',
' ',
'',
'.. py:data:: CONSTANT2',
' :module: target.module',
" :annotation: = ''",
'',
]
@pytest.mark.sphinx('html', testroot='ext-autodoc') @pytest.mark.sphinx('html', testroot='ext-autodoc')
def test_autodoc_typehints_signature(app): def test_autodoc_typehints_signature(app):
app.config.autodoc_typehints = "signature" app.config.autodoc_typehints = "signature"