Skip to content

Commit 997b7c8

Browse files
mchehabgregkh
authored andcommitted
docs: kernel_abi.py: use --enable-lineno for get_abi.pl
Just like kernel-doc extension, we need to be able to identify what part of an imported document has issues, as reporting them as: get_abi.pl rest --dir $srctree/Documentation/ABI/obsolete --rst-source:1689: ERROR: Unexpected indentation. Makes a lot harder for someone to fix. It should be noticed that it the line which will be reported is the line where the "What:" definition is, and not the line with actually has an error. Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/d6155ab16fb7631f2fa8e7a770eae72f24bf7cc5.1604042072.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c830fa9 commit 997b7c8

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

Documentation/sphinx/kernel_abi.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import os
3737
import subprocess
3838
import sys
39+
import re
3940

4041
from os import path
4142

@@ -93,7 +94,7 @@ def run(self):
9394

9495
env = doc.settings.env
9596
cwd = path.dirname(doc.current_source)
96-
cmd = "get_abi.pl rest --dir "
97+
cmd = "get_abi.pl rest --enable-lineno --dir "
9798
cmd += self.arguments[0]
9899

99100
srctree = path.abspath(os.environ["srctree"])
@@ -137,7 +138,7 @@ def runCmd(self, cmd, **kwargs):
137138
% (self.name, ErrorString(exc)))
138139
return out
139140

140-
def nestedParse(self, lines, fname):
141+
def nestedParse(self, lines, f):
141142
content = ViewList()
142143
node = nodes.section()
143144

@@ -147,8 +148,17 @@ def nestedParse(self, lines, fname):
147148
code_block += "\n " + l
148149
lines = code_block + "\n\n"
149150

150-
for c, l in enumerate(lines.split("\n")):
151-
content.append(l, fname, c)
151+
line_regex = re.compile("^#define LINENO (\S+)\#([0-9]+)$")
152+
ln = 0
153+
154+
for line in lines.split("\n"):
155+
match = line_regex.search(line)
156+
if match:
157+
f = match.group(1)
158+
# sphinx counts lines from 0
159+
ln = int(match.group(2)) - 1
160+
else:
161+
content.append(line, f, ln)
152162

153163
buf = self.state.memo.title_styles, self.state.memo.section_level, self.state.memo.reporter
154164

0 commit comments

Comments
 (0)