source: trunk/poppler/freetype-2.1.10/src/tools/docmaker/docmaker.py @ 2

Last change on this file since 2 was 2, checked in by Eugene Romanenko, 16 years ago

First import

File size: 2.7 KB
Line 
1#!/usr/bin/env python
2#
3#  DocMaker (c) 2002, 2004 David Turner <david@freetype.org>
4#
5# This program is a re-write of the original DocMaker took used
6# to generate the API Reference of the FreeType font engine
7# by converting in-source comments into structured HTML.
8#
9# This new version is capable of outputting XML data, as well
10# as accepts more liberal formatting options.
11#
12# It also uses regular expression matching and substitution
13# to speed things significantly.
14#
15
16from sources   import *
17from content   import *
18from utils     import *
19from formatter import *
20from tohtml    import *
21
22import utils
23
24import sys, os, time, string, glob, getopt
25
26
27def usage():
28    print "\nDocMaker Usage information\n"
29    print "  docmaker [options] file1 [ file2 ... ]\n"
30    print "using the following options:\n"
31    print "  -h : print this page"
32    print "  -t : set project title, as in '-t \"My Project\"'"
33    print "  -o : set output directory, as in '-o mydir'"
34    print "  -p : set documentation prefix, as in '-p ft2'"
35    print ""
36    print "  --title  : same as -t, as in '--title=\"My Project\"'"
37    print "  --output : same as -o, as in '--output=mydir'"
38    print "  --prefix : same as -p, as in '--prefix=ft2'"
39   
40
41def main( argv ):
42    """main program loop"""
43
44    global output_dir
45
46    try:
47        opts, args = getopt.getopt( sys.argv[1:],
48                                    "ht:o:p:",
49                                    [ "help", "title=", "output=", "prefix=" ] )
50
51    except getopt.GetoptError:
52        usage()
53        sys.exit( 2 )
54
55    if args == []:
56        usage()
57        sys.exit( 1 )
58
59    # process options
60    #
61    project_title  = "Project"
62    project_prefix = None
63    output_dir     = None
64
65    for opt in opts:
66        if opt[0] in ( "-h", "--help" ):
67            usage()
68            sys.exit( 0 )
69
70        if opt[0] in ( "-t", "--title" ):
71            project_title = opt[1]
72
73        if opt[0] in ( "-o", "--output" ):
74            utils.output_dir = opt[1]
75
76        if opt[0] in ( "-p", "--prefix" ):
77            project_prefix = opt[1]
78
79    check_output( )
80
81    # create context and processor
82    source_processor  = SourceProcessor()
83    content_processor = ContentProcessor()
84
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        content_processor.parse_sources( source_processor )
90       
91    # process sections
92    content_processor.finish()
93
94    formatter = HtmlFormatter( content_processor, project_title, project_prefix )
95
96    formatter.toc_dump()
97    formatter.index_dump()
98    formatter.section_dump_all()
99
100
101# if called from the command line
102#
103if __name__ == '__main__':
104    main( sys.argv )
105
106
107# eof
Note: See TracBrowser for help on using the repository browser.