33# SPDX-FileCopyrightText: Copyright The SCons Foundation (https://scons.org)
44# SPDX-License-Identifier: MIT
55
6- """Module for handling SCons documentation processing.
6+ """
7+ SCons Documentation Processing module
8+ =====================================
79
810This module parses home-brew XML files that document important SCons
911components. Currently it handles Builders, Environment functions/methods,
1820
1921Builder example:
2022
23+ .. code-block:: xml
24+
2125 <builder name="BUILDER">
2226 <summary>
2327 <para>This is the summary description of an SCons Builder.
2933 interpolated by specifying the &b-link-BUILDER; element.
3034 </para>
3135
32- Unlike normal XML , blank lines are significant in these
36+ Unlike vanilla DocBook , blank lines are significant in these
3337 descriptions and serve to separate paragraphs.
3438 They'll get replaced in DocBook output with appropriate tags
3539 to indicate a new paragraph.
4246
4347Function example:
4448
49+ .. code-block:: xml
50+
4551 <scons_function name="FUNCTION">
4652 <arguments signature="SIGTYPE">
4753 (arg1, arg2, key=value)
7480
7581Construction variable example:
7682
83+ .. code-block:: xml
84+
7785 <cvar name="VARIABLE">
7886 <summary>
7987 <para>This is the summary description of a construction variable.
93101
94102Tool example:
95103
104+ .. code-block:: xml
105+
96106 <tool name="TOOL">
97107 <summary>
98108 <para>This is the summary description of an SCons Tool.
@@ -223,7 +233,7 @@ def addEntity(self, name, uri):
223233 self .entries .append (DoctypeEntity (name , uri ))
224234
225235 def createDoctype (self ):
226- content = '<!DOCTYPE %s [\n ' % self . name
236+ content = f '<!DOCTYPE { self . name } [\n '
227237 for e in self .entries :
228238 content += e .getEntityString ()
229239 content += ']>\n '
@@ -318,7 +328,7 @@ def prettyPrintFile(fpath):
318328
319329 @staticmethod
320330 def decorateWithHeader (root ):
321- root .attrib ["{" + xsi + "}schemaLocation" ] = "%s %s /scons.xsd" % ( dbxsd , dbxsd )
331+ root .attrib ["{" + xsi + "}schemaLocation" ] = f" { dbxsd } { dbxsd } /scons.xsd"
322332 return root
323333
324334 def newXmlTree (self , root ):
@@ -340,22 +350,22 @@ def validateXml(fpath, xmlschema_context):
340350 try :
341351 doc = etree .parse (fpath )
342352 except Exception as e :
343- print ("ERROR: %s fails to parse:" % fpath )
353+ print (f "ERROR: { fpath } fails to parse:" )
344354 print (e )
345355 return False
346356 doc .xinclude ()
347357 try :
348358 TreeFactory .xmlschema .assertValid (doc )
349359 except etree .XMLSchemaValidateError as e :
350- print ("ERROR: %s fails to validate:" % fpath )
360+ print (f "ERROR: { fpath } fails to validate:" )
351361 print (e )
352362 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 } ]" )
354364 print ("Line : %d" % e .error_log .last_error .line )
355365 return False
356366
357367 except Exception as e :
358- print ("ERROR: %s fails to validate:" % fpath )
368+ print (f "ERROR: { fpath } fails to validate:" )
359369 print (e )
360370
361371 return False
@@ -365,14 +375,14 @@ def validateXml(fpath, xmlschema_context):
365375 def findAll (root , tag , ns = None , xp_ctxt = None , nsmap = None ):
366376 expression = ".//{%s}%s" % (nsmap [ns ], tag )
367377 if not ns or not nsmap :
368- expression = ".//%s" % tag
378+ expression = f ".//{ tag } "
369379 return root .findall (expression )
370380
371381 @staticmethod
372382 def findAllChildrenOf (root , tag , ns = None , xp_ctxt = None , nsmap = None ):
373383 expression = "./{%s}%s/*" % (nsmap [ns ], tag )
374384 if not ns or not nsmap :
375- expression = "./%s /*" % tag
385+ expression = f "./{ tag } /*"
376386 return root .findall (expression )
377387
378388 @staticmethod
@@ -495,7 +505,7 @@ def __str__(self):
495505 result = []
496506 for m in re .findall (r'([a-zA-Z/_]+|[^a-zA-Z/_]+)' , s ):
497507 if ' ' in m :
498- m = '"%s"' % m
508+ m = f'" { m } "'
499509 result .append (m )
500510 return ' ' .join (result )
501511 def append (self , data ):
0 commit comments