3
"""Create index file to access documentation components."""
5
# Generate an html file ("index.html") to allow easy access to the
6
# documentation for the various components.
7
# This file is run automatically at the end of "generate_MAUS_doc.py" and
8
# generally does not need to be run by itself.
9
# For more information see README.
17
def commonprefix(*args):
18
"""Fix behaviour of commonprefix function"""
19
return os.path.commonprefix(*args).rpartition('/')[0]
21
def create_index_html():
22
"""Create the html file"""
23
paths = [os.environ.get('MAUS_THIRD_PARTY'),
24
os.environ.get('MAUS_ROOT_DIR')]
25
# Get the locations of the local MAUS installation and the location of the
26
# third party libraries relative to the point where their absolute paths
28
tppath_segment = paths[0][len(commonprefix(paths))+1:]
29
maus_path_segment = paths[1][len(commonprefix(paths))+1:]
30
# Need to deal with the case where the two paths are the same
31
if not tppath_segment:
33
# Generate the appropriate paths to link to the third party libaries.
35
rel_tppath = tppath_segment + '/doc/'
36
dir_prepend = '../'*(maus_path_segment.count('/')+2)
37
rel_tppath = dir_prepend + rel_tppath
38
# These need to be defined manually because it is possible that third party
39
# and MAUS documentation are in the same directory.
40
root_segment = ('<li><a href="' + rel_tppath +
41
'doxygen_root/html/index.html">ROOT</a></li>\n')
42
geant4_segment = ('<li><a href="' + rel_tppath +
43
'doxygen_geant4/html/index.html">Geant4</a></li>\n')
44
clhep_segment = ('<li><a href="' + rel_tppath +
45
'doxygen_clhep/html/index.html">CLHEP</a></li>\n')
46
jsoncpp_segment = ('<li><a href="' + rel_tppath +
47
'doxygen_jsoncpp/html/index.html">JsonCpp</a></li>\n')
48
# Fixed components of the index file.
49
upper_html_snippet = """
53
<meta charset="UTF-8" />
54
<title>MAUS doxygen Documentation Index</title>
55
<style type="text/css">
56
body {font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px;}
57
li {line-height:20px;}
58
li.title {font-weight:bold;}
59
ul ul {margin-bottom:20px;}
66
<h1>MAUS doxygen Documentation Index</h1>
67
<p>Use the links below to access the doxygen documentation for the various components of MAUS and some third party libraries</p>
68
<p>If links don't work, the documentation likely hasn't been compiled yet.</p>
70
<li class="title">MAUS Documentation</li>
72
<li><a href="doxygen_framework/html/index.html">Framework</a></li>
73
<li><a href="doxygen_datastructure/html/index.html">DataStructure</a></li>
74
<li><a href="doxygen_input/html/index.html">Input</a></li>
75
<li><a href="doxygen_map/html/index.html">Map</a></li>
76
<li><a href="doxygen_reduce/html/index.html">Reduce</a></li>
77
<li><a href="doxygen_output/html/index.html">Output</a></li>
79
<li class="title">Third Party Documentation</li>
82
lower_html_snippet = """
89
file1 = open(os.path.join(os.environ['MAUS_ROOT_DIR'], \
90
'doc/' 'index.html'), 'w')
91
file1.write(upper_html_snippet + root_segment + geant4_segment +
92
clhep_segment + jsoncpp_segment + lower_html_snippet)
95
if __name__ == "__main__":
96
print "Typically you don't need to run this file by itself."
97
print "It is automatically executed at the end of generate_MAUS_doc.py."
98
print "Only execute this file if documentation has already been compiled."
99
raw_input('If you would still like to generate the index file, '
100
'please press Enter.')