~jderose/wehjit/trunk

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python

"""
Generate API documentation using epydoc.
"""

import sys
import os
from os import path
import shutil
from subprocess import call
import optparse
import wehjit

parser = optparse.OptionParser()
parser.add_option('--extra',
    help='Also generate docs for unit tests and examples',
    default=False,
    action='store_true',
)
(options, args) = parser.parse_args()

tree = path.dirname(path.abspath(__file__))
os.chdir(tree)

package = 'wehjit'
apidoc = path.join(tree, 'doc', 'apidoc')
init = path.join(tree, package, '__init__.py')
name = 'wehjit %s API documentation' % wehjit.__version__

if not path.exists(init):
    print 'Cannot find %r' % init
    print 'Error: %r does not appear to be project tree' % tree
    sys.exit(1)
if path.isdir(apidoc):
    print 'Removing old %r' % apidoc
    shutil.rmtree(apidoc)
if path.lexists(apidoc):
    print 'Error: %r is not a directory' % apidoc
    sys.exit(1)

cmd = ['epydoc', '-v', '--html', '--no-frames',
    '--docformat', 'restructuredtext',
    '--name', name,
    '--output', apidoc,
]
if not options.extra:
    cmd.extend([
        '--exclude', '%s.tests' % package,
        '--exclude', '%s.examples' % package,
    ])
cmd.append(package)

sys.exit(call(cmd))