From 45a85542c5e6d9ce0e275086392898f4f384cd37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Carretero?= Date: Sun, 25 Aug 2013 15:34:45 -0400 Subject: [PATCH] playground: add rst example --- playground/rst/.gitignore | 2 + playground/rst/test.svg | 173 ++++++++++++++++++++++++++++++++++++++ playground/rst/test1.rst | 29 +++++++ playground/rst/test2.rst | 13 +++ playground/rst/wscript | 51 +++++++++++ 5 files changed, 268 insertions(+) create mode 100644 playground/rst/.gitignore create mode 100644 playground/rst/test.svg create mode 100644 playground/rst/test1.rst create mode 100644 playground/rst/test2.rst create mode 100644 playground/rst/wscript diff --git a/playground/rst/.gitignore b/playground/rst/.gitignore new file mode 100644 index 00000000..10f3c3d8 --- /dev/null +++ b/playground/rst/.gitignore @@ -0,0 +1,2 @@ +/build* + diff --git a/playground/rst/test.svg b/playground/rst/test.svg new file mode 100644 index 00000000..cf1f3ed1 --- /dev/null +++ b/playground/rst/test.svg @@ -0,0 +1,173 @@ + + + + waf logo + + + + + + image/svg+xml + + waf logo + License: + cc by-nc + http://creativecommons.org/about/licenses/ + + + + Thomas Nagy + + + + + Thomas Nagy + + + + + waf + + + + + + + + W + A + F + + + + + + + + diff --git a/playground/rst/test1.rst b/playground/rst/test1.rst new file mode 100644 index 00000000..fb7bead9 --- /dev/null +++ b/playground/rst/test1.rst @@ -0,0 +1,29 @@ +######### +Example 1 +######### + +:purpose: demonstrate basic rst processing + +.. figure:: test.svg + :align: center + :width: 50% + + This is a static svg file + +.. figure:: test.png + :align: center + :width: 50% + + This figure is a png file generated + (in the build folder of course). + + As of 2013-08-25, rst2pdf and docutils do not have + some way of specifying include paths, in which includes + are searched. + + So the figure is broken. + + We could generate the figure in the source directory, + but I prefer not having a figure at all for the sake + of cleanleness. + diff --git a/playground/rst/test2.rst b/playground/rst/test2.rst new file mode 100644 index 00000000..84a8d738 --- /dev/null +++ b/playground/rst/test2.rst @@ -0,0 +1,13 @@ +######### +Example 2 +######### + +:purpose: demonstrate rst processing through rst2latex + +.. figure:: test.pdf + :align: center + :width: 50% + + This is a generated pdf file + + diff --git a/playground/rst/wscript b/playground/rst/wscript new file mode 100644 index 00000000..bda5cf85 --- /dev/null +++ b/playground/rst/wscript @@ -0,0 +1,51 @@ +#!/usr/bin/env python + +import os, re, subprocess +from waflib import Options, TaskGen, Utils + +def options(opt): + opt.load('rst') + opt.load('tex') + +def configure(conf): + conf.load('rst') + conf.load('tex') + +def build(bld): + + bld( + features='rst', + target='test1.html', + source='test1.rst', + ) + + bld( + features='rst', + target='test1.pdf', + source='test1.rst', + ) + + for x in bld.path.ant_glob("**/*.svg"): + bld( + rule='inkscape --export-area-drawing --export-png=${TGT[0].bldpath()} ${SRC[0].bldpath()}', + source=x, + target=x.change_ext('.png'), + ) + bld( + rule='inkscape --export-area-drawing --export-pdf=${TGT[0].bldpath()} ${SRC[0].bldpath()}', + source=x, + target=x.change_ext('.pdf'), + ) + + bld( + features='rst', + type='rst2latex', + target='test2.tex', + source='test2.rst', + ) + + bld( + features='tex', + source='test2.tex', + ) +