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 codecs
00038 import os
00039 import sys
00040 import traceback
00041 import yaml
00042
00043 import roslib.msgs
00044 import roslib.rospack
00045 import roslib.srvs
00046 import roslib.stacks
00047 import roslib.packages
00048 import roslib.vcs
00049
00050 def _generate_package_headers(ctx, p):
00051 m = ctx.manifests[p]
00052 m.description = m.description or ''
00053 d = {
00054 'brief': m.brief,
00055 'description': m.description.strip() or '',
00056 'license': m.license or '',
00057 'authors': m.author or '',
00058 'depends': [d.package for d in m.depends],
00059 'review_status': m.status or '',
00060 'review_notes': m.notes or '',
00061 'url': m.url,
00062 }
00063
00064 if m.versioncontrol:
00065 d['version_control'] = m.versioncontrol.url
00066
00067 siblings = []
00068 stack = roslib.stacks.stack_of(p) or ''
00069 if stack:
00070 d['stack'] = stack
00071 d['siblings'] = roslib.stacks.packages_of(stack)
00072
00073 d['depends_on'] = roslib.rospack.rospack_depends_on_1(p)
00074
00075 d['api_documentation'] = package_link(p)
00076
00077 if p in ctx.external_docs:
00078 d['external_documentation'] = ctx.external_docs[p]
00079
00080 d['msgs'] = roslib.msgs.list_msg_types(p, False)
00081 d['srvs'] = roslib.srvs.list_srv_types(p, False)
00082
00083 d['dependency_tree'] = package_link(p) + '%s_deps.pdf'%p
00084
00085
00086
00087 d_copy = d.copy()
00088 for k, v in d_copy.iteritems():
00089 if isinstance(v, basestring):
00090 try:
00091 d[k] = v.encode("utf-8")
00092 except UnicodeDecodeError, e:
00093 print >> sys.stderr, "error: cannot encode value for key", k
00094 d[k] = ''
00095 elif type(v) == list:
00096 try:
00097 d[k] = [x.encode("utf-8") for x in v]
00098 except UnicodeDecodeError, e:
00099 print >> sys.stderr, "error: cannot encode value for key", k
00100 d[k] = []
00101
00102
00103 vcs, repo = roslib.vcs.guess_vcs_uri(roslib.packages.get_pkg_dir(p))
00104
00105
00106
00107
00108 if ctx.repos:
00109 for r_vcs, r_uri in ctx.repos.itervalues():
00110 if r_vcs == vcs and \
00111 (r_uri.startswith(repo) or repo.starswith(r_uri)):
00112 repo = r_uri
00113 break
00114
00115 if repo is not None:
00116 d['repository'] = repo
00117 d['vcs'] = vcs
00118
00119 file_p = os.path.join(ctx.docdir, p, 'manifest.yaml')
00120 file_p_dir = os.path.dirname(file_p)
00121 if not os.path.isdir(file_p_dir):
00122 os.makedirs(file_p_dir)
00123 with codecs.open(file_p, mode='w', encoding='utf-8') as f:
00124 f.write(yaml.dump(d))
00125
00126 def generate_package_headers(ctx):
00127 """
00128 Generate manifest.yaml files for MoinMoin PackageHeader macro
00129 """
00130 try:
00131 import yaml
00132 except ImportError:
00133 print >> sys.stderr, "Cannot import yaml, will not generate MoinMoin PackageHeader files"
00134 return
00135
00136 packages = ctx.packages
00137 for p in packages.iterkeys():
00138 if not ctx.should_document(p):
00139 continue
00140 try:
00141
00142 _generate_package_headers(ctx, p)
00143 except Exception, e:
00144 traceback.print_exc()
00145 print >> sys.stderr, "Unable to generate manifest.yaml for "+p+str(e)