From 206d3bf4d735a655db0dc16a263d97e084972af3 Mon Sep 17 00:00:00 2001 From: cgohlke Date: Tue, 29 Jul 2014 00:29:29 -0700 Subject: [PATCH 1/2] ENH: add HTML Help builder option --- doc/make.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/doc/make.py b/doc/make.py index 80e09c758a56..ceaea5f66679 100755 --- a/doc/make.py +++ b/doc/make.py @@ -6,6 +6,7 @@ import os import shutil import sys +import re ### Begin compatibility block for pre-v2.6: ### # @@ -135,21 +136,32 @@ def doctest(): def linkcheck(): os.system('sphinx-build -b linkcheck -d build/doctrees . build/linkcheck') -def html(): +def html(buildername='html'): check_build() copy_if_out_of_date('../lib/matplotlib/mpl-data/matplotlibrc', '_static/matplotlibrc') if small_docs: options = "-D plot_formats=\"[('png', 80)]\"" else: options = '' - if os.system('sphinx-build %s -b html -d build/doctrees . build/html' % options): + if os.system('sphinx-build %s -b %s -d build/doctrees . build/%s' % (options, buildername, buildername)): raise SystemExit("Building HTML failed.") # Clean out PDF files from the _images directory - for filename in glob.glob('build/html/_images/*.pdf'): + for filename in glob.glob('build/%s/_images/*.pdf' % buildername): os.remove(filename) - shutil.copy('../CHANGELOG', 'build/html/_static/CHANGELOG') + shutil.copy('../CHANGELOG', 'build/%s/_static/CHANGELOG' % buildername) + +def htmlhelp(): + html(buildername='htmlhelp') + # remove scripts from index.html + with open('build/htmlhelp/index.html', 'r+') as fh: + content = fh.read() + fh.seek(0) + content = re.sub(r'', '', content, + flags=re.MULTILINE| re.DOTALL) + fh.write(content) + fh.truncate() def latex(): check_build() @@ -213,6 +225,7 @@ def all(): funcd = { 'html' : html, + 'htmlhelp' : htmlhelp, 'latex' : latex, 'texinfo' : texinfo, 'clean' : clean, From db09a7160a9ccd313663749d607605e7dbb123e0 Mon Sep 17 00:00:00 2001 From: cgohlke Date: Tue, 29 Jul 2014 00:32:27 -0700 Subject: [PATCH 2/2] Build gallery also for HTML Help docs --- doc/sphinxext/gen_gallery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/sphinxext/gen_gallery.py b/doc/sphinxext/gen_gallery.py index 05cba6858c9e..54cf342d1f71 100644 --- a/doc/sphinxext/gen_gallery.py +++ b/doc/sphinxext/gen_gallery.py @@ -61,7 +61,7 @@ def out_of_date(original, derived): def gen_gallery(app, doctree): - if app.builder.name != 'html': + if app.builder.name not in ('html', 'htmlhelp'): return outdir = app.builder.outdir