3 # DocBeauty (c) 2003, 2004 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
17 content_processor
= ContentProcessor()
20 def beautify_block( block
):
22 content_processor
.reset()
24 markups
= content_processor
.process_content( block
.content
)
28 for markup
in markups
:
29 text
.extend( markup
.beautify( first
) )
32 # now beautify the documentation "borders" themselves
33 lines
= [ " /*************************************************************************" ]
35 lines
.append( " *" + l
)
42 print "\nDocBeauty 0.1 Usage information\n"
43 print " docbeauty [options] file1 [ file2 ... ]\n"
44 print "using the following options:\n"
45 print " -h : print this page"
46 print " -b : backup original files with the 'orig' extension"
48 print " --backup : same as -b"
52 """main program loop"""
57 opts
, args
= getopt
.getopt( sys
.argv
[1:],
59 [ "help", "backup" ] )
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
)
89 for block
in source_processor
.blocks
:
90 beautify_block( block
)
91 new_name
= filename
+ ".new"
94 file = open( new_name
, "wt" )
95 for block
in source_processor
.blocks
:
96 for line
in block
.lines
:
103 # if called from the command line
105 if __name__
== '__main__':