Ignore the default docstring text for __init__.

If no docstring is specified for a constructor, Python usually pre-fills
a standard text - "Initialize self. See help(type(self))".

We don't need this default text in our plugins documentation.
This commit is contained in:
Fabio Manganiello 2023-09-30 13:29:49 +02:00
parent d030e2b8c7
commit c82f7bbfbe
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -99,6 +99,7 @@ class DocstringParser:
_param_doc_re = re.compile(r"^:param\s+(?P<name>[\w_]+):\s+(?P<doc>.*)$")
_type_doc_re = re.compile(r"^:type\s+[\w_]+:.*$")
_return_doc_re = re.compile(r"^:return:\s+(?P<doc>.*)$")
_default_docstring = re.compile(r"^Initialize self. See help")
def __init__(
self,
@ -164,6 +165,10 @@ class DocstringParser:
ctx.state = ParseState.TYPE
return
# Ignore the default constructor docstring
if cls._default_docstring.match(line):
return
# Update the return type docstring if required
m = cls._return_doc_re.match(line)
if m or (ctx.state == ParseState.RETURN and cls._is_continuation_line(line)):