reanimate/docs/render_all.sh
David Himmelstrup 23146429a5 Documentation. (#12)
* First docs.

* Docs requirements.

* Add auto-generated gallery and fix two bugs in the driver.

* Gallery: link directly to github.

* Tag examples as Haskell code.

* Update starting guide and redirect gallery links to master branch.

* Include link to readthedocs.


Former-commit-id: 90e846e5001deadd6c921f611c69b3a4210db30d
2019-09-19 16:52:34 +08:00

44 lines
938 B
Shell
Executable file

#!/usr/bin/env bash
EXAMPLES='boundingbox colormaps goo latex_basic latex_color latex_draw
latex_wheel raster sphere sunflower tangent_and_normal vector_field'
WIDTH=640
HEIGHT=$((WIDTH*9/16))
FPS=30
SRC_DIR=examples
DST_DIR=docs/rendered
OPTS='--fps $FPS --width $WIDTH --height $HEIGHT'
cat << EOF > docs/gallery.md
# Gallery
This file is auto-generated by docs/render_all.sh. DO NOT EDIT.
EOF
for e in $EXAMPLES; do
cat << EOF >> docs/gallery.md
## $e
<details>
<summary>View $e.hs</summary>
<pre><code class="haskell">
{!examples/$e.hs!}
</code></pre>
</details>
<br/>
<video width="$WIDTH" height="$HEIGHT" autoplay loop>
<source src="https://github.com/Lemmih/reanimate/raw/master/docs/rendered/$e.mp4">
</video>
<br/><hr><br/>
EOF
SRC_FILE=./$SRC_DIR/$e.hs
DST_FILE=./$DST_DIR/$e.mp4
if [[ "$SRC_FILE" -nt "$DST_FILE" ]]; then
stack $SRC_FILE render --compile -o $DST_FILE $OPTS
fi
done