Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 206d3bf

Browse files
committed
ENH: add HTML Help builder option
1 parent 572731f commit 206d3bf

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

doc/make.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import shutil
88
import sys
9+
import re
910

1011
### Begin compatibility block for pre-v2.6: ###
1112
#
@@ -135,21 +136,32 @@ def doctest():
135136
def linkcheck():
136137
os.system('sphinx-build -b linkcheck -d build/doctrees . build/linkcheck')
137138

138-
def html():
139+
def html(buildername='html'):
139140
check_build()
140141
copy_if_out_of_date('../lib/matplotlib/mpl-data/matplotlibrc', '_static/matplotlibrc')
141142
if small_docs:
142143
options = "-D plot_formats=\"[('png', 80)]\""
143144
else:
144145
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)):
146147
raise SystemExit("Building HTML failed.")
147148

148149
# 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):
150151
os.remove(filename)
151152

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()
153165

154166
def latex():
155167
check_build()
@@ -213,6 +225,7 @@ def all():
213225

214226
funcd = {
215227
'html' : html,
228+
'htmlhelp' : htmlhelp,
216229
'latex' : latex,
217230
'texinfo' : texinfo,
218231
'clean' : clean,

0 commit comments

Comments
 (0)