diff --git a/doc/source/conf.py b/doc/source/conf.py index 88221c1..51322f7 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -34,6 +34,15 @@ except: 'WARNING: https://pypi.python.org/pypi/sphinxcontrib-doxylink\n') extensions = ['sphinx.ext.mathjax'] +# http://sphinx-doc.org/extensions.html#where-to-put-your-own-extensions +sys.path.append(os.path.abspath('exts')) + +# We bundled the `rawfiles` sphinx extension to copy over files on sphinx build +# https://pypi.python.org/pypi/sphinxcontrib-rawfiles +extensions += ['rawfiles'] + +rawfiles = ['fhelp/ctlike.html'] + # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/doc/source/exts/rawfiles.py b/doc/source/exts/rawfiles.py new file mode 100644 index 0000000..5d7b24b --- /dev/null +++ b/doc/source/exts/rawfiles.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# Copied from https://bitbucket.org/birkenfeld/sphinx-contrib/ +import os +import shutil + +def on_html_collect_pages(app): + for f in app.builder.config.rawfiles: + src = os.path.join(app.srcdir, f) + dst = os.path.join(app.builder.outdir, f) + # cleanup + if os.path.exists(dst): + if os.path.isdir(dst): + shutil.rmtree(dst) + elif os.path.isfile(dst): + os.remove(dst) + # copy file + if os.path.exists(src): + if os.path.isdir(src): + shutil.copytree(src, dst) + elif os.path.isfile(src): + shutil.copy(src, dst) + else: + msg = ('rawfiles target is not directory or file "%s".' % src) + app.builder.warn(msg) + else: + msg = ('rawfiles can not find "%s".' % src) + app.builder.warn(msg) + + return () + +def setup(app): + app.add_config_value('rawfiles', [], 'html') + app.connect("html-collect-pages", on_html_collect_pages) \ No newline at end of file