A package to render go diagrams and embed them in reStructuredText documents
rstgo is a package for parsing go diagrams of the style used at the Sensei’s Library and rendering them using reStructuredText. It was designed for embedding dynamically generated images of go games into reST documents, particularly for pelican blogs or sphinx documentation.
The code lives at http://bitbucket.org/cliff/rstgo. Bug reports, feature requests, and contributions are all welcome. If you find the code useful, hop on bitbucket and send me a quick message letting me know.
To use with sphinx, add ‘rstgo.rst’ to your list of extensions.
To use with pelican or another docutils-based system, add the following to your pelican configuration file:
from rstgo import rst rst.setup_docutils()
To use rstgo in standalone rst files, you can use the included rst2html+go.py script, which should get installed onto your PATH.
You can even use rstgo programmatically with go diagrams outside of reStructuredText documents. Just pass a file-like object containing only the text of the diagram to a GoDiagramParser, and then render the image file using a GoDiagram:
from StringIO import StringIO from rstgo import parsers from rstgo import board diagram_text = StringIO("""\ $$ ------- $$ |. 1 .| $$ |X . O| $$ |b a 2| $$ ------- """) parser = parsers.GoDiagramParser() parser.parse(diagram_text) diagram = board.GoDiagram.load_from_parser(parser) diagram.render() diagram.show() diagram.save('diagram.png', 'PNG')
Implemented rendering of sequence moves and letter annotations. Currently, sequence moves have to start with black
Fixed a bug where :alt: argument was unintentionally required.
Fixed pathing and extension loading for usage with Sphinx.
Added release notes to README.txt
Added intro text to README.txt