From 1de187e670340ec1617d8b528e894be14caa6630 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Thu, 27 Sep 2012 13:47:43 +0000 Subject: [PATCH] Added building of docs to the wscript. --- INSTALL | 2 ++ wscript | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/INSTALL b/INSTALL index 743f5de..0bf35a3 100644 --- a/INSTALL +++ b/INSTALL @@ -50,6 +50,8 @@ fine-tune the build: * --avisynth=true/false (default: true) Specifies whether to build the Avisynth compatibility layer when building on Windows. +* --docs=true/false (default: false) + Specifies whether to build the Sphinx-based documentation. Once the project is configured, simply execute: diff --git a/wscript b/wscript index 537cc7e..a46ccd8 100644 --- a/wscript +++ b/wscript @@ -31,6 +31,54 @@ class preproc(Task.Task): def add_pyx_file(self, node): self.create_task('preproc', node, node.get_bld().change_ext('.pyx')) +class docs(Task.Task): + "Build Sphinx documentation" + + ext_out = ['.html'] + inst_to = None + color = 'PINK' + + def run(self): + subprocess.Popen('make html BUILDDIR={0}'.format(os.path.join(os.pardir, OUT)), + shell = True, + cwd = 'doc', + stdout = subprocess.PIPE).wait() + +@TaskGen.feature('docs') +@TaskGen.before_method('process_source') +def apply_rst(self): + rst_nodes = [] + no_nodes = [] + + for x in self.to_nodes(self.source): + if x.name.endswith('.rst'): + rst_nodes.append(x) + else: + no_nodes.append(x) + + self.source = no_nodes + + bld_nodes = [] + + for node in rst_nodes: + n = self.path.find_node(OUT).make_node('html') + + cur = node.parent + dirs = [] + + while not cur is self.path.find_node('doc'): + dirs.append(cur) + cur = cur.parent + + for dir in reversed(dirs): + n = n.make_node(dir.name) + + n = n.make_node(node.name).change_ext('.html') + + bld_nodes.append(n) + + self.rst_task = self.create_task('docs', rst_nodes, bld_nodes) + def options(opt): opt.load('compiler_c') opt.load('compiler_cxx') @@ -41,6 +89,7 @@ def options(opt): opt.add_option('--filters', action = 'store', default = 'true', help = 'build included filters (true/false)') opt.add_option('--cython', action = 'store', default = 'true', help = 'build Cython wrapper (true/false)') opt.add_option('--avisynth', action = 'store', default = 'true', help = 'build Avisynth compatibility layer (true/false)') + opt.add_option('--docs', action = 'store', default = 'false', help = 'build the documentation (true/false)') def configure(conf): def add_options(flags, options): @@ -152,6 +201,11 @@ def configure(conf): if not conf.env.AVISYNTH in ['true', 'false']: conf.fatal('--avisynth must be either true or false.') + conf.env.DOCS = conf.options.docs + + if not conf.env.DOCS in ['true', 'false']: + conf.fatal('--docs must be either true or false.') + conf.check_cxx(lib = 'QtCore') conf.check_cxx(use = ['QTCORE'], header_name = 'QtCore/QtCore') conf.check_cxx(use = ['QTCORE'], header_name = 'QtCore/QtCore', type_name = 'QAtomicInt') @@ -210,4 +264,9 @@ def build(bld): bld(features = 'preproc', source = bld.path.ant_glob([os.path.join('src', 'cython', '*.pyx')])) + if bld.env.DOCS == 'true': + bld(features = 'docs', + source = bld.path.ant_glob([os.path.join('doc', '*.rst'), + os.path.join('doc', '**', '*.rst')])) + bld.install_files('${PREFIX}/include', os.path.join('include', 'VapourSynth.h')) -- 2.11.4.GIT