• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
10from faber.tools.xslt import xsltflags
11from faber.tools.boost import quickbook, boostbook
12from faber.artefacts import html
13from glob import glob as G
14from os import makedirs
15from os.path import relpath, dirname, exists
16from shutil import copyfile
17
18
19def glob(pattern):
20    prefix = srcdir + '/'
21    p = len(prefix)+1
22    return [f[p:] for f in G(prefix + pattern)]
23
24
25class 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
43sphinx_build  = action('sphinx-build', 'sphinx-build -b html $(>) $(<)')
44rst2html  = action('rst2html', 'rst2html --trim-footnote-reference-space --footnote-references=superscript --stylesheet=$(>:D)/rst.css $(>) $(<)')
45
46python_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'])
53tutorial_bbk = rule(quickbook.process, 'tutorial.bbk', 'tutorial.qbk')
54reference_bbk = rule(quickbook.process, 'reference.bbk', 'reference.qbk')
55
56python_db = rule(boostbook.db, 'python.db', python_bbk)
57tutorial_db = rule(boostbook.db, 'tutorial.db', tutorial_bbk)
58reference_db = rule(boostbook.db, 'reference.db', reference_bbk)
59
60python = 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'))
69tutorial = 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/'))
73reference = 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/'))
77numpy = rule(sphinx_build, 'html/numpy', 'numpy', attrs=always, dependencies=[python])
78
79article = rule(rst2html, 'html/article.html', 'article.rst')
80
81html = alias('html', [python, tutorial, reference, numpy, article])
82
83default = html
84