Skip to content

Commit

Permalink
pylint: workaround for 'False positive for "bad-continuation"' bug
Browse files Browse the repository at this point in the history
  pylint-dev/pylint#289 (comment)

Signed-off-by: Markus Heiser <[email protected]>
  • Loading branch information
return42 committed Aug 13, 2018
1 parent 4d8d441 commit 8acdf05
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 55 deletions.
3 changes: 1 addition & 2 deletions linuxdoc/__pkginfo__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ def get_entry_points():
, 'kernel-autodoc = linuxdoc.autodoc:main'
, 'kernel-lintdoc = linuxdoc.lint:main'
, 'kernel-grepdoc = linuxdoc.grep_doc:main'
, ]
, }
, ] , }

# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = [
Expand Down
90 changes: 46 additions & 44 deletions linuxdoc/kernel_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,31 +126,34 @@ def __getitem__(self, group):
#doc_sect = RE(doc_com.pattern + r"([" + doc_special.pattern + r"]?[\w\s]+):(.*)")
# "section header:" names must be unique per function (or struct,union, typedef,
# enum). Additional condition: the header name should have 3 characters at least!
doc_sect = RE(doc_com_section.pattern
+ r"("
+ r"@\w[^:]*" # "@foo: lorem" or
+ r"|" + r"@\w[.\w]+[^:]*" # "@foo.bar: lorem" or
+ r"|" + r"\@\.\.\." # ellipsis "@...: lorem" or
+ r"|" + r"\w[\w\s]+\w" # e.g. "Return: lorem"
+ r")"
+ r":(.*?)\s*$") # this matches also strings like "http://..." (doc_sect_except)

doc_sect_reST = RE(doc_com_section.pattern
+ r"("
+ r"@\w[^:]*" # "@foo: lorem" or
+ r"|" + r"@\w[.\w]+[^:]*" # "@foo.bar: lorem" or
+ r"|" + r"\@\.\.\." # ellipsis "@...: lorem" or
# a tribute to vintage markups, when in reST mode ...
+ r"|description|context|returns?|notes?|examples?|introduction|intro"
+ r")"
+ r":(.*?)\s*$" # this matches also strings like "http://..." (doc_sect_except)
, flags = re.IGNORECASE)

reST_sect = RE(doc_com_section.pattern
+ r"("
r"\w[\w\s]+\w"
+ r")"
+ r":\s*$")
doc_sect = RE(
doc_com_section.pattern
+ r"("
+ r"@\w[^:]*" # "@foo: lorem" or
+ r"|" + r"@\w[.\w]+[^:]*" # "@foo.bar: lorem" or
+ r"|" + r"\@\.\.\." # ellipsis "@...: lorem" or
+ r"|" + r"\w[\w\s]+\w" # e.g. "Return: lorem"
+ r")"
+ r":(.*?)\s*$") # this matches also strings like "http://..." (doc_sect_except)

doc_sect_reST = RE(
doc_com_section.pattern
+ r"("
+ r"@\w[^:]*" # "@foo: lorem" or
+ r"|" + r"@\w[.\w]+[^:]*" # "@foo.bar: lorem" or
+ r"|" + r"\@\.\.\." # ellipsis "@...: lorem" or
# a tribute to vintage markups, when in reST mode ...
+ r"|description|context|returns?|notes?|examples?|introduction|intro"
+ r")"
+ r":(.*?)\s*$" # this matches also strings like "http://..." (doc_sect_except)
, flags = re.IGNORECASE)

reST_sect = RE(
doc_com_section.pattern
+ r"("
r"\w[\w\s]+\w"
+ r")"
+ r":\s*$")

doc_content = RE(doc_com_body.pattern + r"(.*)")
doc_block = RE(doc_com.pattern + r"DOC:\s*(.*)?")
Expand Down Expand Up @@ -2138,17 +2141,17 @@ def state_4(self, line):

elif doc_content.match(line):
cont = doc_content[0]
if (not cont.strip() # dismiss leading newlines
and not self.ctx.contents):
if ( not cont.strip() # dismiss leading newlines
and not self.ctx.contents):
pass
else:
self.ctx.contents += doc_content[0] + "\n"

def state_5(self, line):
u"""state: 5 - gathering documentation outside main block"""

if (self.split_doc_state == 1
and doc_state5_sect.match(line)):
if ( self.split_doc_state == 1
and doc_state5_sect.match(line)):

