From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2201) id 6CB04388302F; Sat, 12 Nov 2022 14:12:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CB04388302F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668262347; bh=nEIv9RAEc6lwqxf3wyuYbzn7f00izd7hFfXGeUaNdRo=; h=From:To:Subject:Date:From; b=PQwBmsj58DbCdF8k/O02ucULTiQkWQZ6G+mkT79EV3MWRj9gKp/mjme+Uakn3f6VM abarbOPEX8yJMxoRwEM3B+XiUBaNfnXvEaf75e+0KLWn4d0LzHd2qXt3BdRLNQf9Ti ADXyarc1RqtZYI9C31ypoh9aj/28gmzpo2bnWezc= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jon TURNEY To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] makedocbook: Adjust inline whitespace to fix flake8 warnings X-Act-Checkin: newlib-cygwin X-Git-Author: Jon Turney X-Git-Refname: refs/heads/master X-Git-Oldrev: 2521dd48d820326cfa2c3efa8bfde19dec7109e5 X-Git-Newrev: 999925b253882ff4c3c47c9a4b91c5cb0d39e84d Message-Id: <20221112141227.6CB04388302F@sourceware.org> Date: Sat, 12 Nov 2022 14:12:27 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dnewlib-cygwin.git;h=3D999925b2538= 82ff4c3c47c9a4b91c5cb0d39e84d commit 999925b253882ff4c3c47c9a4b91c5cb0d39e84d Author: Jon Turney Date: Tue Nov 1 11:35:51 2022 +0000 makedocbook: Adjust inline whitespace to fix flake8 warnings Diff: --- newlib/doc/chapter-texi2docbook.py | 22 +++---- newlib/doc/makedocbook.py | 115 ++++++++++++++++++---------------= ---- 2 files changed, 68 insertions(+), 69 deletions(-) diff --git a/newlib/doc/chapter-texi2docbook.py b/newlib/doc/chapter-texi2d= ocbook.py index 70ab3c04f..e9904ad00 100755 --- a/newlib/doc/chapter-texi2docbook.py +++ b/newlib/doc/chapter-texi2docbook.py @@ -16,8 +16,8 @@ def main(): first_node =3D True prev_sect =3D False =20 - print ('') - print ('') + print('') + print('') =20 for l in sys.stdin.readlines(): l =3D l.rstrip() @@ -29,27 +29,27 @@ def main(): l =3D l.replace("@node", "", 1) l =3D l.strip() if first_node: - print ('' % l.lower().replace(' ', '_')) + print('' % l.lower().replace(' ', '_')) first_node =3D False else: if prev_sect: - print ('') - print ('
' % l) + print('
') + print('
' % l) prev_sect =3D True elif l.startswith("@chapter "): l =3D l.replace("@chapter ", "", 1) - print ('%s' % l) + print('%s' % l) elif l.startswith("@section "): l =3D l.replace("@section ", "", 1) - print ('%s' % l) + print('%s' % l) elif l.startswith("@include "): l =3D l.replace("@include ", "", 1) l =3D l.replace(".def", ".xml", 1) - print ('' % l.strip()) + print('' % l.strip()) =20 if prev_sect: - print ('
') - print ('
') + print('') + print('
') =20 -if __name__ =3D=3D "__main__" : +if __name__ =3D=3D "__main__": main() diff --git a/newlib/doc/makedocbook.py b/newlib/doc/makedocbook.py index 8a3c31ca6..4de20ef92 100755 --- a/newlib/doc/makedocbook.py +++ b/newlib/doc/makedocbook.py @@ -31,11 +31,11 @@ import lxml.etree import ply.lex as lex import ply.yacc as yacc =20 -rootelement =3D None # root element of the XML tree -refentry =3D None # the current refentry +rootelement =3D None # root element of the XML tree +refentry =3D None # the current refentry verbose =3D 0 =20 -def dump(s, stage, threshold =3D 1): +def dump(s, stage, threshold=3D1): if verbose > threshold: print('*' * 40, file=3Dsys.stderr) print(stage, file=3Dsys.stderr) @@ -49,7 +49,7 @@ def dump(s, stage, threshold =3D 1): =20 def skip_whitespace_and_stars(i, src): =20 - while i < len(src) and (src[i].isspace() or (src[i] =3D=3D '*' and src= [i+1] !=3D '/')): + while i < len(src) and (src[i].isspace() or (src[i] =3D=3D '*' and src= [i + 1] !=3D '/')): i +=3D 1 =20 return i @@ -62,7 +62,7 @@ def comment_contents_generator(src): i =3D 0 =20 while i < len(src) - 2: - if src[i] =3D=3D '\n' and src[i+1] =3D=3D '/' and src[i+2] =3D=3D = '*': + if src[i] =3D=3D '\n' and src[i + 1] =3D=3D '/' and src[i + 2] =3D= =3D '*': i =3D i + 3 =20 i =3D skip_whitespace_and_stars(i, src) @@ -82,7 +82,7 @@ def comment_contents_generator(src): =20 i =3D skip_whitespace_and_stars(i, src) =20 - elif src[i] =3D=3D '*' and src[i+1] =3D=3D '/': + elif src[i] =3D=3D '*' and src[i + 1] =3D=3D '/': i =3D i + 2 # If we have just output \n\n, this adds another blank= line. # This is the only way a double blank line can occur. @@ -177,10 +177,10 @@ def function(c, l): spliton =3D ';' o =3D '' for i in l.splitlines(): - if separator in i: - o +=3D i + ';' - else: - o +=3D i + if separator in i: + o +=3D i + ';' + else: + o +=3D i l =3D o[:-1] else: spliton =3D '\n' @@ -265,7 +265,7 @@ def index(c, l): primary.text =3D l =20 # to validate, it seems we need to maintain refentry elements in a cer= tain order - refentry[:] =3D sorted(refentry, key =3D lambda x: x.tag if isinstance= (x.tag, str) else '') + refentry[:] =3D sorted(refentry, key=3Dlambda x: x.tag if isinstance(x= .tag, str) else '') =20 # adds another alternate refname refnamediv =3D refentry.find('refnamediv') @@ -281,7 +281,7 @@ def index(c, l): print('duplicate refname %s discarded' % l, file=3Dsys.stderr) =20 # to validate, it seems we need to maintain refnamediv elements in a c= ertain order - refnamediv[:] =3D sorted(refnamediv, key =3D lambda x: x.tag) + refnamediv[:] =3D sorted(refnamediv, key=3Dlambda x: x.tag) =20 =20 # SYNOPSIS aka ANSI_SYNOPSIS @@ -378,14 +378,13 @@ def synopsis_for_prototype(funcsynopsis, s): # sscanf, have very complex layout using nested tables and itemized lists,= which # it is best to parse in order to transform correctly. # - def refsect(t, s): refsect =3D lxml.etree.SubElement(refentry, 'refsect1') title =3D lxml.etree.SubElement(refsect, 'title') title.text =3D t.title() =20 if verbose: - print('%s has %d paragraphs' % (t, len(s.split('\n\n'))) , file=3D= sys.stderr) + print('%s has %d paragraphs' % (t, len(s.split('\n\n'))), file=3Ds= ys.stderr) =20 if verbose > 1: dump(s, 'before lexing') @@ -422,25 +421,25 @@ def discarded(c, t): return =20 command_dispatch_dict =3D { - 'FUNCTION' : function, - 'TYPEDEF' : function, # TYPEDEF is not currently used, b= ut described in doc.str - 'INDEX' : index, - 'TRAD_SYNOPSIS' : discarded, # K&R-style synopsis, obsolete and= discarded - 'ANSI_SYNOPSIS' : synopsis, - 'SYNOPSIS' : synopsis, - 'DESCRIPTION' : refsect, - 'RETURNS' : refsect, - 'ERRORS' : refsect, - 'PORTABILITY' : refsect, - 'BUGS' : refsect, - 'WARNINGS' : refsect, - 'SEEALSO' : seealso, - 'NOTES' : refsect, # NOTES is not described in doc.st= r, so is currently discarded by makedoc, but that doesn't seem right - 'QUICKREF' : discarded, # The intent of QUICKREF and MATHR= EF is not obvious, but they don't generate any output currently - 'MATHREF' : discarded, - 'START' : discarded, # a START command is inserted to c= ontain the text before the first command - 'END' : discarded, # an END command is inserted merel= y to terminate the text for the last command in a comment block - 'NEWPAGE' : newpage, + 'FUNCTION': function, + 'TYPEDEF': function, # TYPEDEF is not currently used, but de= scribed in doc.str + 'INDEX': index, + 'TRAD_SYNOPSIS': discarded, # K&R-style synopsis, obsolete and disc= arded + 'ANSI_SYNOPSIS': synopsis, + 'SYNOPSIS': synopsis, + 'DESCRIPTION': refsect, + 'RETURNS': refsect, + 'ERRORS': refsect, + 'PORTABILITY': refsect, + 'BUGS': refsect, + 'WARNINGS': refsect, + 'SEEALSO': seealso, + 'NOTES': refsect, # NOTES is not described in doc.str, so= is currently discarded by makedoc, but that doesn't seem right + 'QUICKREF': discarded, # The intent of QUICKREF and MATHREF is= not obvious, but they don't generate any output currently + 'MATHREF': discarded, + 'START': discarded, # a START command is inserted to contai= n the text before the first command + 'END': discarded, # an END command is inserted merely to = terminate the text for the last command in a comment block + 'NEWPAGE': newpage, } =20 # @@ -455,17 +454,17 @@ def line_markup_convert(p): s =3D s.replace('@@', '@') =20 # escape characters not allowed in XML - s =3D s.replace('&','&') - s =3D s.replace('<','<') - s =3D s.replace('>','>') + s =3D s.replace('&', '&') + s =3D s.replace('<', '<') + s =3D s.replace('>', '>') =20 # convert <> to somecode and <[var]> to # var # also handle nested << <[ ]> >> correctly - s =3D s.replace('<<','') - s =3D s.replace('<[','') - s =3D s.replace(']>','') - s =3D s.replace('>>','') + s =3D s.replace('<<', '') + s =3D s.replace('<[', '') + s =3D s.replace(']>', '') + s =3D s.replace('>>', '') =20 # also convert some simple texinfo markup # convert @emph{foo} to foo @@ -493,18 +492,18 @@ def line_markup_convert(p): # =20 texinfo_commands =3D { - 'ifnottex' : 'IFNOTTEX', - 'end ifnottex' : 'ENDIFNOTTEX', - 'tex' : 'IFTEX', - 'end tex' : 'ENDIFTEX', - 'comment' : 'COMMENT', - 'c ' : 'COMMENT', - 'multitable' : 'MULTICOLUMNTABLE', - 'end multitable' : 'ENDMULTICOLUMNTABLE', - 'headitem' : 'MCT_HEADITEM', - 'tab' : 'MCT_COLUMN_SEPARATOR', - 'item' : 'MCT_ITEM', - } + 'ifnottex': 'IFNOTTEX', + 'end ifnottex': 'ENDIFNOTTEX', + 'tex': 'IFTEX', + 'end tex': 'ENDIFTEX', + 'comment': 'COMMENT', + 'c ': 'COMMENT', + 'multitable': 'MULTICOLUMNTABLE', + 'end multitable': 'ENDMULTICOLUMNTABLE', + 'headitem': 'MCT_HEADITEM', + 'tab': 'MCT_COLUMN_SEPARATOR', + 'item': 'MCT_ITEM', +} =20 # token names tokens =3D [ @@ -575,9 +574,9 @@ def t_BLANKLINE(t): return t =20 def t_eof(t): - if hasattr(t.lexer,'at_eof'): + if hasattr(t.lexer, 'at_eof'): # remove eof flag ready for lexing next input - delattr(t.lexer,'at_eof') + delattr(t.lexer, 'at_eof') t.lexer.lineno =3D 0 return None =20 @@ -787,9 +786,10 @@ def p_multitable(p): colspec =3D '\n'.join(['' % (c) for c in co= lfrac]) header =3D '' + p[2] + '\n' body =3D '' + p[3] + '\n' - p[0] =3D '' += colspec + header + body + '' + p[0] =3D '' = + colspec + header + body + '' parser_verbose(p) =20 + def p_error(t): sys.exit('parse error at line %d, token %s, next token %s' % (t.lineno= , t, parser.token())) =20 @@ -831,10 +831,9 @@ def main(file): # # # - -if __name__ =3D=3D '__main__' : +if __name__ =3D=3D '__main__': options =3D OptionParser() - options.add_option('-v', '--verbose', action=3D'count', dest =3D 'verb= ose', default =3D 0) + options.add_option('-v', '--verbose', action=3D'count', dest=3D'verbos= e', default=3D0) (opts, args) =3D options.parse_args() =20 verbose =3D opts.verbose