|
|
|
@ -13,9 +13,13 @@ |
|
|
|
|
# to speed things significantly |
|
|
|
|
# |
|
|
|
|
|
|
|
|
|
from sources import * |
|
|
|
|
from content import * |
|
|
|
|
from tohtml import * |
|
|
|
|
from sources import * |
|
|
|
|
from content import * |
|
|
|
|
from utils import * |
|
|
|
|
from formatter import * |
|
|
|
|
from tohtml import * |
|
|
|
|
|
|
|
|
|
import utils |
|
|
|
|
|
|
|
|
|
import sys, os, time, string, glob, getopt |
|
|
|
|
|
|
|
|
@ -28,7 +32,7 @@ def file_exists( pathname ): |
|
|
|
|
file.close() |
|
|
|
|
except: |
|
|
|
|
result = None |
|
|
|
|
sys.err.write( pathname + " couldn't be accessed\n" ) |
|
|
|
|
sys.stderr.write( pathname + " couldn't be accessed\n" ) |
|
|
|
|
|
|
|
|
|
return result |
|
|
|
|
|
|
|
|
@ -50,8 +54,7 @@ def make_file_list( args = None ): |
|
|
|
|
else: |
|
|
|
|
newpath = [pathname] |
|
|
|
|
|
|
|
|
|
last = len( file_list ) |
|
|
|
|
file_list[last : last] = newpath |
|
|
|
|
file_list.extend( newpath ) |
|
|
|
|
|
|
|
|
|
if len( file_list ) == 0: |
|
|
|
|
file_list = None |
|
|
|
@ -68,13 +71,24 @@ def usage(): |
|
|
|
|
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 ): |
|
|
|
|
"""main program loop""" |
|
|
|
|
|
|
|
|
|
global output_dir |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
opts, args = getopt.getopt( argv[1:],"h", [ "help" ] ) |
|
|
|
|
opts, args = getopt.getopt( sys.argv[1:], |
|
|
|
|
"ht:o:p:", |
|
|
|
|
[ "help", "title=", "output=", "prefix=" ] ) |
|
|
|
|
|
|
|
|
|
except getopt.GetoptError: |
|
|
|
|
usage() |
|
|
|
@ -86,17 +100,32 @@ def main( argv ): |
|
|
|
|
|
|
|
|
|
# process options |
|
|
|
|
# |
|
|
|
|
project_title = "Project" |
|
|
|
|
project_prefix = None |
|
|
|
|
output_dir = None |
|
|
|
|
|
|
|
|
|
for opt in opts: |
|
|
|
|
if opt[0] in ( "-h", "--help" ): |
|
|
|
|
usage() |
|
|
|
|
sys.exit( 0 ) |
|
|
|
|
|
|
|
|
|
if opt[0] in ( "-t", "--title" ): |
|
|
|
|
project_title = opt[1] |
|
|
|
|
|
|
|
|
|
if opt[0] in ( "-o", "--output" ): |
|
|
|
|
utils.output_dir = opt[1] |
|
|
|
|
|
|
|
|
|
if opt[0] in ( "-p", "--prefix" ): |
|
|
|
|
project_prefix = opt[1] |
|
|
|
|
|
|
|
|
|
check_output( ) |
|
|
|
|
|
|
|
|
|
# create context and processor |
|
|
|
|
source_processor = SourceProcessor() |
|
|
|
|
content_processor = ContentProcessor() |
|
|
|
|
|
|
|
|
|
# retrieve the list of files to process |
|
|
|
|
file_list = make_file_list() |
|
|
|
|
file_list = make_file_list( args ) |
|
|
|
|
for filename in file_list: |
|
|
|
|
source_processor.parse_file( filename ) |
|
|
|
|
content_processor.parse_sources( source_processor ) |
|
|
|
@ -104,7 +133,7 @@ def main( argv ): |
|
|
|
|
# process sections |
|
|
|
|
content_processor.finish() |
|
|
|
|
|
|
|
|
|
formatter = HtmlFormatter( content_processor, "Example", "zz" ) |
|
|
|
|
formatter = HtmlFormatter( content_processor, project_title, project_prefix ) |
|
|
|
|
|
|
|
|
|
formatter.toc_dump() |
|
|
|
|
formatter.index_dump() |
|
|
|
|