Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 from __future__ import with_statement
00036
00037 import os, sys
00038 from subprocess import Popen, PIPE
00039
00040 from rosdoc.rdcore import *
00041
00042
00043
00044 def generate_epydoc(ctx):
00045 success = []
00046 for package, path in ctx.packages.iteritems():
00047 if package in ctx.doc_packages and ctx.should_document(package) \
00048 and ctx.has_builder(package, 'epydoc'):
00049
00050
00051
00052
00053 rd_config = [d for d in ctx.rd_configs[package] if d['builder'] == 'epydoc'][0]
00054
00055
00056
00057
00058
00059 try:
00060 html_dir = html_path(package, ctx.docdir)
00061 if 'output_dir' in rd_config:
00062 html_dir = os.path.join(html_dir, rd_config['output_dir'])
00063 if not os.path.isdir(html_dir):
00064 os.makedirs(html_dir)
00065
00066 command = ['epydoc', '--html', package, '-o', html_dir]
00067 if 'exclude' in rd_config:
00068 for s in rd_config['exclude']:
00069 command.extend(['--exclude', s])
00070
00071 if 'config' in rd_config:
00072 import roslib.packages
00073 pkg_dir = roslib.packages.get_pkg_dir(package)
00074 command.extend(['--config', os.path.join(pkg_dir, rd_config['config']) ])
00075 else:
00076
00077 command.extend(['--inheritance', 'included', '--no-private'])
00078
00079
00080 import roslib.launcher
00081
00082 del roslib.launcher._bootstrapped[:]
00083 paths = roslib.launcher._generate_python_path(package, [], os.environ)
00084 env = os.environ.copy()
00085 env['PYTHONPATH'] = os.pathsep.join([p for p in paths if os.path.exists(p)])
00086
00087 if not ctx.quiet:
00088 print "epydoc-building %s [%s]"%(package, ' '.join(command))
00089 Popen(command, stdout=PIPE, env=env).communicate()
00090 success.append(package)
00091 except Exception, e:
00092 print >> sys.stderr, "Unable to generate epydoc for [%s]. This is probably because epydoc is not installed.\nThe exact error is:\n\t%s"%(package, str(e))
00093 return success