|
Boost-Build : |
From: David Abrahams (dave_at_[hidden])
Date: 2004-12-02 17:20:27
I'm trying to do something that ought to be really simple, and getting
jammed up (pun intended).
My aim is to create a docutils tool that can process RestructuredText,
initially into HTML but later into other formats. Here's what I have so
far:
--- docutils.jam ---
# Copyright David Abrahams 2004. 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)
import type ;
import scanner ;
import generators ;
import os ;
import toolset ;
import path ;
.initialized = ;
type.register ReST : rst ;
class rst-scanner : common-scanner
{
rule pattern ( )
{
return "^\\w*\\.\\.\\w+include::\w+(.*)"
"^\\w*\\.\\.\\w+image::\w+(.*)"
"^\\w*\\.\\.\\w+figure::\w+(.*)"
;
}
}
scanner.register rst-scanner : include ;
type.set-scanner ReST : rst-scanner ;
generators.register-standard docutils.html : ReST : HTML ;
rule init ( docutils-dir )
{
docutils-dir ?= [ modules.peek : DOCUTILS_DIR ] ;
if ! $(.initialized)
{
.initialized = true ;
.docutils-dir = [ path.make $(docutils-dir) ] ;
}
}
rule html ( target : source )
{
docutils-dir on $(target) = $(.docutils-dir) ;
}
if [ os.name ] = NT
{
.setup = "set PYTHONPATH="$(.docutils-dir);$(.docutils-dir)\\extras ;
}
else
{
.setup = PYTHONPATH=$(.docutils-dir):"$(.docutils-dir)/extras ;
export PYTHONPATH" ;
}
toolset.flags docutils COMMON-FLAGS : <docutils> ;
toolset.flags docutils HTML-FLAGS : <docutils-html> ;
actions html
{
$(.setup)
python $(.docutils-dir)/tools/rst2html.py $(COMMON-FLAGS)
$(HTML-FLAGS) $(>) $(<)
}
---- end docutils.jam ----
So, did I get this right, and if so, how do I use it in a Jamfile? My
Jamroot looks like:
project mplbook ;
import boostbook ;
for src in [ glob *.rst ]
{
### What goes here?? ###
}
Thanks in advance.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk