Package vdb :: Package tools :: Module gendocs
[hide private]
[frames] | no frames]

Source Code for Module vdb.tools.gendocs

 1  ''' 
 2  Generates HTML documentation for Vdb and related APIs using epydoc. 
 3   
 4  Command line options (all are optional): 
 5   
 6      --dotpath=PATH          To generate class heirarchy graphs as part of 
 7                              documentation, specify the path to the GraphViz 
 8                              dot executable 
 9   
10      -o PATH, --output=PATH  The output directory.  If PATH does not exist, 
11                              then it will be created.  If it exists and is 
12                              non-empty, then the current directory will be 
13                              renamed and a new one created. 
14   
15      NAMES...                If you have additional files / modules to be 
16                              included in the documentation, specify them on the 
17                              command line after other options. 
18   
19  Usage Examples: (from command prompt in directory containing vdb directory) 
20    python -m vdb.tools.gendocs 
21    python -m vdb.tools.gendocs --dotpath "D:\\downloads\\Graphviz 2.28\\bin\\dot.exe" ..\\vdb-extensions-git\\*.py 
22    python -m vdb.tools.gendocs --dotpath "D:\\downloads\\Graphviz 2.28\\bin\\dot.exe" --output mydocs ..\\vdb-extensions-git\\*.py 
23  ''' 
24  import os 
25  import sys 
26  import datetime 
27   
28  try: 
29      #TODO: remove depending if we decide on a contrib dir. 
30      import contrib 
31  except: 
32      print('no contrib dir, trying local python') 
33  import epydoc 
34  import epydoc.cli 
35   
36 -def vdbEpydoc():
37 ''' 38 Generates HTML documentation for Vdb and related APIs using epydoc. 39 ''' 40 41 if len(sys.argv) > 1 and (sys.argv[1] == '-h' or sys.argv[1] == '--help'): 42 print(__doc__) 43 return 44 45 toolsdirname = os.path.dirname(os.path.abspath(__file__)) 46 47 outputdir = os.path.join(toolsdirname, 48 os.path.join('..', os.path.join('..', 'apidocs'))) 49 configfile = os.path.join(toolsdirname, 'vdb.epydoc') 50 cssfile = os.path.join(toolsdirname, 'vdb.epydoc.css') 51 52 newargv = ['epydoc', '--config', configfile, '--output', outputdir, '--css', 53 cssfile] 54 55 if sys.argv > 1: 56 newargv += sys.argv[1:] 57 58 # Create set the fake command line arguments so they will be parsed 59 sys.argv = newargv 60 61 options, names = epydoc.cli.parse_arguments() 62 63 # rename the output directory if it exists to give clean output 64 print(options.target) 65 if os.path.exists(options.target): 66 # path exists, verify it is a directory 67 if not os.path.isdir(options.target): 68 print('%s exists but is not a directory, exiting', options.target) 69 return 70 71 # if dir is not empty, rename it. 72 if len(os.listdir(options.target)) > 0: 73 now = datetime.datetime.now() 74 targetdirname = os.path.join(options.target, '-pre-' + now.strftime('%Y-%m-%d_%H%M%S')) 75 76 print('output dir: %s exists and is not empty. moving old dir to name %s' % (options.target, targetdirname)) 77 os.rename(options.target, targetdirname) 78 79 epydoc.cli.main(options, names)
80 81 if __name__ == '__main__': 82 vdbEpydoc() 83