00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import re
00019 import os
00020 from airbus_docgen import env
00021 from airbus_docgen.common import html
00022 from airbus_docgen.common.html import HtmlElement
00023
00024 from airbus_docgen.digraph.digraph import *
00025 from airbus_docgen.digraph.model.cmakelists import AddMessageFilesDotModel, \
00026 AddActionFilesDotModel, \
00027 AddServiceFilesDotModel, \
00028 AddLibraryDotModel, \
00029 AddExecutableDotModel, \
00030 BuildDependDotModel
00031
00032 class MessageFilesGeneration(HtmlElement):
00033 def __init__(self):
00034 HtmlElement.__init__(self,
00035 tag=html.Sections.article,
00036 attrib={"class":"generation"})
00037
00038 def read(self, pkgdir, f_cmake, digraph):
00039
00040 has_msgs = False
00041 add_msg_dot_model = AddMessageFilesDotModel()
00042
00043 p = HtmlElement(html.Grouping.p)
00044 p.text = 'List of generated '
00045 dep_href = HtmlElement(html.Text.a)
00046 dep_href.set("href","http://wiki.ros.org/msg")
00047 dep_href.set("target", "_blank")
00048 dep_href.text = "message file :"
00049 p.append(dep_href)
00050
00051 ul = HtmlElement(html.Grouping.ul)
00052 for msg in re.finditer(r"(.*?)\.msg", f_cmake):
00053 msfound = msg.group()
00054 if '#' not in msfound:
00055 li = HtmlElement(html.Grouping.li)
00056 rms = msfound.replace('FILES','').replace(' ','')
00057 li.text = rms
00058 add_msg_dot_model.add(rms)
00059 ul.append(li)
00060 has_msgs = True
00061
00062 p.append(ul)
00063 self.append(p)
00064
00065 if has_msgs is True:
00066 digraph.addNode(add_msg_dot_model)
00067 digraph.connect(digraph.getRootNode(), add_msg_dot_model)
00068
00069 return has_msgs
00070
00071 class ActionFilesGeneration(HtmlElement):
00072 def __init__(self):
00073 HtmlElement.__init__(self,
00074 tag=html.Sections.article,
00075 attrib={"class":"generation"})
00076
00077 def read(self, pkgdir, f_cmake, digraph):
00078
00079 has_action = False
00080 add_ac_dot_model = AddActionFilesDotModel()
00081
00082 p = HtmlElement(html.Grouping.p)
00083 p.text = 'List of generated '
00084 dep_href = HtmlElement(html.Text.a)
00085 dep_href.set("href","http://wiki.ros.org")
00086 dep_href.set("target", "_blank")
00087 dep_href.text = "action file :"
00088 p.append(dep_href)
00089
00090 ul = HtmlElement(html.Grouping.ul)
00091 for msg in re.finditer(r"(.*?)\.action", f_cmake):
00092 msfound = msg.group()
00093 if '#' not in msfound:
00094 li = HtmlElement(html.Grouping.li)
00095 rac = msfound.replace(' ','')
00096 li.text = rac
00097 add_ac_dot_model.add(rac)
00098 ul.append(li)
00099 has_action = True
00100
00101 p.append(ul)
00102 self.append(p)
00103
00104 if has_action is True:
00105 digraph.addNode(add_ac_dot_model)
00106 digraph.connect(digraph.getRootNode(), add_ac_dot_model)
00107
00108 return has_action
00109
00110 class ServiceFilesGeneration(HtmlElement):
00111 def __init__(self):
00112 HtmlElement.__init__(self,
00113 tag=html.Sections.article,
00114 attrib={"class":"generation"})
00115
00116 def read(self, pkgdir, f_cmake, digraph):
00117
00118 has_srv = False
00119 add_srv_dot_model = AddServiceFilesDotModel()
00120
00121 p = HtmlElement(html.Grouping.p)
00122 p.text = 'List of generated '
00123 dep_href = HtmlElement(html.Text.a)
00124 dep_href.set("href","http://wiki.ros.org/srv")
00125 dep_href.set("target", "_blank")
00126 dep_href.text = "service file :"
00127 p.append(dep_href)
00128
00129 ul = HtmlElement(html.Grouping.ul)
00130 for msg in re.finditer(r"(.*?)\.srv", f_cmake):
00131 msfound = msg.group()
00132 if '#' not in msfound:
00133 li = HtmlElement(html.Grouping.li)
00134 rsrv = msfound.replace(' ','')
00135 li.text = rsrv
00136 add_srv_dot_model.add(rsrv)
00137 ul.append(li)
00138 has_srv = True
00139
00140 p.append(ul)
00141 self.append(p)
00142
00143 if has_srv is True:
00144 digraph.addNode(add_srv_dot_model)
00145 digraph.connect(digraph.getRootNode(), add_srv_dot_model)
00146
00147 return has_srv
00148
00149 class LibrarieGeneration(HtmlElement):
00150 def __init__(self):
00151 HtmlElement.__init__(self,
00152 tag=html.Sections.article,
00153 attrib={"class":"generation"})
00154 def read(self, pkgdir, f_cmake, digraph):
00155
00156 has_lib = False
00157 add_lib_dot_model = AddLibraryDotModel()
00158
00159 p = HtmlElement(html.Grouping.p)
00160 p.text = 'List of generated '
00161 dep_href = HtmlElement(html.Text.a)
00162 dep_href.set("href","http://wiki.ros.org/catkin/CMakeLists.txt")
00163 dep_href.set("target", "_blank")
00164 dep_href.text = "libraries :"
00165 p.append(dep_href)
00166
00167 ul = HtmlElement(html.Grouping.ul)
00168
00169 for lib in re.finditer("(.*?)add_library\((?P<lib>(.+?){1,})", f_cmake):
00170 libfound = lib.group()
00171 if '#' not in libfound:
00172 li = HtmlElement(html.Grouping.li)
00173 rlib = lib.group('lib').split('/')[0].split(' ')[0]
00174 li.text = rlib
00175 add_lib_dot_model.add(rlib)
00176 ul.append(li)
00177 has_lib = True
00178
00179 p.append(ul)
00180 self.append(p)
00181
00182 if has_lib is True:
00183 digraph.addNode(add_lib_dot_model)
00184 digraph.connect(digraph.getRootNode(), add_lib_dot_model)
00185
00186 return has_lib
00187
00188 class ExecutableGeneration(HtmlElement):
00189 def __init__(self):
00190 HtmlElement.__init__(self,
00191 tag=html.Sections.article,
00192 attrib={"class":"generation"})
00193
00194 def read(self, pkgdir, f_cmake, digraph):
00195
00196 has_exec = False
00197 add_exec_dot_model = AddExecutableDotModel()
00198
00199 p = HtmlElement(html.Grouping.p)
00200 p.text = 'List of generated '
00201 dep_href = HtmlElement(html.Text.a)
00202 dep_href.set("href","http://wiki.ros.org/catkin/CMakeLists.txt")
00203 dep_href.set("target", "_blank")
00204 dep_href.text = "executables :"
00205 p.append(dep_href)
00206
00207 ul = HtmlElement(html.Grouping.ul)
00208
00209 for lib in re.finditer("(.*?)add_executable\((?P<exec>(.+?){1,})", f_cmake):
00210 libfound = lib.group()
00211 if '#' not in libfound:
00212 li = HtmlElement(html.Grouping.li)
00213 rexec = lib.group('exec').split('/')[0].split(' ')[0]
00214 li.text = rexec
00215 add_exec_dot_model.add(rexec)
00216 ul.append(li)
00217 has_exec = True
00218
00219 p.append(ul)
00220 self.append(p)
00221
00222 if has_exec is True:
00223 digraph.addNode(add_exec_dot_model)
00224 digraph.connect(digraph.getRootNode(), add_exec_dot_model)
00225
00226 return has_exec
00227
00228 class PyExecutableGeneration(HtmlElement):
00229 def __init__(self):
00230 HtmlElement.__init__(self,
00231 tag=html.Sections.article,
00232 attrib={"class":"py_generation"})
00233
00234 def read(self, pkgdir, pkg_name, digraph):
00235
00236 has_exec = False
00237 add_exec_dot_model = AddExecutableDotModel("add_py_executable","Python executable generated")
00238
00239 p = HtmlElement(html.Grouping.p)
00240 p.text = 'List of generated '
00241 dep_href = HtmlElement(html.Text.a)
00242 dep_href.set("href","http://wiki.ros.org/catkin/CMakeLists.txt")
00243 dep_href.set("target", "_blank")
00244 dep_href.text = "python executables :"
00245 p.append(dep_href)
00246
00247 ul = HtmlElement(html.Grouping.ul)
00248
00249 fscripts = pkgdir+'/scripts'
00250 fnodes = pkgdir+'/nodes'
00251
00252 if os.path.isdir(fscripts):
00253 for filename in os.listdir(fscripts):
00254 if filename != "__init__.py":
00255 li = HtmlElement(html.Grouping.li)
00256 li.text = filename
00257 add_exec_dot_model.add(filename)
00258 ul.append(li)
00259 has_exec = True
00260
00261 if os.path.isdir(fnodes):
00262 for filename in os.listdir(fnodes):
00263 if filename != "__init__.py":
00264 li = HtmlElement(html.Grouping.li)
00265 li.text = filename
00266 add_exec_dot_model.add(filename)
00267 ul.append(li)
00268 has_exec = True
00269
00270 p.append(ul)
00271 self.append(p)
00272
00273 if has_exec is True:
00274 digraph.addNode(add_exec_dot_model)
00275 digraph.connect(digraph.getRootNode(), add_exec_dot_model)
00276
00277 return has_exec
00278
00279 class PackageGenerations(HtmlElement):
00280
00281 def __init__(self):
00282 HtmlElement.__init__(self,
00283 tag=html.Sections.article,
00284 attrib={"class":"generation"})
00285
00286
00287 def _create_digraph(self, name, dep_pkg_list):
00288
00289 digraph = Digraph("PkgGenerationGraph")
00290 digraph.setAttrib(Digraph.NODESEP, 0.1)
00291
00292
00293 nconf = NODE("node")
00294 nconf.setAttrib(NODE.SHAPE, SHAPE.Plaintext)
00295 digraph.addNode(nconf)
00296
00297 pkg = NODE(name)
00298 pkg.setAttrib(NODE.SHAPE, "box3d")
00299 pkg.setAttrib(NODE.STYLE, STYLE.FILLED)
00300 pkg.setAttrib(NODE.COLOR, RgbColor.CornflowerBlue)
00301 pkg.setAttrib(NODE.FONTSIZE, 22)
00302 digraph.addRootNode(pkg)
00303
00304 if dep_pkg_list is not None:
00305 dep_dot_model = BuildDependDotModel()
00306 for dep in dep_pkg_list:
00307 dep_dot_model.add(dep)
00308 digraph.addNode(dep_dot_model)
00309 digraph.connect(dep_dot_model, digraph.getRootNode())
00310
00311
00312 return digraph
00313
00314 def read(self, pkgdir, f_cmake, dep_pkg_list):
00315
00316 index = 0
00317 pkg_name = pkgdir.split('/')[-1]
00318 digraph = self._create_digraph(pkg_name, dep_pkg_list)
00319
00320
00321
00322
00323
00324
00325
00326
00327 try:
00328 msgs = MessageFilesGeneration()
00329 if msgs.read(pkgdir, f_cmake, digraph) is True:
00330 index += 1
00331 title = HtmlElement(html.Sections.h3)
00332 title.text = "4.%i Message(s)"%index
00333 self.append(title)
00334 self.append(msgs)
00335 except Exception as ex:
00336 html.HTMLException(ex,self)
00337
00338 try:
00339 ac = ActionFilesGeneration()
00340 if ac.read(pkgdir, f_cmake, digraph) is True:
00341 index += 1
00342 title = HtmlElement(html.Sections.h3)
00343 title.text = "4.%i Action(s)"%index
00344 self.append(title)
00345 self.append(ac)
00346 except Exception as ex:
00347 html.HTMLException(ex,self)
00348
00349 try:
00350 srv = ServiceFilesGeneration()
00351 if srv.read(pkgdir, f_cmake, digraph) is True:
00352 index += 1
00353 title = HtmlElement(html.Sections.h3)
00354 title.text = "4.%i Service(s)"%index
00355 self.append(title)
00356 self.append(srv)
00357 except Exception as ex:
00358 html.HTMLException(ex,self)
00359
00360 try:
00361 lib = LibrarieGeneration()
00362 if lib.read(pkgdir, f_cmake, digraph) is True:
00363 index += 1
00364 title = HtmlElement(html.Sections.h3)
00365 title.text = "4.%i Librarie(s)"%index
00366 self.append(title)
00367 self.append(lib)
00368 except Exception as ex:
00369 html.HTMLException(ex,self)
00370
00371 try:
00372 exe = ExecutableGeneration()
00373 if exe.read(pkgdir, f_cmake, digraph) is True:
00374 index += 1
00375 title = HtmlElement(html.Sections.h3)
00376 title.text = "4.%i Executable(s)"%index
00377 self.append(title)
00378 self.append(exe)
00379 except Exception as ex:
00380 html.HTMLException(ex,self)
00381
00382 try:
00383 pyexe = PyExecutableGeneration()
00384 if pyexe.read(pkgdir, pkg_name, digraph) is True:
00385 index += 1
00386 title = HtmlElement(html.Sections.h3)
00387 title.text = "4.%i Python executable(s)"%index
00388 self.append(title)
00389 self.append(pyexe)
00390 except Exception as ex:
00391 html.HTMLException(ex,self)
00392
00393 digraph.saveDot(env.ROSDOC_DOT+"/gen/%s.dot"%pkg_name)
00394 digraph.dotToPng(env.ROSDOC_DOT+"/gen/%s.png"%pkg_name)
00395
00396 if index is 0:
00397 return False
00398 else:
00399 return True
00400