# First line (split_doc_state 1) needs to be a @parameter
self.ctx.section = self.sect_title(doc_state5_sect[0].strip())
Expand Down Expand Up @@ -2209,9 +2212,9 @@ def process_state3_function(self, line):
elif stripProto.match(line):
self.ctx.prototype += " " + stripProto[0]

if (MACRO_define.search(line)
or "{" in line
or ";" in line ):
if ( MACRO_define.search(line)
or "{" in line
or ";" in line ):

# strip cr&nl, strip C89 comments, strip leading whitespaces
self.ctx.prototype = C89_comments.sub(
Expand All @@ -2220,9 +2223,9 @@ def process_state3_function(self, line):
if SYSCALL_DEFINE.search(self.ctx.prototype):
self.ctx.prototype = self.syscall_munge(self.ctx.prototype)

if (TRACE_EVENT.search(self.ctx.prototype)
or DEFINE_EVENT.search(self.ctx.prototype)
or DEFINE_SINGLE_EVENT.search(self.ctx.prototype) ):
if ( TRACE_EVENT.search(self.ctx.prototype)
or DEFINE_EVENT.search(self.ctx.prototype)
or DEFINE_SINGLE_EVENT.search(self.ctx.prototype) ):
self.ctx.prototype = self.tracepoint_munge(self.ctx.prototype)

self.ctx.prototype = self.ctx.prototype.strip()
Expand Down Expand Up @@ -2900,9 +2903,9 @@ def push_parameter(self, p_name, p_type):
p_name = p_name.strip()
p_type = p_type.strip()

if (self.anon_struct_union
and not p_type
and p_name == "}"):
if ( self.anon_struct_union
and not p_type
and p_name == "}" ):
# ignore the ending }; from anon. struct/union
return

Expand Down Expand Up @@ -2950,10 +2953,9 @@ def push_parameter(self, p_name, p_type):
# also ignore unnamed structs/unions;

if not self.anon_struct_union:
if (not self.ctx.parameterdescs.get(p_name, None)
and not p_name.startswith("#")):

if p_type == "function" or p_type == "enum":
if ( not self.ctx.parameterdescs.get(p_name, None)
and not p_name.startswith("#") ):
if p_type in ("function", "enum"):
self.warn("Function parameter or member '%(p_name)s' not "
"described in '%(decl_name)s'."
, p_name = p_name
Expand Down Expand Up @@ -3011,8 +3013,8 @@ def check_return_section(self, decl_name, return_type):
# Ignore an empty return type (It's a macro) and ignore functions with a
# "void" return type. (But don't ignore "void *")

if (not return_type
or re.match(r"void\s*\w*\s*$", return_type)):
if ( not return_type
or re.match(r"void\s*\w*\s*$", return_type) ):
self.debug("check_return_section(): ignore void")
return

Expand Down
18 changes: 9 additions & 9 deletions linuxdoc/rstKernelDoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ def getParserOptions(self):
, known_attrs = (known_attrs or "").replace(","," ").split()
,)

if ("doc" not in self.options
and opts.man_sect is None):
if ( "doc" not in self.options
and opts.man_sect is None):
opts.man_sect = self.env.config.kernel_doc_mansect

opts.set_defaults()
Expand All @@ -381,11 +381,11 @@ def getParserOptions(self):
opts.skip_preamble = True
opts.skip_epilog = True

if ("doc" not in self.options
and "export" not in self.options
and "internal" not in self.options
and "functions" not in self.options
and "snippets" not in self.options):
if ( "doc" not in self.options
and "export" not in self.options
and "internal" not in self.options
and "functions" not in self.options
and "snippets" not in self.options ):
# if no explicit content is selected, then print all, including all
# DOC sections
opts.use_all_docs = True
Expand Down Expand Up @@ -418,8 +418,8 @@ def getParserOptions(self):
else:
pattern = path.join(kerneldoc.SRCTREE, pattern)

if (not glob.has_magic(pattern)
and not path.lexists(pattern)):
if ( not glob.has_magic(pattern)
and not path.lexists(pattern) ):
# if pattern is a filename (is not a glob pattern) and this file
# does not exists, an error is raised.
raise FaultyOption("file not found: %s" % pattern)
Expand Down

0 comments on commit 8acdf05

Please sign in to comment.