~chris-rogers/maus/emr_mc_digitization

« back to all changes in this revision

Viewing changes to doc/doc_tools/generate_doc_index.py

  • Committer: Chris Rogers
  • Date: 2014-04-16 11:48:45 UTC
  • mfrom: (707 merge)
  • mto: This revision was merged to the branch mainline in revision 711.
  • Revision ID: chris.rogers@stfc.ac.uk-20140416114845-h3u3q7pdcxkxvovs
Update to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/env python
 
2
 
 
3
"""Create index file to access documentation components."""
 
4
 
 
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.
 
10
 
 
11
import os
 
12
 
 
13
def main():
 
14
    """Main"""
 
15
    create_index_html()
 
16
 
 
17
def commonprefix(*args):
 
18
    """Fix behaviour of commonprefix function"""
 
19
    return os.path.commonprefix(*args).rpartition('/')[0]
 
20
 
 
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
 
27
    # branch.
 
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:
 
32
        rel_tppath = ''
 
33
    # Generate the appropriate paths to link to the third party libaries.
 
34
    else:
 
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 = """
 
50
<!DOCTYPE html>
 
51
<html lang="en">
 
52
<head>
 
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;}
 
60
 
 
61
div 
 
62
</style>
 
63
</head>
 
64
<body>
 
65
<div>
 
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>
 
69
  <ul>
 
70
    <li class="title">MAUS Documentation</li>
 
71
      <ul>
 
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>
 
78
      </ul>
 
79
     <li class="title">Third Party Documentation</li>
 
80
      <ul>
 
81
    """
 
82
    lower_html_snippet = """
 
83
      </ul>
 
84
 </ul>
 
85
</div>
 
86
</body>
 
87
</html>
 
88
    """
 
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)
 
93
    file1.close()
 
94
 
 
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.')
 
101
    main()