3 # DocBeauty (c) 2003, 2004, 2008 David Turner <david@freetype.org>
5 # This program is used to beautify the documentation comments used
6 # in the FreeType 2 public headers.
15 import sys
, os
, time
, string
, getopt
18 content_processor
= ContentProcessor()
21 def beautify_block( block
):
23 content_processor
.reset()
25 markups
= content_processor
.process_content( block
.content
)
29 for markup
in markups
:
30 text
.extend( markup
.beautify( first
) )
33 # now beautify the documentation "borders" themselves
34 lines
= [" /*************************************************************************"]
36 lines
.append( " *" + l
)
43 print "\nDocBeauty 0.1 Usage information\n"
44 print " docbeauty [options] file1 [file2 ...]\n"
45 print "using the following options:\n"
46 print " -h : print this page"
47 print " -b : backup original files with the 'orig' extension"
49 print " --backup : same as -b"
53 """main program loop"""
58 opts
, args
= getopt
.getopt( sys
.argv
[1:], \
61 except getopt
.GetoptError
:
75 if opt
[0] in ( "-h", "--help" ):
79 if opt
[0] in ( "-b", "--backup" ):
82 # create context and processor
83 source_processor
= SourceProcessor()
85 # retrieve the list of files to process
86 file_list
= make_file_list( args
)
87 for filename
in file_list
:
88 source_processor
.parse_file( filename
)
90 for block
in source_processor
.blocks
:
91 beautify_block( block
)
93 new_name
= filename
+ ".new"
97 file = open( new_name
, "wt" )
98 for block
in source_processor
.blocks
:
99 for line
in block
.lines
:
107 # if called from the command line
109 if __name__
== '__main__':