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 from __future__ import print_function
00034
00035 """
00036 The package header is a YAML file that is used by the ROS.org wiki as
00037 well as rosinstall. It is similar in concept to the package manifest
00038 (manifest.xml), but it contains additional data and is in YAML format
00039 for easier processing in python scripts.
00040
00041 The data in the package header is not formally specified, but includes:
00042
00043 * manifest data (description, license, author, depends, review status, url)
00044 * rosinstall configuration information (VCS URI, branches, etc...)
00045 * stack and stack siblings (packages)
00046 * depends-on information
00047 * msg/srv listing
00048 """
00049
00050 import codecs
00051 import os
00052 import sys
00053 import traceback
00054 import yaml
00055
00056 import rospkg
00057
00058 import roslib.msgs
00059 import roslib.srvs
00060
00061 from .core import package_link, safe_encode
00062 from .repo_util import guess_vcs_uri, get_svn_url
00063
00064 def compute_package_dictionary(p, m, repo, rospack, rosstack):
00065 """
00066 @param m: manifest
00067 @param p: package name
00068 """
00069 m.description = m.description or ''
00070 d = {
00071 'name': p,
00072 'brief': m.brief,
00073 'description': m.description.strip() or '',
00074 'license': m.license or '',
00075 'authors': m.author or '',
00076 'depends': [d.package for d in m.depends],
00077 'review_status': m.status or '',
00078 'review_notes': m.notes or '',
00079 'url': m.url,
00080 }
00081
00082 if m.versioncontrol:
00083 d['version_control'] = m.versioncontrol.url
00084
00085 d['api_documentation'] = package_link(p)
00086 d['dependency_tree'] = package_link(p) + '%s_deps.pdf'%p
00087
00088
00089
00090 siblings = []
00091
00092 stack = rospack.stack_of(p) or ''
00093 if stack:
00094 d['stack'] = stack
00095 d['siblings'] = rosstack.packages_of(stack)
00096
00097 d['depends_on'] = rospack.get_depends_on(p, implicit=False)
00098
00099 d['msgs'] = roslib.msgs.list_msg_types(p, False)
00100 d['srvs'] = roslib.srvs.list_srv_types(p, False)
00101
00102
00103
00104
00105
00106
00107 d['repository'] = repo.aggregate_name or repo.name
00108 d['repository-actual'] = repo.name
00109 d['vcs'] = repo.type
00110 d['rosinstall'] = repo.rosinstall.copy()
00111
00112
00113
00114 if repo.rosinstalls:
00115 d['rosinstalls'] = repo.rosinstalls.copy()
00116
00117 if repo.is_released_stack:
00118
00119
00120 print("[%s] package is from released stack, using repo URI [%s]"%(p, repo.uri))
00121 print("loading vcs URI", repo.uri)
00122 d['vcs_uri'] = repo.uri
00123 elif repo.type == 'svn':
00124
00125 d['vcs_uri'] = get_svn_url(rospack.get_path(p))
00126
00127 d['rosinstall']['svn']['uri'] = d['vcs_uri']
00128 elif repo.type == 'git':
00129
00130 repo_type, repo_uri = guess_vcs_uri(rospack.get_path(p))
00131 d['vcs_uri'] = repo_uri
00132
00133 d['rosinstall']['git']['uri'] = repo_uri
00134 else:
00135 d['vcs_uri'] = repo.uri
00136 return d
00137
00138 def _generate_package_headers(ctx, repo, p, filename, rospack, rosstack):
00139 m = ctx.manifests[p]
00140 d = compute_package_dictionary(p, m, repo, rospack, rosstack)
00141
00142 if p in ctx.external_docs:
00143 d['external_documentation'] = ctx.external_docs[p]
00144
00145
00146
00147 d = safe_encode(d)
00148 with codecs.open(filename, mode='w', encoding='utf-8') as f:
00149 f.write(yaml.safe_dump(d, default_style="'"))
00150
00151 def generate_package_headers(ctx, repo, packages):
00152 """
00153 Generate manifest.yaml files for MoinMoin PackageHeader macro
00154 """
00155 rospack = rospkg.RosPack()
00156 rosstack = rospkg.RosStack()
00157
00158 artifacts = []
00159 for p in packages:
00160 if not ctx.should_document(p):
00161 continue
00162
00163 filename = os.path.join(ctx.docdir, p, 'manifest.yaml')
00164 filename_dir = os.path.dirname(filename)
00165 if not os.path.isdir(filename_dir):
00166 os.makedirs(filename_dir)
00167
00168 try:
00169 if not ctx.quiet:
00170 print("writing package properties to", filename)
00171 _generate_package_headers(ctx, repo, p, filename, rospack, rosstack)
00172 artifacts.append(filename)
00173 except Exception as e:
00174 traceback.print_exc()
00175 print("Unable to generate manifest.yaml for %s: %s"%(p, e), file=sys.stderr)
00176
00177 return artifacts