Skip to content

Commit

Permalink
Revert "Fix #1063: autodoc: automodule directive handles undocumented…
Browse files Browse the repository at this point in the history
… module level variables"

This reverts commit 69d93c9 (without
CHANGES).
  • Loading branch information
tk0miya committed Jun 10, 2019
1 parent 2289ae0 commit 21be789
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 39 deletions.
13 changes: 2 additions & 11 deletions sphinx/ext/autodoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,8 @@ def filter_members(self, members, want_all):

if self.analyzer:
attr_docs = self.analyzer.find_attr_docs()
tagorder = self.analyzer.tagorder
else:
attr_docs = {}
tagorder = {}

# process members and determine which to skip
for (membername, member) in members:
Expand Down Expand Up @@ -582,13 +580,12 @@ def filter_members(self, members, want_all):
membername in self.options.special_members:
keep = has_doc or self.options.undoc_members
elif (namespace, membername) in attr_docs:
has_doc = bool(attr_docs[namespace, membername])
if want_all and membername.startswith('_'):
# ignore members whose name starts with _ by default
keep = has_doc and self.options.private_members
keep = self.options.private_members
else:
# keep documented attributes
keep = has_doc
keep = True
isattr = True
elif want_all and membername.startswith('_'):
# ignore members whose name starts with _ by default
Expand All @@ -597,8 +594,6 @@ def filter_members(self, members, want_all):
else:
# ignore undocumented members if :undoc-members: is not given
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
# should be skipped
Expand Down Expand Up @@ -1296,10 +1291,6 @@ def get_real_modname(self):
return self.get_attr(self.parent or self.object, '__module__', None) \
or self.modname

def get_doc(self, encoding=None, ignore=1):
# type: (str, int) -> List[List[str]]
return []


class MethodDocumenter(DocstringSignatureMixin, ClassLevelDocumenter): # type: ignore
"""
Expand Down
4 changes: 0 additions & 4 deletions tests/roots/test-ext-autodoc/target/module.py

This file was deleted.

24 changes: 0 additions & 24 deletions tests/test_autodoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1689,30 +1689,6 @@ def test_partialmethod(app):
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')
def test_autodoc_typehints_signature(app):
app.config.autodoc_typehints = "signature"
Expand Down

0 comments on commit 21be789

Please sign in to comment.