36 It prints a reference of all commandline parameters that may |
36 It prints a reference of all commandline parameters that may |
37 be used and ends the application. |
37 be used and ends the application. |
38 """ |
38 """ |
39 print("eric5_doc") |
39 print("eric5_doc") |
40 print() |
40 print() |
41 print("Copyright (c) 2003 - 2013 Detlev Offenbach <detlev@die-offenbachs.de>.") |
41 print("Copyright (c) 2003 - 2013 Detlev Offenbach" |
|
42 " <detlev@die-offenbachs.de>.") |
42 print() |
43 print() |
43 print("Usage:") |
44 print("Usage:") |
44 print() |
45 print() |
45 print(" eric5_doc [options] files...") |
46 print(" eric5_doc [options] files...") |
46 print() |
47 print() |
89 print(" --l2header-background-color=color") |
90 print(" --l2header-background-color=color") |
90 print(" Specify the text background color of level 2 headers.") |
91 print(" Specify the text background color of level 2 headers.") |
91 print(" --cfheader-color=color") |
92 print(" --cfheader-color=color") |
92 print(" Specify the text color of class and function headers.") |
93 print(" Specify the text color of class and function headers.") |
93 print(" --cfheader-background-color=color") |
94 print(" --cfheader-background-color=color") |
94 print(" Specify the text background color of class and function headers.") |
95 print(" Specify the text background color of class and" |
|
96 " function headers.") |
95 print(" --link-color=color") |
97 print(" --link-color=color") |
96 print(" Specify the text color of hyperlinks.") |
98 print(" Specify the text color of hyperlinks.") |
97 print() |
99 print() |
98 print(" --create-qhp") |
100 print(" --create-qhp") |
99 print(" Enable generation of QtHelp files.") |
101 print(" Enable generation of QtHelp files.") |
153 ]) |
155 ]) |
154 except getopt.error: |
156 except getopt.error: |
155 usage() |
157 usage() |
156 |
158 |
157 excludeDirs = ["CVS", ".svn", "_svn", ".ropeproject", "_ropeproject", |
159 excludeDirs = ["CVS", ".svn", "_svn", ".ropeproject", "_ropeproject", |
158 ".eric5project", "_eric5project", "dist", "build", "doc", "docs"] |
160 ".eric5project", "_eric5project", "dist", "build", "doc", |
|
161 "docs"] |
159 excludePatterns = [] |
162 excludePatterns = [] |
160 outputDir = "doc" |
163 outputDir = "doc" |
161 recursive = False |
164 recursive = False |
162 doIndex = True |
165 doIndex = True |
163 noempty = False |
166 noempty = False |
275 sf = open(stylesheetFile, "r", encoding="utf-8") |
278 sf = open(stylesheetFile, "r", encoding="utf-8") |
276 stylesheet = sf.read() |
279 stylesheet = sf.read() |
277 sf.close() |
280 sf.close() |
278 except IOError: |
281 except IOError: |
279 sys.stderr.write( |
282 sys.stderr.write( |
280 "The CSS stylesheet '{0}' does not exist\n".format(stylesheetFile)) |
283 "The CSS stylesheet '{0}' does not exist\n".format( |
|
284 stylesheetFile)) |
281 sys.stderr.write("Disabling CSS usage.\n") |
285 sys.stderr.write("Disabling CSS usage.\n") |
282 stylesheet = None |
286 stylesheet = None |
283 else: |
287 else: |
284 stylesheet = None |
288 stylesheet = None |
285 |
289 |
298 else: |
302 else: |
299 qtHelpOutputDir = os.getcwd() |
303 qtHelpOutputDir = os.getcwd() |
300 qtHelpOutputDir = os.path.abspath(qtHelpOutputDir) |
304 qtHelpOutputDir = os.path.abspath(qtHelpOutputDir) |
301 |
305 |
302 qtHelpGenerator = QtHelpGenerator(outputDir, |
306 qtHelpGenerator = QtHelpGenerator(outputDir, |
303 qtHelpOutputDir, qtHelpNamespace, qtHelpFolder, |
307 qtHelpOutputDir, qtHelpNamespace, |
304 qtHelpFilterName, qtHelpFilterAttribs, |
308 qtHelpFolder, qtHelpFilterName, |
305 qtHelpTitle, qtHelpCreateCollection) |
309 qtHelpFilterAttribs, qtHelpTitle, |
|
310 qtHelpCreateCollection) |
306 |
311 |
307 for arg in args: |
312 for arg in args: |
308 if os.path.isdir(arg): |
313 if os.path.isdir(arg): |
309 if os.path.exists(os.path.join(arg, Utilities.joinext("__init__", ".py"))): |
314 if os.path.exists(os.path.join( |
|
315 arg, Utilities.joinext("__init__", ".py"))): |
310 basename = os.path.dirname(arg) |
316 basename = os.path.dirname(arg) |
311 if arg == '.': |
317 if arg == '.': |
312 sys.stderr.write("The directory '.' is a package.\n") |
318 sys.stderr.write("The directory '.' is a package.\n") |
313 sys.stderr.write("Please repeat the call giving its real name.\n") |
319 sys.stderr.write( |
|
320 "Please repeat the call giving its real name.\n") |
314 sys.stderr.write("Ignoring the directory.\n") |
321 sys.stderr.write("Ignoring the directory.\n") |
315 continue |
322 continue |
316 else: |
323 else: |
317 basename = arg |
324 basename = arg |
318 if basename: |
325 if basename: |
329 for filename in names: |
336 for filename in names: |
330 inpackage = False |
337 inpackage = False |
331 if os.path.isdir(filename): |
338 if os.path.isdir(filename): |
332 files = [] |
339 files = [] |
333 for ext in supportedExtensions: |
340 for ext in supportedExtensions: |
334 files.extend(glob.glob(os.path.join(filename, |
341 files.extend(glob.glob(os.path.join( |
335 Utilities.joinext("*", ext)))) |
342 filename, Utilities.joinext("*", ext)))) |
336 initFile = os.path.join(filename, Utilities.joinext("__init__", ext)) |
343 initFile = os.path.join( |
|
344 filename, Utilities.joinext("__init__", ext)) |
337 if initFile in files: |
345 if initFile in files: |
338 inpackage = True |
346 inpackage = True |
339 files.remove(initFile) |
347 files.remove(initFile) |
340 files.insert(0, initFile) |
348 files.insert(0, initFile) |
341 else: |
349 else: |
352 break |
360 break |
353 if skipIt: |
361 if skipIt: |
354 continue |
362 continue |
355 |
363 |
356 try: |
364 try: |
357 module = Utilities.ModuleParser.readModule(file, basename=basename, |
365 module = Utilities.ModuleParser.readModule( |
358 inpackage=inpackage, extensions=supportedExtensions) |
366 file, basename=basename, |
|
367 inpackage=inpackage, extensions=supportedExtensions) |
359 moduleDocument = ModuleDocument(module, colors, stylesheet) |
368 moduleDocument = ModuleDocument(module, colors, stylesheet) |
360 doc = moduleDocument.genDocument() |
369 doc = moduleDocument.genDocument() |
361 except IOError as v: |
370 except IOError as v: |
362 sys.stderr.write("{0} error: {1}\n".format(file, v[1])) |
371 sys.stderr.write("{0} error: {1}\n".format(file, v[1])) |
363 continue |
372 continue |
365 sys.stderr.write("{0} error: {1}\n".format(file, v)) |
374 sys.stderr.write("{0} error: {1}\n".format(file, v)) |
366 continue |
375 continue |
367 |
376 |
368 input = input + 1 |
377 input = input + 1 |
369 |
378 |
370 f = Utilities.joinext(os.path.join(outputDir, moduleDocument.name()), |
379 f = Utilities.joinext(os.path.join( |
371 ".html") |
380 outputDir, moduleDocument.name()), ".html") |
372 |
381 |
373 # remember for index file generation |
382 # remember for index file generation |
374 indexGenerator.remember(file, moduleDocument, basename) |
383 indexGenerator.remember(file, moduleDocument, basename) |
375 |
384 |
376 # remember for QtHelp generation |
385 # remember for QtHelp generation |