Skip to content

Commit 66dad42

Browse files
committed
Build docs with faber.
1 parent ed3cbf8 commit 66dad42

File tree

4 files changed

+96
-11
lines changed

4 files changed

+96
-11
lines changed

.ci/upload_docs.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ fi
2222
REPO=`git config remote.origin.url`
2323
SHA=`git rev-parse --verify HEAD`
2424

25-
# bin.SCons happens to contain the "doc/html" tree that we want to push
25+
# build happens to contain the "doc/html" tree that we want to push
2626
# into the gh-pages branch. So we step into that directory, create a new repo,
2727
# set the remote appropriately, then commit and push.
28-
cd bin.SCons
28+
cd build
2929
git init
3030
git config user.name "Travis CI"
3131
git config user.email "travis-ci"

.travis.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,14 @@ matrix:
2929
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++98
3030
- compiler: clang
3131
env: CXX=clang++ PYTHON=python3 CXXFLAGS=-std=c++11
32-
#- env: PYTHON=python DOC=1
32+
- env: PYTHON=python DOC=1
3333

3434

3535
addons:
3636
apt:
3737
sources:
3838
- ubuntu-toolchain-r-test
3939
packages:
40-
- scons
4140
- gcc-4.8
4241
- g++-4.8
4342
- clang
@@ -80,11 +79,13 @@ install:
8079
rm -rf $HOME/Boost/boost/python*
8180
popd
8281
# Install Faber, the build tool.
83-
date=2017-11-09
84-
#wget https://github.com/stefanseefeld/faber/archive/snapshot/$date.tar.gz
85-
wget https://github.com/stefanseefeld/faber/archive/release/0.2.tar.gz
86-
tar xf 0.2.tar.gz
87-
pushd faber-release-0.2
82+
date=2018-03-07
83+
wget https://github.com/stefanseefeld/faber/archive/snapshot/$date.tar.gz
84+
tar xf $date.tar.gz
85+
pushd faber-snapshot-$date
86+
#wget https://github.com/stefanseefeld/faber/archive/release/0.2.tar.gz
87+
#tar xf 0.2.tar.gz
88+
#pushd faber-release-0.2
8889
sudo python setup.py install
8990
popd
9091
fi
@@ -95,8 +96,8 @@ before_script:
9596
- faber -h
9697

9798
script:
98-
- faber --with-boost-include=$HOME/Boost test.report cxx.name=$CXX cxxflags=$CXXFLAGS
99-
#- if [ "$DOC" ]; then scons doc; else scons && scons test; fi
99+
- faber --with-boost-include=$HOME/Boost --builddir=build test.report cxx.name=$CXX cxxflags=$CXXFLAGS
100+
- if [ "$DOC" ]; then BOOST_ROOT=$HOME/Boost faber --builddir=build doc.html; fi
100101

101102
after_success:
102103
# Upload docs only when building upstream.

doc/fabscript

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# -*- python -*-
2+
#
3+
# Copyright (c) 2016 Stefan Seefeld
4+
# All rights reserved.
5+
#
6+
# Distributed under the Boost Software License, Version 1.0.
7+
# (See accompanying file LICENSE_1_0.txt or copy at
8+
# http://www.boost.org/LICENSE_1_0.txt)
9+
10+
from faber.tools.xslt import xsltflags
11+
from faber.tools.boost import quickbook, boostbook
12+
from faber.artefacts import html
13+
from glob import glob as G
14+
from os import makedirs
15+
from os.path import relpath, dirname, exists
16+
from shutil import copyfile
17+
18+
19+
def glob(pattern):
20+
prefix = srcdir + '/'
21+
p = len(prefix)+1
22+
return [f[p:] for f in G(prefix + pattern)]
23+
24+
25+
class make_html(action):
26+
27+
def __init__(self):
28+
action.__init__(self, 'make_html', self.process)
29+
30+
def map(self, fs):
31+
return boostbook.html.map(fs)
32+
33+
def process(self, target, source):
34+
boostbook.html(target, source[0:1])
35+
for s in source[1:]:
36+
t = target[0]._filename + relpath(s._filename, srcdir)
37+
d = dirname(t)
38+
if not exists(d):
39+
makedirs(d)
40+
copyfile(s._filename, t)
41+
42+
43+
sphinx_build = action('sphinx-build', 'sphinx-build -b html $(>) $(<)')
44+
rst2html = action('rst2html', 'rst2html --trim-footnote-reference-space --footnote-references=superscript --stylesheet=$(>:D)/rst.css $(>) $(<)')
45+
46+
python_bbk = rule(quickbook.process, 'python.bbk', 'python.qbk',
47+
dependencies=['release_notes.qbk',
48+
'building.qbk',
49+
'configuration.qbk',
50+
'suport.qbk',
51+
'faq.qbk',
52+
'glossary.qbk'])
53+
tutorial_bbk = rule(quickbook.process, 'tutorial.bbk', 'tutorial.qbk')
54+
reference_bbk = rule(quickbook.process, 'reference.bbk', 'reference.qbk')
55+
56+
python_db = rule(boostbook.db, 'python.db', python_bbk)
57+
tutorial_db = rule(boostbook.db, 'tutorial.db', tutorial_bbk)
58+
reference_db = rule(boostbook.db, 'reference.db', reference_bbk)
59+
60+
python = html.dir(make_html(), 'html', [python_db, 'boostbook.css'] + glob('/images/*.*') + glob('/images/callouts/*.*'),
61+
features=xsltflags('--stringparam generate.toc "library nop; chaper toc; section toc;"',
62+
'--stringparam html.stylesheet boostbook.css',
63+
'--stringparam boost.image.src images/bpl.png',
64+
'--stringparam boost.graphics.root images/',
65+
'--stringparam boost.defaults none',
66+
'--param toc.max.depth 3',
67+
'--param toc.section.depth 2',
68+
'--param chunk.section.depth 1'))
69+
tutorial = html.dir(boostbook.html, 'html/tutorial', tutorial_db, dependencies=[python],
70+
features=xsltflags('--stringparam html.stylesheet ../boostbook.css',
71+
'--stringparam boost.image.src ../images/bpl.png',
72+
'--stringparam boost.graphics.root ../images/'))
73+
reference = html.dir(boostbook.html, 'html/reference', reference_db, dependencies=[python],
74+
features=xsltflags('--stringparam html.stylesheet ../boostbook.css',
75+
'--stringparam boost.image.src ../images/bpl.png',
76+
'--stringparam boost.graphics.root ../images/'))
77+
numpy = rule(sphinx_build, 'html/numpy', 'numpy', attrs=always, dependencies=[python])
78+
79+
article = rule(rst2html, 'html/article.html', 'article.rst')
80+
81+
html = alias('html', [python, tutorial, reference, numpy, article])
82+
83+
default = html

fabscript

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,6 @@ config = report('config', checks)
7777

7878
src = module('src', features=config.use)
7979
test = module('test', features=config.use)
80+
doc = module('doc', features=config.use)
8081

8182
default = src.default

0 commit comments

Comments
 (0)