1 from __future__
import print_function
2 from __future__
import absolute_import
3 import json, urllib2, os, sys
4 from bs4
import BeautifulSoup
12 def __init__(self, dataPath, path, cmsVer = ""):
18 self.
managersURL =
'http://cmsdoxy.web.cern.ch/cmsdoxy/tcproxy.php?type=managers' 19 self.
usersURL =
'http://cmsdoxy.web.cern.ch/cmsdoxy/tcproxy.php?type=users' 20 self.
CMSSWURL =
'http://cmsdoxy.web.cern.ch/cmsdoxy/tcproxy.php?type=packages&release=CMSSW_4_4_2' 22 self.
tWikiLinks = {
'Analysis':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrab',
23 'Calibration and Alignment':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCalAli',
24 'Core':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideFrameWork',
25 'DAQ':
'https://twiki.cern.ch/twiki/bin/view/CMS/TriDASWikiHome',
26 'DQM':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideDQM',
27 'Database':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCondDB',
28 'Documentation':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuide',
29 'Fast Simulation':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideFastSimulation',
30 'Full Simulation':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideSimulation',
31 'Generators':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideEventGeneration',
32 'Geometry':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideDetectorDescription',
33 'HLT':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideHighLevelTrigger',
34 'L1':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideL1Trigger',
35 'Reconstruction':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideReco',
36 'Visualization':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideVisualization'}
40 self.
GitLink =
"https://github.com/cms-sw/cmssw/tree/" + self.
CMSVER +
"/%s/%s" 42 self.
title =
"<center>\n<h1>CMSSW Documentation</h1>\n<h2>" + self.
CMSVER +
"</h2>\n</center>\n" 44 <p style="margin-left:10px;"> 45 Learn <a href="ReferenceManual.html">how to build Reference Manual</a><br> 46 Learn more about <a target="_blank" href="http://www.stack.nl/~dimitri/doxygen/commands.html">special doxygen commands</a> 49 <!-- Content Script & Style --> 50 <script type="text/javascript"> 53 function toggleHoba(item, path) 55 for(var i = 0; i < itemList.length; i++) 57 if(itemList[i] == item) 59 var iframe = $("#"+itemList[i]+"_div").children("iframe:first"); 60 if(!iframe.attr("src")) 62 iframe.attr("src", path) 64 $("#"+item+"_div").slideToggle(); 67 $("#"+itemList[i]+"_div").slideUp(); 71 $(document).ready(function() { 72 searchBox.OnSelectItem(0); 73 $(".doctable").find("td").each(function(){ if (this.id.indexOf("hoba_") != -1)itemList.push(this.id);}); 82 border-bottom: 1px solid #c1c1dc; 90 <!-- Content Script & Style --> 96 soup.head.insert(len(soup.head), self.
head)
98 contents = soup.find(
"div", {
"class" :
"contents" })
99 for child
in contents.findChildren():
105 print(
"Main page template created...")
108 print(
"RefMan created...")
116 """This method reads file directly or from path.""" 119 f = open(self.
path + fileName)
122 print(
"Read:", fileName)
128 """This method writes data""" 130 f = open(self.
path + fileName,
"w")
135 """This method returns file name without extension""" 137 return fileName[0:fileName.find(
'.')]
142 """This method returns data which is read from URL""" 143 u = urllib2.urlopen(URL)
144 return json.loads(u.read())
147 return str_[0:str_.find(
'/')]
151 return str_[str_.find(
'/')+1:]
156 return item[
"id"].
count(
"_") - 1
159 return fileName.lower().
replace(
' ',
'_')
163 print(
"Managers loaded and parsed...")
166 print(
"Users loaded and parsed...")
170 self.
data[i] = {
"__DATA__":{
"Contact":[]}}
174 print(
"Domains loaded and parsed...")
189 contents = soup.find(
"div", {
"class" :
"contents" })
190 li = contents.findAll(
"tr", {})
195 self.
packages[i.a.text] = i.a[
"href"]
200 contents = soup.find(
"div", {
"class" :
"contents" })
201 tr = contents.findAll(
"tr", {})
204 if tr[0].text ==
'src': origin = -1
214 self.
classes[level1][i.text] = {}
226 if flag
and i.text !=
u'interface':
227 self.
classes[level1][level2][i.text] = i.a[
"href"]
229 print(
"Class hierarchy loaded(%d)..." % len(self.
classes))
235 contents = soup.find(
"div", {
"class" :
"contents" })
236 td = contents.findAll(
"td", {})
240 if i.a
and 'href' in i.a:
246 if j
not in self.
classes:
continue 248 if "Package " + j +
"/" + k
in self.
packages:
249 self.
data[i][j][k][
"__DATA__"][
"packageDoc"] =
'../' + self.
packages[
"Package " + j +
"/" + k]
250 if k
not in self.
classes[j]:
continue 258 if self.
data ==
None:
263 content =
"""<h1>The Reference Manual </h1> 264 This is the CMSSW Reference Manual, the reference documentation of all classes and packages in CMSSW.<p> 265 This page explains how to write the documentation for your code. 267 </p><h2>Class Documentation</h2> 269 Classes and methods are documented with properly formatted <a target="_blank" class="el" href="d3/d88/namespacecomments.html">comments</a> in the code.<p> 270 Here is a template of a documented <a target="_blank" href="http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/Documentation/CodingRules/Template.h?rev=HEAD&cvsroot=CMSSW&content-type=text/vnd.viewcvs-markup">.h file</a>, and of a <a target="_blank" href="http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/CMSSW/Documentation/CodingRules/Template.cc?rev=HEAD&cvsroot=CMSSW&content-type=text/vnd.viewcvs-markup">.cc file</a>. The resulting doxygen page is <a target="_blank" class="el" href="d6/d3e/classTemplate.html">here</a>. 272 </p><h2>Package Documentation</h2> 274 Each package should contain a very brief description of its content and purpose. Remember that this is a reference, and not a user's guide: tutorials, howtos, etc. are best documented in the <a target="_blank" href="https://twiki.cern.ch/twiki/bin/view/CMS/SWGuide">CMS Offline Guide</a> and in the <a target="_blank" href="https://twiki.cern.ch/twiki/bin/view/CMS/WorkBook">WorkBook</a>. Cross links between the CMS Offline Guide and the WorkBook and this manual are a good way to avoid duplication of content.<p> 275 This documentation should be written in a file [Package]/doc/[Package].doc. The simplest way of doing this is to go to the doc/ directory in your package and then run the script 276 <a target="_blank" href="http://cmssw.cvs.cern.ch/cgi-bin/cmssw.cgi/*checkout*/CMSSW/Documentation/ReferenceManualScripts/scripts/makePackageDoc?rev=HEAD&cvsroot=CMSSW">makePackageDoc</a>, 277 which is available in your PATH. 279 </p><h2> How to generate your documentation locally </h2> 280 One you have updated your documentation, you can look at how it displays in the following way: 283 <li>check out the following packages: 284 <pre> > cmsrel CMSSW_7_X_X 287 > git cms-addpkg Documentation 289 > generate_reference_manual 293 > firefox doc/html/index.html </pre> 299 if self.
data ==
None:
303 <table class="doctable" border="0" cellpadding="0" cellspacing="0"> 305 <tr class="top" valign="top"> 306 <th class="domain">Domain</th><th class="contact">Contact</th> 312 if i ==
'Other':
continue 315 contents = contents +
'\n<tr class="DCRow">\n' 317 if i ==
'Operations':
318 contents = contents +
"""<td width="50%%" style="padding:8px">%s</td>\n""" % i
320 contents = contents +
"""<td width="50%%" style="padding:8px;cursor:pointer" onclick="toggleHoba('hoba_%s', 'iframes/%s.html')" id="hoba_%s"><a>%s</a></td>\n""" % (i.replace(
' ',
'_'), i.lower().
replace(
' ',
'_'), i.replace(
' ',
'_'), i)
323 contents = contents +
'<td width="50%" class="contact">' 324 for j
in range(len(self.
data[i][
"__DATA__"][
"Contact"])):
325 if j == len(self.
data[i][
"__DATA__"][
"Contact"]) - 1:
326 contents = contents +
'<a href="mailto:%s">%s</a> ' % (self.
data[i][
"__DATA__"][
"Contact"][j][1], self.
data[i][
"__DATA__"][
"Contact"][j][0])
328 contents = contents +
'<a href="mailto:%s">%s</a>, ' % (self.
data[i][
"__DATA__"][
"Contact"][j][1], self.
data[i][
"__DATA__"][
"Contact"][j][0])
329 contents = contents +
'</td>\n' 330 contents = contents +
'</tr>\n\n' 332 if i ==
'Operations':
continue 334 contents = contents +
""" 335 <tr><td colspan="2" style="background:#d7dbe3"> 336 <div style="display:none;" id="hoba_%s_div"><iframe width="100%%" frameborder="0"></iframe></div> 338 """ % (i.replace(
' ',
'_'))
340 contents = contents +
"</table>" 345 if domain
not in self.
data:
return 348 keysI = sorted(self.
data[domain].
keys())
350 if i ==
'__DATA__':
continue 352 keysJ = sorted(self.
data[domain][i].
keys())
360 keysK = sorted(self.
data[domain][i][j].
keys())
364 if "__DATA__" in self.
data[domain][i][j]:
369 if "__DATA__" in self.
data[domain][i][j]:
375 if k ==
'__DATA__':
continue 376 if self.
data[domain][i][j][k][
"__DATA__"]: content += self.
HTMLTreeAddItem(k, self.
data[domain][i][j][k][
"__DATA__"])
385 print(
'Warning: The twiki link of "%s" domain not found...' % domain)
389 html =
'\n<li>\n<div class="hitarea expandable-hitarea"></div>\n' 390 html = html +
'<span class="folder">%s\n' % title
391 for i
in links.keys():
392 html = html +
'<a target="_blank" href="%s">[%s]</a> \n' % (links[i], i)
393 html = html +
'</span>\n' 394 html = html +
'<ul style="display: block;">\n' 398 return '</li></ul>\n\n' 401 if endNode: html =
'\t<li class="last">' 402 else: html =
'\t<li>' 404 if isinstance(links, str)
or isinstance(links, type(
u'')):
406 html = html +
'\t<a href="%s" target="_blank" class=""><span class="emptyFolder">%s</span></a>\n' % (links, title)
408 html = html +
'\t<a href="%s" target="_blank" class=""><span class="file">%s</span></a>\n' % (links, title)
409 elif isinstance(links, dict):
411 html = html +
'<span class="emptyFolder">%s ' % title
413 html = html +
'<span class="file">%s ' % title
414 for i
in links.keys():
415 html = html +
'<a target="_blank" href="%s">[%s]</a> \n' % (links[i], i)
416 html = html +
'</span>' 418 html = html +
'\t<span class="file">%s</span>\n' % title
419 return html +
'\t</li>\n' 421 if len(sys.argv) == 5:
422 DATA_PATH = sys.argv[1]
431 l.CreateNewMainPage(OUTF)
433 print(
"parameter error. It must be like this: python MainPageGenerator.py DATA_PATH/ CMSSW/doc/html/ CMS_VER OUTPUT_FILE_NAME")
def WriteFile(self, fileName, data)
def HTMLTreeAddItem(self, title, links=None, endNode=False, folder=False)
def __ParseItem(self, str_)
def __ParseSubItem(self, str_)
def __init__(self, dataPath, path, cmsVer="")
Constructor method.
def ExportJSON(self, fileName)
def __HTMLFileName(self, fileName)
def replace(string, replacements)
def ParseJsonFromURL(self, URL)
MainPageGenerator class is used for generating main page that contains domain trees (Analysis...
def CreateBuildRefMan(self)
def __NewTreePage(self, domain)
def ReadFile(self, fileName, pathFlag=True)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def HTMLTreeBegin(self, title, links={})
def CreateNewMainPage(self, outputFileName)
def __GetHTMLItemDepth(self, item)
def GetFileName(self, fileName)