diff options
Diffstat (limited to 'sphinx/ext/autodoc/__init__.py')
-rw-r--r-- | sphinx/ext/autodoc/__init__.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 41a6731d2..ead3a25fd 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -110,6 +110,20 @@ def bool_option(arg): return True +def merge_special_members_option(options): + # type: (Dict) -> None + """Merge :special-members: option to :members: option.""" + if 'special-members' in options and options['special-members'] is not ALL: + if options.get('members') is ALL: + pass + elif options.get('members'): + for member in options['special-members']: + if member not in options['members']: + options['members'].append(member) + else: + options['members'] = options['special-members'] + + class AutodocReporter(object): """ A reporter replacement that assigns the correct source name @@ -823,6 +837,11 @@ class ModuleDocumenter(Documenter): 'imported-members': bool_option, 'ignore-module-all': bool_option } # type: Dict[unicode, Callable] + def __init__(self, *args): + # type: (Any) -> None + super(ModuleDocumenter, self).__init__(*args) + merge_special_members_option(self.options) + @classmethod def can_document_member(cls, member, membername, isattr, parent): # type: (Any, unicode, bool, Any) -> bool @@ -1075,6 +1094,11 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: 'private-members': bool_option, 'special-members': members_option, } # type: Dict[unicode, Callable] + def __init__(self, *args): + # type: (Any) -> None + super(ClassDocumenter, self).__init__(*args) + merge_special_members_option(self.options) + @classmethod def can_document_member(cls, member, membername, isattr, parent): # type: (Any, unicode, bool, Any) -> bool |