Skip to main content

sphinxcontrib-svgbob Stars

A Sphinx extension to render ASCII diagrams into SVG using Svgbob.

Actions Codecov License Source PyPI Wheel Python Versions PyPI - Implementation Changelog GitHub issues Downloads

🗺️ Overview

Diagrams to be included into Sphinx documentation are commonly described with a dedicated markup language, and converted into an image by Sphinx when the documentation is built. However, this reduces the legibility of the documentation source for readers that are not browsing the HTML version.

Svgbob is a diagramming model implemented in Rust that can convert ASCII diagrams into SVG. Using it allows you to:

  • Keep a textual version of the diagram in your documentation, so that it remains legible.
  • Render a nicer version as SVG for HTML or PDF versions of the documentation.

This Sphinx extension builds Svgbob statically and lets you use it to render ASCII diagrams within Sphinx documentation. Since it does not require any external dependency, it's also suitable to use on readthedocs.org.

🔧 Installing

sphinxcontrib-svgbob can be installed from PyPI, which hosts some pre-built CPython wheels for x86-64 Linux and OSX, as well as the code required to compile from source:

$ pip install sphinxcontrib-svgbob

If a Rust compiler is not available, the setup.py script will attempt to install a temporary copy if the package is compiled on a UNIX system. If it doesn't work, see the documentation on rust-lang.org to learn how to install Rust on your machine.

Then add this extension to the Sphinx extensions in your conf.py file to make the svgbob directive available:

extensions = [
    ...,
    "sphinxcontrib.svgbob",
]

That's it, you're all set!

💡 Example

Use the svgbob directive in a function docstring to show a diagram of what is being computed:

def hamming(x, y):
    """Compute the Hamming distance between two strings.

    Hamming distance between two strings of equal length is the number of
    positions at which the corresponding symbols are different. For instance,
    Hamming distance for a 3-bit string can be computed visually using a
    3-bit binary cube:

    .. svgbob::
       :align: center

                         110              111                          
                            *-----------*      
                           /|          /|
                          / |     011 / |     
                     010 *--+--------*  |
                         |  | 100    |  |
                         |  *--------+--* 101
                         | /         | /
                         |/          |/
                     000 *-----------*  001


    The minimum distance between any two vertices is the Hamming distance
    between the two bit vectors (e.g. 100→011 has distance 3).

    """

When Sphinx (and autodoc) renders the docstring of this function, you'll get the following HTML page (here shown with the Sphinx theme for readthedocs.org):

example1.html.png

And yet, the help(hamming) will still look nice and helpful:

example1.console.png

🔩 Configuration

The svgbob directive supports the following arguments:

  • font-size (integer): the size of the text to be rendered, defaults to 14.
  • font-family: the family of the font used to render the text, defaults to monospace.
  • fill-color (CSS color): the color to use to fill closed shapes.
  • stroke-color (CSS color): the color to use to paint strokes, defaults to black.
  • scale (float): the SVG scale of the figure, defaults to 8.0.
  • align (CSS align value): the alignment of the resulting image.
  • class (HTML class): an arbitrary class to add to the resulting HTML element.

For instance, use the following to use Arial with size 12, to render nicer text in the diagram blocks:

.. svgbob::
   :font-family: Arial
   :font-size: 12

   +-------+       +--------+
   | Hello |------>| World! |
   +-------+       +--------+

example2.svg

💭 Feedback

⚠️ Issue Tracker

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker if you need to report or ask something. If you are filing in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.

🏗️ Contributing

Contributions are more than welcome! See CONTRIBUTING.md for more details.

📚 Alternatives

🔨 Credits

sphinxcontrib-svgbob is developped and maintained by:

The structure of this repository was adapted from the aforementioned sphinxcontrib-kroki repository, as I had no experience setting up a Sphinx extension otherwise.

⚖️ License

This library is provided under the MIT License.

Metadata

