blob: 8f7e718e9b0f1cfe01839da29e769932233c47b7 [file] [log] [blame]
Sameer Agarwalfa21df82013-02-18 08:48:52 -08001#!/usr/bin/python
2#
3# Ceres Solver - A fast non-linear least squares minimizer
4# Copyright 2013 Google Inc. All rights reserved.
5# http://code.google.com/p/ceres-solver/
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions are met:
9#
10# * Redistributions of source code must retain the above copyright notice,
11# this list of conditions and the following disclaimer.
12# * Redistributions in binary form must reproduce the above copyright notice,
13# this list of conditions and the following disclaimer in the documentation
14# and/or other materials provided with the distribution.
15# * Neither the name of Google Inc. nor the names of its contributors may be
16# used to endorse or promote products derived from this software without
17# specific prior written permission.
18#
19# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGE.
30#
31# Author: sameeragarwal@google.com (Sameer Agarwal)
32#
33# Note: You will need Sphinx and Pygments installed for this to work.
34
Sameer Agarwalfa21df82013-02-18 08:48:52 -080035import glob
Sameer Agarwal931c3092013-02-25 09:46:21 -080036import os
37import sys
Sameer Agarwalfa21df82013-02-18 08:48:52 -080038
39if len(sys.argv) < 3:
40 print "make_docs.py src_root destination_root"
Sameer Agarwalbeb45052013-02-22 13:37:01 -080041 sys.exit(1)
Sameer Agarwalfa21df82013-02-18 08:48:52 -080042
43src_dir = sys.argv[1] + "/docs/source"
44build_root = sys.argv[2]
45doctrees_dir = build_root + "/doctrees"
46html_dir = build_root + "/html"
47
48# Run Sphinx to build the documentation.
49os.system("sphinx-build -b html -d %s %s %s" %(doctrees_dir, src_dir, html_dir))
50
51input_pattern = """config=TeX-AMS-MML_HTMLorMML"></script>"""
52output_pattern = """config=TeX-AMS_HTML">
53 MathJax.Hub.Config({
54 "HTML-CSS": {
55 availableFonts: ["TeX"]
56 }
57 });
58</script>"""
59
60# By default MathJax uses does not use TeX fonts. This simple search
Sameer Agarwalbeb45052013-02-22 13:37:01 -080061# and replace fixes that.
Sameer Agarwalfa21df82013-02-18 08:48:52 -080062for name in glob.glob("%s/*.html" % html_dir):
63 print "Postprocessing: ", name
Sameer Agarwalbeb45052013-02-22 13:37:01 -080064 fptr = open(name)
65 out = fptr.read().replace(input_pattern, output_pattern)
Sameer Agarwal931c3092013-02-25 09:46:21 -080066 fptr.close()
67
68 fptr = open(name, "w")
69 fptr.write(out)
70 fptr.close()