mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
refactor: autodoc: Check special-member or not using regexp
This commit is contained in:
parent
46f0b3063d
commit
59f68baddd
@ -61,6 +61,7 @@ py_ext_sig_re = re.compile(
|
||||
(?:\s* -> \s* (.*))? # return annotation
|
||||
)? $ # and nothing more
|
||||
''', re.VERBOSE)
|
||||
special_member_re = re.compile(r'^__\S+__$')
|
||||
|
||||
|
||||
def identity(x: Any) -> Any:
|
||||
@ -674,8 +675,7 @@ class Documenter:
|
||||
elif self.options.exclude_members and membername in self.options.exclude_members:
|
||||
# remove members given by exclude-members
|
||||
keep = False
|
||||
elif want_all and membername.startswith('__') and \
|
||||
membername.endswith('__') and len(membername) > 4:
|
||||
elif want_all and special_member_re.match(membername):
|
||||
# special __methods__
|
||||
if self.options.special_members and membername in self.options.special_members:
|
||||
if membername == '__doc__':
|
||||
|
Loading…
Reference in New Issue
Block a user