Commit eeacb716 authored by Quentin Monnet's avatar Quentin Monnet Committed by Daniel Borkmann

bpf: change eBPF helper doc parsing script to allow for smaller indent

Documentation for eBPF helpers can be parsed from bpf.h and eventually
turned into a man page. Commit 6f96674d ("bpf: relax constraints on
formatting for eBPF helper documentation") changed the script used to
parse it, in order to allow for different indent style and to ease the
work for writing documentation for future helpers.

The script currently considers that the first tab can be replaced by 6
to 8 spaces. But the documentation for bpf_fib_lookup() uses a mix of
tabs (for the "Description" part) and of spaces ("Return" part), and
only has 5 space long indent for the latter.

We probably do not want to change the values accepted by the script each
time a new helper gets a new indent style. However, it is worth noting
that with those 5 spaces, the "Description" and "Return" part *look*
aligned in the generated patch and in `git show`, so it is likely other
helper authors will use the same length. Therefore, allow for helper
documentation to use 5 spaces only for the first indent level.
Signed-off-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent b9f672af
...@@ -95,7 +95,7 @@ class HeaderParser(object): ...@@ -95,7 +95,7 @@ class HeaderParser(object):
return capture.group(1) return capture.group(1)
def parse_desc(self): def parse_desc(self):
p = re.compile(' \* ?(?:\t| {6,8})Description$') p = re.compile(' \* ?(?:\t| {5,8})Description$')
capture = p.match(self.line) capture = p.match(self.line)
if not capture: if not capture:
# Helper can have empty description and we might be parsing another # Helper can have empty description and we might be parsing another
...@@ -109,7 +109,7 @@ class HeaderParser(object): ...@@ -109,7 +109,7 @@ class HeaderParser(object):
if self.line == ' *\n': if self.line == ' *\n':
desc += '\n' desc += '\n'
else: else:
p = re.compile(' \* ?(?:\t| {6,8})(?:\t| {8})(.*)') p = re.compile(' \* ?(?:\t| {5,8})(?:\t| {8})(.*)')
capture = p.match(self.line) capture = p.match(self.line)
if capture: if capture:
desc += capture.group(1) + '\n' desc += capture.group(1) + '\n'
...@@ -118,7 +118,7 @@ class HeaderParser(object): ...@@ -118,7 +118,7 @@ class HeaderParser(object):
return desc return desc
def parse_ret(self): def parse_ret(self):
p = re.compile(' \* ?(?:\t| {6,8})Return$') p = re.compile(' \* ?(?:\t| {5,8})Return$')
capture = p.match(self.line) capture = p.match(self.line)
if not capture: if not capture:
# Helper can have empty retval and we might be parsing another # Helper can have empty retval and we might be parsing another
...@@ -132,7 +132,7 @@ class HeaderParser(object): ...@@ -132,7 +132,7 @@ class HeaderParser(object):
if self.line == ' *\n': if self.line == ' *\n':
ret += '\n' ret += '\n'
else: else:
p = re.compile(' \* ?(?:\t| {6,8})(?:\t| {8})(.*)') p = re.compile(' \* ?(?:\t| {5,8})(?:\t| {8})(.*)')
capture = p.match(self.line) capture = p.match(self.line)
if capture: if capture:
ret += capture.group(1) + '\n' ret += capture.group(1) + '\n'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment