playground: add rst example

This commit is contained in:
Jérôme Carretero 2013-08-25 15:34:45 -04:00
parent e62d3771e1
commit 45a85542c5
5 changed files with 268 additions and 0 deletions

2
playground/rst/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/build*

173
playground/rst/test.svg Normal file
View File

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="23.594137"
height="23.597517"
id="svg7339"
sodipodi:version="0.32"
inkscape:version="0.48.4 r9939"
sodipodi:docname="test.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1"
inkscape:export-filename="/home/cJ/opt/waf/docs/gfx/waflogo.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<title
id="title3013">waf logo</title>
<defs
id="defs7341" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="6.5953125"
inkscape:cx="40.061576"
inkscape:cy="-6.5618662"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:window-width="1142"
inkscape:window-height="768"
inkscape:window-x="0"
inkscape:window-y="0"
showgrid="false"
fit-margin-top="0"
fit-margin-left="0"
fit-margin-right="0"
fit-margin-bottom="0"
inkscape:window-maximized="0" />
<metadata
id="metadata7344">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>waf logo</dc:title>
<dc:description>License:
cc by-nc
http://creativecommons.org/about/licenses/
</dc:description>
<dc:creator>
<cc:Agent>
<dc:title>Thomas Nagy</dc:title>
</cc:Agent>
</dc:creator>
<dc:rights>
<cc:Agent>
<dc:title>Thomas Nagy</dc:title>
</cc:Agent>
</dc:rights>
<dc:subject>
<rdf:Bag>
<rdf:li>waf</rdf:li>
</rdf:Bag>
</dc:subject>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Capa 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-423.56214,-286.09002)">
<rect
style="fill:#f2e100;fill-opacity:1;stroke:#000000;stroke-width:1.051;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
id="rect6090"
width="22.549196"
height="22.549196"
x="424.08255"
y="286.62332"
inkscape:export-filename="/tmp/waf-128x128.png"
inkscape:export-xdpi="488.13104"
inkscape:export-ydpi="488.13104" />
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="426.62204"
y="296.69394"
id="text7069"
inkscape:export-filename="/tmp/waf-128x128.png"
inkscape:export-xdpi="488.13104"
inkscape:export-ydpi="488.13104"><tspan
sodipodi:role="line"
id="tspan7071"
x="426.62204"
y="296.69394">W</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:round;stroke-opacity:1;font-family:Bitstream Vera Sans"
x="437.11179"
y="296.69394"
id="text7073"
inkscape:export-filename="/tmp/waf-128x128.png"
inkscape:export-xdpi="488.13104"
inkscape:export-ydpi="488.13104"><tspan
sodipodi:role="line"
id="tspan7075"
x="437.11179"
y="296.69394">A</tspan></text>
<text
xml:space="preserve"
style="font-size:10px;font-style:normal;font-weight:normal;fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;font-family:Bitstream Vera Sans"
x="437.26559"
y="306.03296"
id="text7077"
inkscape:export-filename="/tmp/waf-128x128.png"
inkscape:export-xdpi="488.13104"
inkscape:export-ydpi="488.13104"><tspan
sodipodi:role="line"
id="tspan7079"
x="437.26559"
y="306.03296">F</tspan></text>
<g
id="g3220"
transform="translate(34.107143,-4.1071429)"
inkscape:export-filename="/tmp/waf-128x128.png"
inkscape:export-xdpi="488.13104"
inkscape:export-ydpi="488.13104">
<rect
y="310.27875"
x="394.11942"
height="0.32545468"
width="6.2254734"
id="rect3204"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.67729282;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<rect
y="308.00058"
x="394.24146"
height="0.32545468"
width="5.9813371"
id="rect3206"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.67729282;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
<path
transform="matrix(0.6835814,0,0,0.6075154,142.59807,120.18847)"
d="m 374.82143,303.61218 c 0,1.28209 -1.03934,2.32143 -2.32143,2.32143 -1.28209,0 -2.32143,-1.03934 -2.32143,-2.32143 0,-1.28209 1.03934,-2.32143 2.32143,-2.32143 1.28209,0 2.32143,1.03934 2.32143,2.32143 z"
sodipodi:ry="2.3214285"
sodipodi:rx="2.3214285"
sodipodi:cy="303.61218"
sodipodi:cx="372.5"
id="path3208"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.051;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none"
sodipodi:type="arc" />
<rect
transform="matrix(0,1,-1,0,0,0)"
y="-397.30557"
x="304.19296"
height="0.32545468"
width="5.9813371"
id="rect3218"
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.67729282;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.4 KiB

29
playground/rst/test1.rst Normal file
View File

@ -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.

13
playground/rst/test2.rst Normal file
View File

@ -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

51
playground/rst/wscript Normal file
View File

@ -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',
)