shoebot / sphinxcontrib-shoebot

Display graphics from Shoebot in Sphinx Docs
Other
0 stars 0 forks source link

.. -- restructuredtext --

============================= Shoebot extension for Sphinx

:author: Stuart Axon stuaxo2@yahoo.com

About

This extension allows rendering of Shoebot scripts using python_.

It adds the shoebot directive, which renders the script contents into an image and displays it alongside the script source.

Example

This source::

.. shoebot::

    size(100, 100)
    background(.8)
    fill(.3)
    rect(10, 10, 35, 35)
    # see how roundness affects the shape
    rect(55, 10, 35, 35, 0.3)
    rect(10, 55, 35, 35, 0.7)
    rect(55, 55, 35, 35, 1)

will render an image of a rounded rectangle.

The directive 'snapshot' specifies that it will generate a single image.

Options

The size option is used to change the canvas size without including the size() command in the script itself.

.. shoebot::
    :size: 400, 400

    # On a 400x400 canvas draw some rectangles
    nofill()
    strokewidth(20)
    stroke(0.75, 0., 0)
    for i in range(380, 0, -40):
        rect(200-i, 200-i, i*2, i*2)

The ximports option takes care of importing Shoebot libraries, specified in a comma-separated sequence without quotes or brackets.

.. shoebot::
    :ximports: cornu, colors, photobot

Requirements

Shoebot_ should be installed and be in the current python environment.

Installing

Install the module::

$ python setup.py install

Enabling the extension in Sphinx_

Just add sphinxcontrib.shoebot to the list of extensions in the conf.py file. For example::

extensions = ['sphinxcontrib.shoebot']