eric4-doc.py

changeset 12
1d8dd9706f46
parent 0
de9c2efb9d02
child 13
1af94a91f439
equal deleted inserted replaced
11:b0996e4a289e 12:1d8dd9706f46
1 #!/usr/bin/env python 1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*- 2 # -*- coding: utf-8 -*-
3 3
4 # Copyright (c) 2003 - 2009 Detlev Offenbach <detlev@die-offenbachs.de> 4 # Copyright (c) 2003 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
5 # 5 #
6 6
35 Function to print some usage information. 35 Function to print some usage information.
36 36
37 It prints a reference of all commandline parameters that may 37 It prints a reference of all commandline parameters that may
38 be used and ends the application. 38 be used and ends the application.
39 """ 39 """
40 print "eric4-doc" 40 print("eric4-doc")
41 print 41 print()
42 print "Copyright (c) 2003 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>." 42 print("Copyright (c) 2003 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>.")
43 print 43 print()
44 print "Usage:" 44 print("Usage:")
45 print 45 print()
46 print " eric4-doc [options] files..." 46 print(" eric4-doc [options] files...")
47 print 47 print()
48 print "where files can be either python modules, package" 48 print("where files can be either python modules, package")
49 print "directories or ordinary directories." 49 print("directories or ordinary directories.")
50 print 50 print()
51 print "Options:" 51 print("Options:")
52 print 52 print()
53 print " -c filename or --style-sheet=filename" 53 print(" -c filename or --style-sheet=filename")
54 print " Specify a CSS style sheet file to be used." 54 print(" Specify a CSS style sheet file to be used.")
55 print " -e or --noempty" 55 print(" -e or --noempty")
56 print " Don't include empty modules." 56 print(" Don't include empty modules.")
57 print " -h or --help" 57 print(" -h or --help")
58 print " Show this help and exit." 58 print(" Show this help and exit.")
59 print " -i or --noindex" 59 print(" -i or --noindex")
60 print " Don't generate index files." 60 print(" Don't generate index files.")
61 print " -o directory or --outdir=directory" 61 print(" -o directory or --outdir=directory")
62 print " Generate files in the named directory." 62 print(" Generate files in the named directory.")
63 print " -R, -r or --recursive" 63 print(" -R, -r or --recursive")
64 print " Perform a recursive search for Python files." 64 print(" Perform a recursive search for Python files.")
65 print " -t ext or --extension=ext" 65 print(" -t ext or --extension=ext")
66 print " Add the given extension to the list of file extensions." 66 print(" Add the given extension to the list of file extensions.")
67 print " This option may be given multiple times." 67 print(" This option may be given multiple times.")
68 print " -V or --version" 68 print(" -V or --version")
69 print " Show version information and exit." 69 print(" Show version information and exit.")
70 print " -x directory or --exclude=directory" 70 print(" -x directory or --exclude=directory")
71 print " Specify a directory basename to be excluded." 71 print(" Specify a directory basename to be excluded.")
72 print " This option may be repeated multiple times." 72 print(" This option may be repeated multiple times.")
73 print " --exclude-file=pattern" 73 print(" --exclude-file=pattern")
74 print " Specify a filename pattern of files to be excluded." 74 print(" Specify a filename pattern of files to be excluded.")
75 print " This option may be repeated multiple times." 75 print(" This option may be repeated multiple times.")
76 print 76 print()
77 print " --body-color=color" 77 print(" --body-color=color")
78 print " Specify the text color." 78 print(" Specify the text color.")
79 print " --body-background-color=color" 79 print(" --body-background-color=color")
80 print " Specify the text background color." 80 print(" Specify the text background color.")
81 print " --l1header-color=color" 81 print(" --l1header-color=color")
82 print " Specify the text color of level 1 headers." 82 print(" Specify the text color of level 1 headers.")
83 print " --l1header-background-color=color" 83 print(" --l1header-background-color=color")
84 print " Specify the text background color of level 1 headers." 84 print(" Specify the text background color of level 1 headers.")
85 print " --l2header-color=color" 85 print(" --l2header-color=color")
86 print " Specify the text color of level 2 headers." 86 print(" Specify the text color of level 2 headers.")
87 print " --l2header-background-color=color" 87 print(" --l2header-background-color=color")
88 print " Specify the text background color of level 2 headers." 88 print(" Specify the text background color of level 2 headers.")
89 print " --cfheader-color=color" 89 print(" --cfheader-color=color")
90 print " Specify the text color of class and function headers." 90 print(" Specify the text color of class and function headers.")
91 print " --cfheader-background-color=color" 91 print(" --cfheader-background-color=color")
92 print " Specify the text background color of class and function headers." 92 print(" Specify the text background color of class and function headers.")
93 print " --link-color=color" 93 print(" --link-color=color")
94 print " Specify the text color of hyperlinks." 94 print(" Specify the text color of hyperlinks.")
95 print 95 print()
96 print " --create-qhp" 96 print(" --create-qhp")
97 print " Enable generation of QtHelp files." 97 print(" Enable generation of QtHelp files.")
98 print " --qhp-outdir=directory" 98 print(" --qhp-outdir=directory")
99 print " Generate QtHelp files in the named directory." 99 print(" Generate QtHelp files in the named directory.")
100 print " --qhp-namespace=namespace" 100 print(" --qhp-namespace=namespace")
101 print " Use the given namespace (mandatory)." 101 print(" Use the given namespace (mandatory).")
102 print " --qhp-virtualfolder=folder" 102 print(" --qhp-virtualfolder=folder")
103 print " Use the given virtual folder (mandatory)." 103 print(" Use the given virtual folder (mandatory).")
104 print " The virtual folder must not contain '/'." 104 print(" The virtual folder must not contain '/'.")
105 print " --qhp-filtername=name" 105 print(" --qhp-filtername=name")
106 print " Use the given name for the custom filter." 106 print(" Use the given name for the custom filter.")
107 print " --qhp-filterattribs=attributes" 107 print(" --qhp-filterattribs=attributes")
108 print " Add the given attributes to the filter list." 108 print(" Add the given attributes to the filter list.")
109 print " Attributes must be separated by ':'." 109 print(" Attributes must be separated by ':'.")
110 print " --qhp-title=title" 110 print(" --qhp-title=title")
111 print " Use this as the title for the generated help (mandatory)." 111 print(" Use this as the title for the generated help (mandatory).")
112 print " --create-qhc" 112 print(" --create-qhc")
113 print " Enable generation of QtHelp Collection files." 113 print(" Enable generation of QtHelp Collection files.")
114 sys.exit(1) 114 sys.exit(1)
115 115
116 def version(): 116 def version():
117 """ 117 """
118 Function to show the version information. 118 Function to show the version information.
119 """ 119 """
120 print \ 120 print("""eric4-doc %s
121 """eric4-doc %s
122 121
123 Eric4 API documentation generator. 122 Eric4 API documentation generator.
124 123
125 Copyright (c) 2003-2009 Detlev Offenbach <detlev@die-offenbachs.de> 124 Copyright (c) 2003-2009 Detlev Offenbach <detlev@die-offenbachs.de>
126 This is free software; see the LICENSE.GPL3 for copying conditions. 125 This is free software; see the LICENSE.GPL3 for copying conditions.
127 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A 126 There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
128 PARTICULAR PURPOSE.""" % Version 127 PARTICULAR PURPOSE.""" % Version)
129 sys.exit(1) 128 sys.exit(1)
130 129
131 def main(): 130 def main():
132 """ 131 """
133 Main entry point into the application. 132 Main entry point into the application.
147 "link-color=", 146 "link-color=",
148 "create-qhp", "qhp-outdir=", "qhp-namespace=", 147 "create-qhp", "qhp-outdir=", "qhp-namespace=",
149 "qhp-virtualfolder=", "qhp-filtername=", "qhp-filterattribs=", 148 "qhp-virtualfolder=", "qhp-filtername=", "qhp-filterattribs=",
150 "qhp-title=", "create-qhc", 149 "qhp-title=", "create-qhc",
151 ]) 150 ])
152 except getopt.error, e: 151 except getopt.error as e:
153 usage() 152 usage()
154 153
155 excludeDirs = ["CVS", ".svn", "_svn", ".ropeproject", "_ropeproject", 154 excludeDirs = ["CVS", ".svn", "_svn", ".ropeproject", "_ropeproject",
156 ".eric4project", "_eric4project", "dist", "build", "doc", "docs"] 155 ".eric4project", "_eric4project", "dist", "build", "doc", "docs"]
157 excludePatterns = [] 156 excludePatterns = []
344 try: 343 try:
345 module = Utilities.ModuleParser.readModule(file, basename = basename, 344 module = Utilities.ModuleParser.readModule(file, basename = basename,
346 inpackage = inpackage, extensions = supportedExtensions) 345 inpackage = inpackage, extensions = supportedExtensions)
347 moduleDocument = ModuleDocument(module, colors, stylesheet) 346 moduleDocument = ModuleDocument(module, colors, stylesheet)
348 doc = moduleDocument.genDocument() 347 doc = moduleDocument.genDocument()
349 except IOError, v: 348 except IOError as v:
350 sys.stderr.write("%s error: %s\n" % (file, v[1])) 349 sys.stderr.write("%s error: %s\n" % (file, v[1]))
351 continue 350 continue
352 except ImportError, v: 351 except ImportError as v:
353 sys.stderr.write("%s error: %s\n" % (file, v)) 352 sys.stderr.write("%s error: %s\n" % (file, v))
354 continue 353 continue
355 354
356 input = input + 1 355 input = input + 1
357 356
369 and moduleDocument.isEmpty(): 368 and moduleDocument.isEmpty():
370 continue 369 continue
371 370
372 # generate output 371 # generate output
373 try: 372 try:
374 out = open(f, "wb") 373 out = open(f, "w")
375 out.write(doc) 374 out.write(doc)
376 out.close() 375 out.close()
377 except IOError, v: 376 except IOError as v:
378 sys.stderr.write("%s error: %s\n" % (file, v[1])) 377 sys.stderr.write("%s error: %s\n" % (file, v[1]))
379 else: 378 else:
380 sys.stdout.write("%s ok\n" % f) 379 sys.stdout.write("%s ok\n" % f)
381 380
382 output = output + 1 381 output = output + 1

eric ide

mercurial