Release files for sphinxcontrib-svgbob 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinxcontrib-svgbob 0.3.2
File Size Uploaded
sphinxcontrib_svgbob-0.3.2.tar.gz 21.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for sphinxcontrib-svgbob 0.3.2
File
sphinxcontrib_svgbob-0.3.2-cp38-abi3-win_amd64.whl CPython 3.8 abi3 Windows x86-64 Details
sphinxcontrib_svgbob-0.3.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 abi3 Linux glibc 2.17+ x86-64 Details
sphinxcontrib_svgbob-0.3.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.8 abi3 Linux glibc 2.17+ ARM64 Details
sphinxcontrib_svgbob-0.3.2-cp38-abi3-macosx_11_0_arm64.whl CPython 3.8 abi3 macOS 11.0+ ARM64 Details
sphinxcontrib_svgbob-0.3.2-cp38-abi3-macosx_10_12_x86_64.whl CPython 3.8 abi3 macOS 10.12+ x86-64 Details

Total release size: 2.9 MB

Release files / sphinxcontrib_svgbob-0.3.2.tar.gz

Download URL sphinxcontrib_svgbob-0.3.2.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6b17b278d4a1cb46c85e29b55f75ecd272b4098e7a4e19db3bdab37b426f75cb
BLAKE2b-256 checksum
How to use checksums
997b0961a42fa052935cb8320f4e2590d2d435ba8fe53d7b0d019772516e1def
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 19, 2026.

Transparency log

Release files / sphinxcontrib_svgbob-0.3.2-cp38-abi3-win_amd64.whl

Download URL sphinxcontrib_svgbob-0.3.2-cp38-abi3-win_amd64.whl
Size 482.1 kB
Tags CPython 3.8 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
dbddd1774ac31ef039adff11c294dce0ef94fd6cbbd9565df471d53d862422e5
BLAKE2b-256 checksum
How to use checksums
47660d9a87add8327c53a34da302f4ae6adfb9e5589347426d5cd8ea2118d8a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 19, 2026.

Transparency log

Release files / sphinxcontrib_svgbob-0.3.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL sphinxcontrib_svgbob-0.3.2-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 638.3 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
8fc6aa99ef6b15bddca0b45fda8ce98da2e7d1db1048c6d5721798d906e0d4c2
BLAKE2b-256 checksum
How to use checksums
87bd206a2567e339eeb684a04451188f71c2482170c7c99718bb0887928323fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 19, 2026.

Transparency log

Release files / sphinxcontrib_svgbob-0.3.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL sphinxcontrib_svgbob-0.3.2-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 595.4 kB
Tags CPython 3.8 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
1c4700ca226142b2bdbd213f670aef76185621c22e06f47f2420f143f6971738
BLAKE2b-256 checksum
How to use checksums
50e9f0f4fbe65e3585bf655b270030e158e69cc60b2f4740250db2958257a7ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 19, 2026.

Transparency log

Release files / sphinxcontrib_svgbob-0.3.2-cp38-abi3-macosx_11_0_arm64.whl

Download URL sphinxcontrib_svgbob-0.3.2-cp38-abi3-macosx_11_0_arm64.whl
Size 546.5 kB
Tags CPython 3.8 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
03a05515875fe0ff1c7e7c088605a993d5d915e991f5c9991fef17c874708b3d
BLAKE2b-256 checksum
How to use checksums
5e26607c6ddc76e5f36db0a3d54eee1317206efa442cc51277e454d2d9b26e49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 19, 2026.

Transparency log

Release files / sphinxcontrib_svgbob-0.3.2-cp38-abi3-macosx_10_12_x86_64.whl

Download URL sphinxcontrib_svgbob-0.3.2-cp38-abi3-macosx_10_12_x86_64.whl
Size 580.9 kB
Tags CPython 3.8 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
eae4a846fa81b2fd73ff73daa8bf3612551b289b2d2b79d2f2f1cf887f7f5e2e
BLAKE2b-256 checksum
How to use checksums
1b641d8e8a9410ab2652ee12a437cac23007c9129612e8b7cd0034573b3da20d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 19, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.2 This release

6 release files

0.3.0

30 release files

0.2.1

16 release files

0.2.0

17 release files

0.1.1

23 release files

0.1.0

19 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page