wscript: build sphinx documentation if sphinx-build is found in PATH
authorPaul Brossier <piem@piem.org>
Fri, 16 Sep 2016 16:33:17 +0000 (18:33 +0200)
committerPaul Brossier <piem@piem.org>
Fri, 16 Sep 2016 16:33:17 +0000 (18:33 +0200)
wscript

diff --git a/wscript b/wscript
index c665ff5..72abc0d 100644 (file)
--- a/wscript
+++ b/wscript
@@ -326,6 +326,12 @@ def configure(ctx):
         except ctx.errors.ConfigurationError:
           ctx.to_log('doxygen was not found (ignoring)')
 
+        # check if sphinx-build is installed, optional
+        try:
+          ctx.find_program('sphinx-build', var='SPHINX')
+        except ctx.errors.ConfigurationError:
+          ctx.to_log('sphinx-build was not found (ignoring)')
+
 def build(bld):
     bld.env['VERSION'] = VERSION
     bld.env['LIB_VERSION'] = LIB_VERSION
@@ -367,6 +373,16 @@ def build(bld):
                 cwd = bld.path.find_dir ('doc/web'),
                 relative_trick = True)
 
+    # build documentation from source files using sphinx-build
+    if bld.env['SPHINX']:
+        bld( name = 'sphinx', rule = 'make html',
+                source = ['doc/conf.py'] + bld.path.ant_glob('doc/**.rst'),
+                cwd = 'doc')
+        bld.install_files( '${PREFIX}' + '/share/doc/libaubio-doc/sphinx',
+                bld.path.ant_glob('doc/_build/html/**'),
+                cwd = bld.path.find_dir ('doc/_build/html'),
+                relative_trick = True)
+
 def shutdown(bld):
     from waflib import Logs
     if bld.options.target_platform in ['ios', 'iosimulator']: