Skip to content

Commit eeacb71

Browse files
qmonnetborkmann
authored andcommitted
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 6f96674 ("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: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent b9f672a commit eeacb71

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎scripts/bpf_helpers_doc.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def parse_proto(self):
9595
return capture.group(1)
9696

9797
def parse_desc(self):
98-
p = re.compile(' \* ?(?:\t| {6,8})Description$')
98+
p = re.compile(' \* ?(?:\t| {5,8})Description$')
9999
capture = p.match(self.line)
100100
if not capture:
101101
# Helper can have empty description and we might be parsing another
@@ -109,7 +109,7 @@ def parse_desc(self):
109109
if self.line == ' *\n':
110110
desc += '\n'
111111
else:
112-
p = re.compile(' \* ?(?:\t| {6,8})(?:\t| {8})(.*)')
112+
p = re.compile(' \* ?(?:\t| {5,8})(?:\t| {8})(.*)')
113113
capture = p.match(self.line)
114114
if capture:
115115
desc += capture.group(1) + '\n'
@@ -118,7 +118,7 @@ def parse_desc(self):
118118
return desc
119119

120120
def parse_ret(self):
121-
p = re.compile(' \* ?(?:\t| {6,8})Return$')
121+
p = re.compile(' \* ?(?:\t| {5,8})Return$')
122122
capture = p.match(self.line)
123123
if not capture:
124124
# Helper can have empty retval and we might be parsing another
@@ -132,7 +132,7 @@ def parse_ret(self):
132132
if self.line == ' *\n':
133133
ret += '\n'
134134
else:
135-
p = re.compile(' \* ?(?:\t| {6,8})(?:\t| {8})(.*)')
135+
p = re.compile(' \* ?(?:\t| {5,8})(?:\t| {8})(.*)')
136136
capture = p.match(self.line)
137137
if capture:
138138
ret += capture.group(1) + '\n'

0 commit comments

Comments
 (0)