For the
SVGo workshop I had to document many examples of code+pictures, so I created a workflow to create consistently formatted illustrations of SVGo code and the pictures they produce.
Below is the script that automates the process. The heart of the script is a small Go program,
codepic
which creates a SVG file of code and picture:
Here's the script:
#!/bin/sh
for i in $*
do
base=`basename $i .go`
gofmt -w -spaces -tabindent=false -tabwidth=4 $i &&
goc $base &&
./${base} > ${base}.svg &&
codepic -codeframe=f -font Inconsolata -fs 14 -ls 16 $i > ${base}-slide.svg &&
svg2pdf ${base}-slide.svg
done
for each file the script:
- formats the source
- builds the source
- runs the program and captures its output
- make a slide showing the code and output
- convert the slide to PDF for inclusion in Keynote