From 66dad425aaad3bce0b3744735c47779b9003cb0f Mon Sep 17 00:00:00 2001 From: Stefan Seefeld Date: Wed, 7 Mar 2018 11:01:20 -0500 Subject: [PATCH] Build docs with faber. --- .ci/upload_docs.sh | 4 +-- .travis.yml | 19 ++++++----- doc/fabscript | 83 ++++++++++++++++++++++++++++++++++++++++++++++ fabscript | 1 + 4 files changed, 96 insertions(+), 11 deletions(-) create mode 100644 doc/fabscript diff --git a/.ci/upload_docs.sh b/.ci/upload_docs.sh index aa20838d..1e6f6b5c 100755 --- a/.ci/upload_docs.sh +++ b/.ci/upload_docs.sh @@ -22,10 +22,10 @@ fi REPO=`git config remote.origin.url` SHA=`git rev-parse --verify HEAD` -# bin.SCons happens to contain the "doc/html" tree that we want to push +# build happens to contain the "doc/html" tree that we want to push # into the gh-pages branch. So we step into that directory, create a new repo, # set the remote appropriately, then commit and push. -cd bin.SCons +cd build git init git config user.name "Travis CI" git config user.email "travis-ci" diff --git a/.travis.yml b/.travis.yml index e9342193..cd11fd0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ matrix: env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++98 - compiler: clang env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++11 - #- env: PYTHON=python DOC=1 + - env: PYTHON=python DOC=1 addons: @@ -37,7 +37,6 @@ addons: sources: - ubuntu-toolchain-r-test packages: - - scons - gcc-4.8 - g++-4.8 - clang @@ -80,11 +79,13 @@ install: rm -rf $HOME/Boost/boost/python* popd # Install Faber, the build tool. - date=2017-11-09 - #wget https://github.com/stefanseefeld/faber/archive/snapshot/$date.tar.gz - wget https://github.com/stefanseefeld/faber/archive/release/0.2.tar.gz - tar xf 0.2.tar.gz - pushd faber-release-0.2 + date=2018-03-07 + wget https://github.com/stefanseefeld/faber/archive/snapshot/$date.tar.gz + tar xf $date.tar.gz + pushd faber-snapshot-$date + #wget https://github.com/stefanseefeld/faber/archive/release/0.2.tar.gz + #tar xf 0.2.tar.gz + #pushd faber-release-0.2 sudo python setup.py install popd fi @@ -95,8 +96,8 @@ before_script: - faber -h script: -- faber --with-boost-include=$HOME/Boost test.report cxx.name=$CXX cxxflags=$CXXFLAGS -#- if [ "$DOC" ]; then scons doc; else scons && scons test; fi +- faber --with-boost-include=$HOME/Boost --builddir=build test.report cxx.name=$CXX cxxflags=$CXXFLAGS +- if [ "$DOC" ]; then BOOST_ROOT=$HOME/Boost faber --builddir=build doc.html; fi after_success: # Upload docs only when building upstream. diff --git a/doc/fabscript b/doc/fabscript new file mode 100644 index 00000000..bd8be7a3 --- /dev/null +++ b/doc/fabscript @@ -0,0 +1,83 @@ +# -*- python -*- +# +# Copyright (c) 2016 Stefan Seefeld +# All rights reserved. +# +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +from faber.tools.xslt import xsltflags +from faber.tools.boost import quickbook, boostbook +from faber.artefacts import html +from glob import glob as G +from os import makedirs +from os.path import relpath, dirname, exists +from shutil import copyfile + + +def glob(pattern): + prefix = srcdir + '/' + p = len(prefix)+1 + return [f[p:] for f in G(prefix + pattern)] + + +class make_html(action): + + def __init__(self): + action.__init__(self, 'make_html', self.process) + + def map(self, fs): + return boostbook.html.map(fs) + + def process(self, target, source): + boostbook.html(target, source[0:1]) + for s in source[1:]: + t = target[0]._filename + relpath(s._filename, srcdir) + d = dirname(t) + if not exists(d): + makedirs(d) + copyfile(s._filename, t) + + +sphinx_build = action('sphinx-build', 'sphinx-build -b html $(>) $(<)') +rst2html = action('rst2html', 'rst2html --trim-footnote-reference-space --footnote-references=superscript --stylesheet=$(>:D)/rst.css $(>) $(<)') + +python_bbk = rule(quickbook.process, 'python.bbk', 'python.qbk', + dependencies=['release_notes.qbk', + 'building.qbk', + 'configuration.qbk', + 'suport.qbk', + 'faq.qbk', + 'glossary.qbk']) +tutorial_bbk = rule(quickbook.process, 'tutorial.bbk', 'tutorial.qbk') +reference_bbk = rule(quickbook.process, 'reference.bbk', 'reference.qbk') + +python_db = rule(boostbook.db, 'python.db', python_bbk) +tutorial_db = rule(boostbook.db, 'tutorial.db', tutorial_bbk) +reference_db = rule(boostbook.db, 'reference.db', reference_bbk) + +python = html.dir(make_html(), 'html', [python_db, 'boostbook.css'] + glob('/images/*.*') + glob('/images/callouts/*.*'), + features=xsltflags('--stringparam generate.toc "library nop; chaper toc; section toc;"', + '--stringparam html.stylesheet boostbook.css', + '--stringparam boost.image.src images/bpl.png', + '--stringparam boost.graphics.root images/', + '--stringparam boost.defaults none', + '--param toc.max.depth 3', + '--param toc.section.depth 2', + '--param chunk.section.depth 1')) +tutorial = html.dir(boostbook.html, 'html/tutorial', tutorial_db, dependencies=[python], + features=xsltflags('--stringparam html.stylesheet ../boostbook.css', + '--stringparam boost.image.src ../images/bpl.png', + '--stringparam boost.graphics.root ../images/')) +reference = html.dir(boostbook.html, 'html/reference', reference_db, dependencies=[python], + features=xsltflags('--stringparam html.stylesheet ../boostbook.css', + '--stringparam boost.image.src ../images/bpl.png', + '--stringparam boost.graphics.root ../images/')) +numpy = rule(sphinx_build, 'html/numpy', 'numpy', attrs=always, dependencies=[python]) + +article = rule(rst2html, 'html/article.html', 'article.rst') + +html = alias('html', [python, tutorial, reference, numpy, article]) + +default = html diff --git a/fabscript b/fabscript index 054321d5..054ed90e 100644 --- a/fabscript +++ b/fabscript @@ -77,5 +77,6 @@ config = report('config', checks) src = module('src', features=config.use) test = module('test', features=config.use) +doc = module('doc', features=config.use) default = src.default