3
3
# SPDX-FileCopyrightText: Copyright The SCons Foundation (https://scons.org)
4
4
# SPDX-License-Identifier: MIT
5
5
6
- """Module for handling SCons documentation processing.
6
+ """
7
+ SCons Documentation Processing module
8
+ =====================================
7
9
8
10
This module parses home-brew XML files that document important SCons
9
11
components. Currently it handles Builders, Environment functions/methods,
18
20
19
21
Builder example:
20
22
23
+ .. code-block:: xml
24
+
21
25
<builder name="BUILDER">
22
26
<summary>
23
27
<para>This is the summary description of an SCons Builder.
29
33
interpolated by specifying the &b-link-BUILDER; element.
30
34
</para>
31
35
32
- Unlike normal XML , blank lines are significant in these
36
+ Unlike vanilla DocBook , blank lines are significant in these
33
37
descriptions and serve to separate paragraphs.
34
38
They'll get replaced in DocBook output with appropriate tags
35
39
to indicate a new paragraph.
42
46
43
47
Function example:
44
48
49
+ .. code-block:: xml
50
+
45
51
<scons_function name="FUNCTION">
46
52
<arguments signature="SIGTYPE">
47
53
(arg1, arg2, key=value)
74
80
75
81
Construction variable example:
76
82
83
+ .. code-block:: xml
84
+
77
85
<cvar name="VARIABLE">
78
86
<summary>
79
87
<para>This is the summary description of a construction variable.
93
101
94
102
Tool example:
95
103
104
+ .. code-block:: xml
105
+
96
106
<tool name="TOOL">
97
107
<summary>
98
108
<para>This is the summary description of an SCons Tool.
@@ -223,7 +233,7 @@ def addEntity(self, name, uri):
223
233
self .entries .append (DoctypeEntity (name , uri ))
224
234
225
235
def createDoctype (self ):
226
- content = '<!DOCTYPE %s [\n ' % self . name
236
+ content = f '<!DOCTYPE { self . name } [\n '
227
237
for e in self .entries :
228
238
content += e .getEntityString ()
229
239
content += ']>\n '
@@ -318,7 +328,7 @@ def prettyPrintFile(fpath):
318
328
319
329
@staticmethod
320
330
def decorateWithHeader (root ):
321
- root .attrib ["{" + xsi + "}schemaLocation" ] = "%s %s /scons.xsd" % ( dbxsd , dbxsd )
331
+ root .attrib ["{" + xsi + "}schemaLocation" ] = f" { dbxsd } { dbxsd } /scons.xsd"
322
332
return root
323
333
324
334
def newXmlTree (self , root ):
@@ -340,22 +350,22 @@ def validateXml(fpath, xmlschema_context):
340
350
try :
341
351
doc = etree .parse (fpath )
342
352
except Exception as e :
343
- print ("ERROR: %s fails to parse:" % fpath )
353
+ print (f "ERROR: { fpath } fails to parse:" )
344
354
print (e )
345
355
return False
346
356
doc .xinclude ()
347
357
try :
348
358
TreeFactory .xmlschema .assertValid (doc )
349
359
except etree .XMLSchemaValidateError as e :
350
- print ("ERROR: %s fails to validate:" % fpath )
360
+ print (f "ERROR: { fpath } fails to validate:" )
351
361
print (e )
352
362
print (e .error_log .last_error .message )
353
- print ("In file: [%s]" % e .error_log .last_error .filename )
363
+ print (f "In file: [{ e .error_log .last_error .filename } ]" )
354
364
print ("Line : %d" % e .error_log .last_error .line )
355
365
return False
356
366
357
367
except Exception as e :
358
- print ("ERROR: %s fails to validate:" % fpath )
368
+ print (f "ERROR: { fpath } fails to validate:" )
359
369
print (e )
360
370
361
371
return False
@@ -365,14 +375,14 @@ def validateXml(fpath, xmlschema_context):
365
375
def findAll (root , tag , ns = None , xp_ctxt = None , nsmap = None ):
366
376
expression = ".//{%s}%s" % (nsmap [ns ], tag )
367
377
if not ns or not nsmap :
368
- expression = ".//%s" % tag
378
+ expression = f ".//{ tag } "
369
379
return root .findall (expression )
370
380
371
381
@staticmethod
372
382
def findAllChildrenOf (root , tag , ns = None , xp_ctxt = None , nsmap = None ):
373
383
expression = "./{%s}%s/*" % (nsmap [ns ], tag )
374
384
if not ns or not nsmap :
375
- expression = "./%s /*" % tag
385
+ expression = f "./{ tag } /*"
376
386
return root .findall (expression )
377
387
378
388
@staticmethod
@@ -495,7 +505,7 @@ def __str__(self):
495
505
result = []
496
506
for m in re .findall (r'([a-zA-Z/_]+|[^a-zA-Z/_]+)' , s ):
497
507
if ' ' in m :
498
- m = '"%s"' % m
508
+ m = f'" { m } "'
499
509
result .append (m )
500
510
return ' ' .join (result )
501
511
def append (self , data ):
0 commit comments