From 939bbee1c007d307f80c538b2a09ee2632f16655 Mon Sep 17 00:00:00 2001 From: Ankit Dhankhar Date: Sun, 15 Apr 2018 22:35:40 +0200 Subject: [PATCH] [docmaker] Make it work with python3. * src/tools/docmaker (*.py): Use parentheses around arguments of `print'. Remove unused imports. --- src/tools/docmaker/content.py | 12 ++-- src/tools/docmaker/docbeauty.py | 18 +++--- src/tools/docmaker/docmaker.py | 24 ++++---- src/tools/docmaker/sources.py | 10 ++-- src/tools/docmaker/tohtml.py | 100 ++++++++++++++++---------------- 5 files changed, 81 insertions(+), 83 deletions(-) diff --git a/src/tools/docmaker/content.py b/src/tools/docmaker/content.py index c9969dbe5..198780aee 100644 --- a/src/tools/docmaker/content.py +++ b/src/tools/docmaker/content.py @@ -109,7 +109,7 @@ class DocCode: def dump( self, prefix = "", width = 60 ): lines = self.dump_lines( 0, width ) for l in lines: - print prefix + l + print( prefix + l ) def dump_lines( self, margin = 0, width = 60 ): result = [] @@ -139,7 +139,7 @@ class DocPara: def dump( self, prefix = "", width = 60 ): lines = self.dump_lines( 0, width ) for l in lines: - print prefix + l + print( prefix + l ) def dump_lines( self, margin = 0, width = 60 ): cur = "" # current line @@ -243,13 +243,13 @@ class DocField: def dump( self, prefix = "" ): if self.field: - print prefix + self.field + " ::" + print( prefix + self.field + " ::" ) prefix = prefix + "----" first = 1 for p in self.items: if not first: - print "" + print( "" ) p.dump( prefix ) first = 0 @@ -330,10 +330,10 @@ class DocMarkup: return None def dump( self, margin ): - print " " * margin + "<" + self.tag + ">" + print( " " * margin + "<" + self.tag + ">" ) for f in self.fields: f.dump( " " ) - print " " * margin + "" + print( " " * margin + "" ) ################################################################ diff --git a/src/tools/docmaker/docbeauty.py b/src/tools/docmaker/docbeauty.py index 3ddf4a94a..0b021fa6c 100644 --- a/src/tools/docmaker/docbeauty.py +++ b/src/tools/docmaker/docbeauty.py @@ -10,9 +10,7 @@ from sources import * from content import * from utils import * -import utils - -import sys, os, time, string, getopt +import sys, os, string, getopt content_processor = ContentProcessor() @@ -40,13 +38,13 @@ def beautify_block( block ): def usage(): - print "\nDocBeauty 0.1 Usage information\n" - print " docbeauty [options] file1 [file2 ...]\n" - print "using the following options:\n" - print " -h : print this page" - print " -b : backup original files with the 'orig' extension" - print "" - print " --backup : same as -b" + print( "\nDocBeauty 0.1 Usage information\n" ) + print( " docbeauty [options] file1 [file2 ...]\n" ) + print( "using the following options:\n" ) + print( " -h : print this page" ) + print( " -b : backup original files with the 'orig' extension" ) + print( "" ) + print( " --backup : same as -b" ) def main( argv ): diff --git a/src/tools/docmaker/docmaker.py b/src/tools/docmaker/docmaker.py index 253a4d35a..eb49afb0a 100644 --- a/src/tools/docmaker/docmaker.py +++ b/src/tools/docmaker/docmaker.py @@ -31,21 +31,21 @@ from tohtml import * import utils -import sys, os, time, string, glob, getopt +import sys, glob, getopt def usage(): - print "\nDocMaker Usage information\n" - print " docmaker [options] file1 [file2 ...]\n" - print "using the following options:\n" - print " -h : print this page" - print " -t : set project title, as in '-t \"My Project\"'" - print " -o : set output directory, as in '-o mydir'" - print " -p : set documentation prefix, as in '-p ft2'" - print "" - print " --title : same as -t, as in '--title=\"My Project\"'" - print " --output : same as -o, as in '--output=mydir'" - print " --prefix : same as -p, as in '--prefix=ft2'" + print( "\nDocMaker Usage information\n" ) + print( " docmaker [options] file1 [file2 ...]\n" ) + print( "using the following options:\n" ) + print( " -h : print this page" ) + print( " -t : set project title, as in '-t \"My Project\"'" ) + print( " -o : set output directory, as in '-o mydir'" ) + print( " -p : set documentation prefix, as in '-p ft2'" ) + print( "" ) + print( " --title : same as -t, as in '--title=\"My Project\"'" ) + print( " --output : same as -o, as in '--output=mydir'" ) + print( " --prefix : same as -p, as in '--prefix=ft2'" ) def main( argv ): diff --git a/src/tools/docmaker/sources.py b/src/tools/docmaker/sources.py index 2cd5a3379..e3b95e0fa 100644 --- a/src/tools/docmaker/sources.py +++ b/src/tools/docmaker/sources.py @@ -29,7 +29,7 @@ # -import fileinput, re, sys, os, string +import fileinput, re, string ################################################################ @@ -296,10 +296,10 @@ class SourceBlock: # debugging only -- not used in normal operations def dump( self ): if self.content: - print "{{{content start---" + print( "{{{content start---" ) for l in self.content: - print l - print "---content end}}}" + print( l ) + print( "---content end}}}" ) return fmt = "" @@ -307,7 +307,7 @@ class SourceBlock: fmt = repr( self.format.id ) + " " for line in self.lines: - print line + print( line ) ################################################################ diff --git a/src/tools/docmaker/tohtml.py b/src/tools/docmaker/tohtml.py index 7f5ecda41..9f318a2a4 100644 --- a/src/tools/docmaker/tohtml.py +++ b/src/tools/docmaker/tohtml.py @@ -406,7 +406,7 @@ class HtmlFormatter( Formatter ): return string.join( lines, '\n' ) def print_html_items( self, items ): - print self.make_html_items( items ) + print( self.make_html_items( items ) ) def print_html_field( self, field ): if field.name: @@ -414,10 +414,10 @@ class HtmlFormatter( Formatter ): + field.name + "" ) - print self.make_html_items( field.items ) + print( self.make_html_items( field.items ) ) if field.name: - print "" + print( "" ) def html_source_quote( self, line, block_name = None ): result = "" @@ -468,14 +468,14 @@ class HtmlFormatter( Formatter ): return result def print_html_field_list( self, fields ): - print '' + print( '
' ) for field in fields: - print ( '" - print "
' - + field.name - + '' ) + print( '
' + + field.name + + '' ) self.print_html_items( field.items ) - print "
" + print( "" ) + print( "" ) def print_html_markup( self, markup ): table_fields = [] @@ -499,7 +499,7 @@ class HtmlFormatter( Formatter ): # formatting the index # def index_enter( self ): - print self.html_index_header + print( self.html_index_header ) self.index_items = {} def index_name_enter( self, name ): @@ -512,7 +512,7 @@ class HtmlFormatter( Formatter ): count = len( self.block_index ) rows = ( count + self.columns - 1 ) // self.columns - print '' + print( '
' ) for r in range( rows ): line = "" for c in range( self.columns ): @@ -531,15 +531,15 @@ class HtmlFormatter( Formatter ): else: line = line + '' line = line + "" - print line + print( line ) - print "
" + print( "" ) print( index_footer_start + self.file_prefix + "toc.html" + index_footer_end ) - print self.html_footer + print( self.html_footer ) self.index_items = {} @@ -553,25 +553,25 @@ class HtmlFormatter( Formatter ): # formatting the table of contents # def toc_enter( self ): - print self.html_toc_header - print "

Table of Contents

" + print( self.html_toc_header ) + print( "

Table of Contents

" ) def toc_chapter_enter( self, chapter ): - print chapter_header + string.join( chapter.title ) + chapter_inter - print '' + print( chapter_header + string.join( chapter.title ) + chapter_inter ) + print( '
' ) def toc_section_enter( self, section ): - print ( '" + print( "" ) def toc_chapter_exit( self, chapter ): - print "
' ) - print self.make_html_para( section.abstract ) + print( '
' ) + print( self.make_html_para( section.abstract ) ) def toc_section_exit( self, section ): - print "
" - print chapter_footer + print( "" ) + print( chapter_footer ) def toc_index( self, index_filename ): print( chapter_header @@ -583,7 +583,7 @@ class HtmlFormatter( Formatter ): + self.file_prefix + "index.html" + toc_footer_end ) - print self.html_footer + print( self.html_footer ) def toc_dump( self, toc_filename = None, index_filename = None ): if toc_filename == None: @@ -598,11 +598,11 @@ class HtmlFormatter( Formatter ): # formatting sections # def section_enter( self, section ): - print self.html_header + print( self.html_header ) - print ( section_title_header1 + section.name + section_title_header2 - + section.title - + section_title_footer ) + print( section_title_header1 + section.name + section_title_header2 + + section.title + + section_title_footer ) maxwidth = 0 for b in section.blocks.values(): @@ -612,8 +612,8 @@ class HtmlFormatter( Formatter ): width = 70 # XXX magic number if maxwidth > 0: # print section synopsis - print section_synopsis_header - print '' + print( section_synopsis_header ) + print( '
' ) columns = width // maxwidth if columns < 1: @@ -650,17 +650,17 @@ class HtmlFormatter( Formatter ): line = line + '' line = line + "" - print line + print( line ) - print "
" - print section_synopsis_footer + print( "" ) + print( section_synopsis_footer ) - print description_header - print self.make_html_items( section.description ) - print description_footer + print( description_header ) + print( self.make_html_items( section.description ) ) + print( description_footer ) def block_enter( self, block ): - print block_header + print( block_header ) # place html anchor if needed if block.name: @@ -686,28 +686,28 @@ class HtmlFormatter( Formatter ): # + " '" + block.source.filename + "'.\n" ) if header: - print ( header_location_header - + 'Defined in ' + header + '.' - + header_location_footer ) + print( header_location_header + + 'Defined in ' + header + '.' + + header_location_footer ) - print source_header + print( source_header ) for l in block.code: - print self.html_source_quote( l, block.name ) - print source_footer + print( self.html_source_quote( l, block.name ) ) + print( source_footer ) def markup_enter( self, markup, block ): if markup.tag == "description": - print description_header + print( description_header ) else: - print marker_header + markup.tag + marker_inter + print( marker_header + markup.tag + marker_inter ) self.print_html_markup( markup ) def markup_exit( self, markup, block ): if markup.tag == "description": - print description_footer + print( description_footer ) else: - print marker_footer + print( marker_footer ) def block_exit( self, block ): print( block_footer_start + self.file_prefix + "index.html" @@ -715,7 +715,7 @@ class HtmlFormatter( Formatter ): + block_footer_end ) def section_exit( self, section ): - print html_footer + print( html_footer ) def section_dump_all( self ): for section in self.sections: