Skip to main content

metapensiero.sphinx.d2

Sphinx d2lang extension

This is a very simple extension to Sphinx that implements a d2 directive to draw diagrams using d2.

To use it, first of all you must register the extension within the Sphinx environment, adding the full name of the package to the extensions list in the file conf.py, for example:

# Add any Sphinx extension module names here, as strings.
extensions = ['metapensiero.sphinx.d2']

You can optionally define the following default settings:

d2_center

Default value for the :center: option

d2_class

Default CSS class of the diagram, when producing HTML

d2_dark_theme

Default value for the :dark_theme: option

d2_format

Default value for the :format: option

d2_layout

Default value for the :layout: option

d2_pad

Default value for the :pad: option

d2_redirect_links_to_blank_page

Default value for the :redirect_links_to_blank_page: option

d2_scale

Default value for the :scale: option

d2_sketch

Default value for the :sketch: option

d2_theme

Default value for the :theme: option

At that point you can place d2 directives in your documents. The d2 script can be specified either inline, as the content of the directive, or as a file, relative to the document itself. The directive accepts the following options:

align

the alignment of the generated image

alt

the alternative textual description explaining the diagram

caption

a short description of the diagram

center

a boolean value, whether the diagram should be horizontally centered or not

class

the CSS classes of the diagram

dark_theme

an integer, the dark theme to be used

format

the output format, by default svg, but it can alternatively set to png

layout

the algorithm used to layout the diagram, either dagre (the default) or elk

pad

an integer number of pixels, by default 100

redirect_links_to_blank_page

when generating SVG, this forces all local link to be opened in a different browser tab

scale

a float number, the relative scale to be used

sketch

a boolean value, whether to enable the sketch mode

theme

an integer, the theme to be used

width

an integer value, the width of the containing figure

Directive-specific options have higher priority on default settings.

See example/index.rst for some usage examples.

Metadata

Release files for metapensiero.sphinx.d2 0.10

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

Source distribution (sdist)

Source distribution for metapensiero.sphinx.d2 0.10
File Size Uploaded
metapensiero_sphinx_d2-0.10.tar.gz 10.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for metapensiero.sphinx.d2 0.10
File Interpreter ABI Platform
metapensiero_sphinx_d2-0.10-py3-none-any.whl Python 3 none any Details

Total release size: 17.9 kB

Release files / metapensiero_sphinx_d2-0.10.tar.gz

Download URL metapensiero_sphinx_d2-0.10.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
ebabee43a6cda8a595432296ab25011b8768124255b939470455a7b91f7b6e18
BLAKE2b-256 checksum
How to use checksums
9dfc3939ce1b1e0d100c2e05d48219ab13e3a6df930edd3231e27e8c297081da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.9

Release files / metapensiero_sphinx_d2-0.10-py3-none-any.whl

Download URL metapensiero_sphinx_d2-0.10-py3-none-any.whl
Size 7.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50489db15dfe8be4e6dddfc2716c0999cf6a7d5cf5df5bfd335e96a75527d22d
BLAKE2b-256 checksum
How to use checksums
8ac9afb20afcc47a1cafcc7b8216f92d21daaddf1c6beddaebc45b3eb0b2d6e7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.10 This release

2 release files

0.9

2 release files

0.8

2 release files

0.7

2 release files

0.6

2 release files

0.5

2 release files

0.4

2 release files

0.3

2 release files

0.2

2 release files

0.1

2 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