|
6 | 6 | import os |
7 | 7 | import shutil |
8 | 8 | import sys |
| 9 | +import re |
9 | 10 |
|
10 | 11 | ### Begin compatibility block for pre-v2.6: ### |
11 | 12 | # |
@@ -135,21 +136,32 @@ def doctest(): |
135 | 136 | def linkcheck(): |
136 | 137 | os.system('sphinx-build -b linkcheck -d build/doctrees . build/linkcheck') |
137 | 138 |
|
138 | | -def html(): |
| 139 | +def html(buildername='html'): |
139 | 140 | check_build() |
140 | 141 | copy_if_out_of_date('../lib/matplotlib/mpl-data/matplotlibrc', '_static/matplotlibrc') |
141 | 142 | if small_docs: |
142 | 143 | options = "-D plot_formats=\"[('png', 80)]\"" |
143 | 144 | else: |
144 | 145 | options = '' |
145 | | - if os.system('sphinx-build %s -b html -d build/doctrees . build/html' % options): |
| 146 | + if os.system('sphinx-build %s -b %s -d build/doctrees . build/%s' % (options, buildername, buildername)): |
146 | 147 | raise SystemExit("Building HTML failed.") |
147 | 148 |
|
148 | 149 | # Clean out PDF files from the _images directory |
149 | | - for filename in glob.glob('build/html/_images/*.pdf'): |
| 150 | + for filename in glob.glob('build/%s/_images/*.pdf' % buildername): |
150 | 151 | os.remove(filename) |
151 | 152 |
|
152 | | - shutil.copy('../CHANGELOG', 'build/html/_static/CHANGELOG') |
| 153 | + shutil.copy('../CHANGELOG', 'build/%s/_static/CHANGELOG' % buildername) |
| 154 | + |
| 155 | +def htmlhelp(): |
| 156 | + html(buildername='htmlhelp') |
| 157 | + # remove scripts from index.html |
| 158 | + with open('build/htmlhelp/index.html', 'r+') as fh: |
| 159 | + content = fh.read() |
| 160 | + fh.seek(0) |
| 161 | + content = re.sub(r'<script>.*?</script>', '', content, |
| 162 | + flags=re.MULTILINE| re.DOTALL) |
| 163 | + fh.write(content) |
| 164 | + fh.truncate() |
153 | 165 |
|
154 | 166 | def latex(): |
155 | 167 | check_build() |
@@ -213,6 +225,7 @@ def all(): |
213 | 225 |
|
214 | 226 | funcd = { |
215 | 227 | 'html' : html, |
| 228 | + 'htmlhelp' : htmlhelp, |
216 | 229 | 'latex' : latex, |
217 | 230 | 'texinfo' : texinfo, |
218 | 231 | 'clean' : clean, |
|
0 commit comments