Search code examples
docrestructuredtexttikz

Drawing database schema or state machine figure within RestructuredText


What is a technique or a tool that I can use to draw schema figures within RestructuredText?

I do not want to import png, jpeg,.. for simple stuff.

What I am looking is, a RestructuredText equivalent for TikZ in Latex to draw, e.g., state machine. It greatly speeds up documentation writing.

I use rst2pdf to generate my documents.


Solution

  • I have ended up with graphviz. To keep it simple (without sphinx), I created a Makefile that compiles dot into svg:

    figures/main_components.dot
    main.rst
    Makefile
    

    Makefile:

    generate_figures:
        for f in $$(find . -iname *.dot); do \
            f_dir=$$(dirname $$f); \
            f_name=$$(basename $$f); \
            f_name="$${f_name%.*}";\
            dot -Tsvg $$f -o $$f_dir/$$f_name.svg; \
        done;
    

    In main.rst, I use the svg-s.

    .. figure:: figures/main_components.svg
       :scale: 50%