Skip to main content

Sphinx d2lang extension

Project description

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_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_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

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

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

metapensiero_sphinx_d2-0.7.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

metapensiero_sphinx_d2-0.7-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file metapensiero_sphinx_d2-0.7.tar.gz.

File metadata

  • Download URL: metapensiero_sphinx_d2-0.7.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for metapensiero_sphinx_d2-0.7.tar.gz
Algorithm Hash digest
SHA256 55668eb544262579b740919a20a4030f2c5ea2d47e85ba16981b9d7016d9b739
MD5 1b05359f5cf4761a85f5cf6f6f54352c
BLAKE2b-256 473cea2215f63af2a34f024d20721e2fbd4d62dd92d713d6512d1175b2ce63bb

See more details on using hashes here.

File details

Details for the file metapensiero_sphinx_d2-0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for metapensiero_sphinx_d2-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7bdfce7d10fbff43d4e3e00c27a255a5144f55b53624a6ca1bfa7ae4e7c11454
MD5 32a224af228527fc9ff76a9cd26ee661
BLAKE2b-256 fa5eed65134a665e4954f7662d7cf0c698e1279227a20a0857d4f8da88c4debb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page