1 | # Copyright David Abrahams 2004. Distributed under the Boost |
---|
2 | # Software License, Version 1.0. (See accompanying |
---|
3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
---|
4 | |
---|
5 | # Support for docutils ReStructuredText processing. |
---|
6 | |
---|
7 | import type ; |
---|
8 | import scanner ; |
---|
9 | import generators ; |
---|
10 | import os ; |
---|
11 | import common ; |
---|
12 | import toolset ; |
---|
13 | import path ; |
---|
14 | import feature : feature ; |
---|
15 | |
---|
16 | .initialized = ; |
---|
17 | |
---|
18 | type.register ReST : rst ; |
---|
19 | |
---|
20 | class rst-scanner : common-scanner |
---|
21 | { |
---|
22 | rule pattern ( ) |
---|
23 | { |
---|
24 | return "^\\w*\\.\\.\\w+include::\w+(.*)" |
---|
25 | "^\\w*\\.\\.\\w+image::\w+(.*)" |
---|
26 | "^\\w*\\.\\.\\w+figure::\w+(.*)" |
---|
27 | ; |
---|
28 | } |
---|
29 | } |
---|
30 | |
---|
31 | scanner.register rst-scanner : include ; |
---|
32 | type.set-scanner ReST : rst-scanner ; |
---|
33 | |
---|
34 | generators.register-standard docutils.html : ReST : HTML ; |
---|
35 | |
---|
36 | rule init ( docutils-dir ) |
---|
37 | { |
---|
38 | docutils-dir ?= [ modules.peek : DOCUTILS_DIR ] ; |
---|
39 | |
---|
40 | if ! $(.initialized) |
---|
41 | { |
---|
42 | .initialized = true ; |
---|
43 | .docutils-dir = $(docutils-dir) ; |
---|
44 | |
---|
45 | .setup = [ |
---|
46 | common.prepend-path-variable-command PYTHONPATH |
---|
47 | : $(.docutils-dir) $(.docutils-dir)/extras ] ; |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | rule html ( target : source : properties * ) |
---|
52 | { |
---|
53 | docutils-dir on $(target) = $(.docutils-dir) ; |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | feature docutils : : free ; |
---|
58 | feature docutils-html : : free ; |
---|
59 | toolset.flags docutils COMMON-FLAGS : <docutils> ; |
---|
60 | toolset.flags docutils HTML-FLAGS : <docutils-html> ; |
---|
61 | |
---|
62 | actions html |
---|
63 | { |
---|
64 | $(.setup) |
---|
65 | python $(docutils-dir)/tools/rst2html.py $(COMMON-FLAGS) $(HTML-FLAGS) $(>) $(<) |
---|
66 | } |
---|
67 | |
---|