1 import json, urllib2, os, sys
2 from BeautifulSoup
import *
10 def __init__(self, dataPath, path, cmsVer = ""):
16 self.
managersURL =
'http://cmsdoxy.web.cern.ch/cmsdoxy/tcproxy.php?type=managers'
17 self.
usersURL =
'http://cmsdoxy.web.cern.ch/cmsdoxy/tcproxy.php?type=users'
18 self.
CMSSWURL =
'http://cmsdoxy.web.cern.ch/cmsdoxy/tcproxy.php?type=packages&release=CMSSW_4_4_2'
20 self.
tWikiLinks = {
'Analysis':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCrab',
21 'Calibration and Alignment':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCalAli',
22 'Core':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideFrameWork',
23 'DAQ':
'https://twiki.cern.ch/twiki/bin/view/CMS/TriDASWikiHome',
24 'DQM':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideDQM',
25 'Database':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideCondDB',
26 'Documentation':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuide',
27 'Fast Simulation':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideFastSimulation',
28 'Full Simulation':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideSimulation',
29 'Generators':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideEventGeneration',
30 'Geometry':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideDetectorDescription',
31 'HLT':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideHighLevelTrigger',
32 'L1':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideL1Trigger',
33 'Reconstruction':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideReco',
34 'Visualization':
'https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideVisualization'}
38 self.
GitLink =
"https://github.com/cms-sw/cmssw/tree/" + self.
CMSVER +
"/%s/%s"
40 self.
title =
"<center>\n<h1>CMSSW Documentation</h1>\n<h2>" + self.
CMSVER +
"</h2>\n</center>\n"
42 <p style="margin-left:10px;">
43 Learn <a href="ReferenceManual.html">how to build Reference Manual</a><br>
44 Learn more about <a target="_blank" href="http://www.stack.nl/~dimitri/doxygen/commands.html">special doxygen commands</a>
47 <!-- Content Script & Style -->
48 <script type="text/javascript">
51 function toggleHoba(item, path)
53 for(var i = 0; i < itemList.length; i++)
55 if(itemList[i] == item)
57 var iframe = $("#"+itemList[i]+"_div").children("iframe:first");
58 if(!iframe.attr("src"))
60 iframe.attr("src", path)
62 $("#"+item+"_div").slideToggle();
65 $("#"+itemList[i]+"_div").slideUp();
69 $(document).ready(function() {
70 searchBox.OnSelectItem(0);
71 $(".doctable").find("td").each(function(){ if (this.id.indexOf("hoba_") != -1)itemList.push(this.id);});
80 border-bottom: 1px solid #c1c1dc;
88 <!-- Content Script & Style -->
94 soup.head.insert(len(soup.head), self.
head)
96 contents = soup.find(
"div", {
"class" :
"contents" })
97 for child
in contents.findChildren():
101 self.
mainPageTemplate = self.mainPageTemplate.replace(
"CSCDQM Framework Guide",
"")
103 print "Main page template created..."
106 print "RefMan created..."
114 """This method reads file directly or from path."""
116 print "Read:", self.
path + fileName
117 f = open(self.
path + fileName)
120 print "Read:", fileName
126 """This method writes data"""
127 print "Write:", self.
path + fileName
128 f = open(self.
path + fileName,
"w")
133 """This method returns file name without extension"""
135 return fileName[0:fileName.find(
'.')]
140 """This method returns data which is read from URL"""
141 u = urllib2.urlopen(URL)
142 return json.loads(u.read())
145 return str_[0:str_.find(
'/')]
149 return str_[str_.find(
'/')+1:]
154 return item[
"id"].
count(
"_") - 1
157 return fileName.lower().
replace(
' ',
'_')
161 print "Managers loaded and parsed..."
164 print "Users loaded and parsed..."
167 for i
in self.managers.keys():
168 self.
data[i] = {
"__DATA__":{
"Contact":[]}}
172 print "Domains loaded and parsed..."
174 for i
in self.domains.keys():
187 contents = soup.find(
"div", {
"class" :
"contents" })
188 li = contents.findAll(
"tr", {})
193 self.
packages[i.a.text] = i.a[
"href"]
194 print "Packages parsed(%d)..." % len(self.
packages)
198 contents = soup.find(
"div", {
"class" :
"contents" })
199 tr = contents.findAll(
"tr", {})
202 if tr[0].text ==
'src': origin = -1
212 self.
classes[level1][i.text] = {}
224 if flag
and i.text !=
u'interface':
225 self.
classes[level1][level2][i.text] = i.a[
"href"]
227 print "Class hierarchy loaded(%d)..." % len(self.
classes)
233 contents = soup.find(
"div", {
"class" :
"contents" })
234 td = contents.findAll(
"td", {})
238 if i.a
and i.a.has_key(
'href'):
240 print "Class URLs was loaded... (%s)" % len(self.
classesURLs)
242 for i
in self.data.keys():
244 if not self.classes.has_key(j):
continue
246 if "Package " + j +
"/" + k
in self.
packages:
247 self.
data[i][j][k][
"__DATA__"][
"packageDoc"] =
'../' + self.
packages[
"Package " + j +
"/" + k]
248 if not self.
classes[j].has_key(k):
continue
256 if self.
data ==
None:
261 content =
"""<h1>The Reference Manual </h1>
262 This is the CMSSW Reference Manual, the reference documentation of all classes and packages in CMSSW.<p>
263 This page explains how to write the documentation for your code.
265 </p><h2>Class Documentation</h2>
267 Classes and methods are documented with properly formatted <a target="_blank" class="el" href="d3/d88/namespacecomments.html">comments</a> in the code.<p>
268 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>.
270 </p><h2>Package Documentation</h2>
272 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>
273 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
274 <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>,
275 which is available in your PATH.
277 </p><h2> How to generate your documentation locally </h2>
278 One you have updated your documentation, you can look at how it displays in the following way:
281 <li>check out the following packages:
282 <pre> > cmsrel CMSSW_7_X_X
285 > git cms-addpkg Documentation
287 > generate_reference_manual
291 > firefox doc/html/index.html </pre>
297 if self.
data ==
None:
301 <table class="doctable" border="0" cellpadding="0" cellspacing="0">
303 <tr class="top" valign="top">
304 <th class="domain">Domain</th><th class="contact">Contact</th>
307 keysI = self.data.keys()
311 if i ==
'Other':
continue
314 contents = contents +
'\n<tr class="DCRow">\n'
316 if i ==
'Operations':
317 contents = contents +
"""<td width="50%%" style="padding:8px">%s</td>\n""" % i
319 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)
322 contents = contents +
'<td width="50%" class="contact">'
323 for j
in range(len(self.
data[i][
"__DATA__"][
"Contact"])):
324 if j == len(self.
data[i][
"__DATA__"][
"Contact"]) - 1:
325 contents = contents +
'<a href="mailto:%s">%s</a> ' % (self.
data[i][
"__DATA__"][
"Contact"][j][1], self.
data[i][
"__DATA__"][
"Contact"][j][0])
327 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 +
'</td>\n'
329 contents = contents +
'</tr>\n\n'
331 if i ==
'Operations':
continue
333 contents = contents +
"""
334 <tr><td colspan="2" style="background:#d7dbe3">
335 <div style="display:none;" id="hoba_%s_div"><iframe width="100%%" frameborder="0"></iframe></div>
337 """ % (i.replace(
' ',
'_'))
339 contents = contents +
"</table>"
344 if not self.data.has_key(domain):
return
350 if i ==
'__DATA__':
continue
361 keysK = self.
data[domain][i][j].
keys()
366 if self.
data[domain][i][j].has_key(
"__DATA__"):
371 if self.
data[domain][i][j].has_key(
"__DATA__"):
377 if k ==
'__DATA__':
continue
378 if self.
data[domain][i][j][k][
"__DATA__"]: content += self.
HTMLTreeAddItem(k, self.
data[domain][i][j][k][
"__DATA__"])
384 if self.tWikiLinks.has_key(domain):
387 print 'Warning: The twiki link of "%s" domain not found...' % domain
391 html =
'\n<li>\n<div class="hitarea expandable-hitarea"></div>\n'
392 html = html +
'<span class="folder">%s\n' % title
393 for i
in links.keys():
394 html = html +
'<a target="_blank" href="%s">[%s]</a> \n' % (links[i], i)
395 html = html +
'</span>\n'
396 html = html +
'<ul style="display: block;">\n'
400 return '</li></ul>\n\n'
403 if endNode: html =
'\t<li class="last">'
404 else: html =
'\t<li>'
406 if type(links) == str
or type(links) == type(
u''):
408 html = html +
'\t<a href="%s" target="_blank" class=""><span class="emptyFolder">%s</span></a>\n' % (links, title)
410 html = html +
'\t<a href="%s" target="_blank" class=""><span class="file">%s</span></a>\n' % (links, title)
411 elif type(links) == dict:
413 html = html +
'<span class="emptyFolder">%s ' % title
415 html = html +
'<span class="file">%s ' % title
416 for i
in links.keys():
417 html = html +
'<a target="_blank" href="%s">[%s]</a> \n' % (links[i], i)
418 html = html +
'</span>'
420 html = html +
'\t<span class="file">%s</span>\n' % title
421 return html +
'\t</li>\n'
423 if len(sys.argv) == 5:
424 DATA_PATH = sys.argv[1]
433 l.CreateNewMainPage(OUTF)
435 print "parameter error. It must be like this: python MainPageGenerator.py DATA_PATH/ CMSSW/doc/html/ CMS_VER OUTPUT_FILE_NAME"
def __init__
Constructor method.
MainPageGenerator class is used for generating main page that contains domain trees (Analysis...