Skip to content

Commit d879c2e

Browse files
author
Jonathan Corbet
committed
Merge branch 'mauro' into docs-mw
Mauro says: That's the final series to complete the migration of documentation build: it converts get_feat from Perl to Python. V2 is technically identical to v1: the only difference is that it now uses tools/lib/python/feat to store the library logic. With that, no Sphinx in-kernel extensions use fork anymore to call ancillary scripts: everything is now importing Python methods directly from the libraries. There's nothing special on this conversion: it is a direct translation, almost bug-compatible with the original version (*). (*) I did solve two or three caveats on patch 1. Most of the complexity of the script relies at the logic to produce ReST tables. I do have here on my internal scripts a (somewhat) generic formatter for ReST tables in Python. I was tempted to convert the logic to use it, but, as this could cause regressions, I opted to not do it right now, mainly because the matrix table logic is complex. Also, I'm tempted to modify a little bit the output there, but extra tests are required to see if PDF output would work with complex tables (I remember I had a problem with that in the past). So, I'm postponing such extra cleanup.
2 parents 55fb2d5 + e6bfd69 commit d879c2e

4 files changed

Lines changed: 732 additions & 652 deletions

File tree

Documentation/sphinx/kernel_feat.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@
3434
import codecs
3535
import os
3636
import re
37-
import subprocess
3837
import sys
3938

4039
from docutils import nodes, statemachine
4140
from docutils.statemachine import ViewList
4241
from docutils.parsers.rst import directives, Directive
4342
from sphinx.util.docutils import switch_source_input
4443

44+
srctree = os.path.abspath(os.environ["srctree"])
45+
sys.path.insert(0, os.path.join(srctree, "tools/lib/python"))
46+
47+
from feat.parse_features import ParseFeature # pylint: disable=C0413
48+
4549
def ErrorString(exc): # Shamelessly stolen from docutils
4650
return f'{exc.__class__.__name}: {exc}'
4751

@@ -84,18 +88,16 @@ def run(self):
8488

8589
srctree = os.path.abspath(os.environ["srctree"])
8690

87-
args = [
88-
os.path.join(srctree, 'tools/docs/get_feat.pl'),
89-
'rest',
90-
'--enable-fname',
91-
'--dir',
92-
os.path.join(srctree, 'Documentation', self.arguments[0]),
93-
]
91+
feature_dir = os.path.join(srctree, 'Documentation', self.arguments[0])
9492

95-
if len(self.arguments) > 1:
96-
args.extend(['--arch', self.arguments[1]])
93+
feat = ParseFeature(feature_dir, False, True)
94+
feat.parse()
9795

98-
lines = subprocess.check_output(args, cwd=os.path.dirname(doc.current_source)).decode('utf-8')
96+
if len(self.arguments) > 1:
97+
arch = self.arguments[1]
98+
lines = feat.output_arch_table(arch)
99+
else:
100+
lines = feat.output_matrix()
99101

100102
line_regex = re.compile(r"^\.\. FILE (\S+)$")
101103

0 commit comments

Comments
 (0)