Sphinx Extension to include draw.io files
Project description
sphinxcontrib-drawio
Sphinx Extension to add the drawio
directive to include draw.io diagrams.
Important: This extension is in development and not all features will work as advertised or at all.
The drawio-desktop package does not run without an x-server (e.g. when in a CI
environment), see
this issue.
The workaround is to install xvfb
and set the drawio_headless
config to auto
.
If any other of the draw.io
CLI tool's options are wanted, please file an issue.
Installation
python3 -m pip install sphinxcontrib-drawio
- In your sphinx config:
extensions = [
"sphinxcontrib.drawio"
]
- Add the binary to
$PATH
. For Windows addC:\Program Files\draw.io
and on Linux add/opt/draw.io/
. - (if running headless),
sudo apt install xvfb
Options
These values are placed in the conf.py
of your sphinx project.
Output Format
- Formal Name:
drawio_output_format
- Default Value:
"png"
- Possible Values:
"png"
,"jpg"
, or"svg"
This config option controls the output file format which will be placed inside the generated HTML. More file formats are available but not exposed, please file an issue if you wish to add another file format.
Binary Path
- Formal Name:
drawio_binary_path
- Default Value:
None
This allows for a specific override for the binary location. By default, this gets chosen depending on the OS (Linux, Mac, or Windows) to the default install path of the draw.io program.
Headless Mode
- Formal Name:
drawio_headless
- Default Value:
"auto"
- Possible Values:
True
,False
, or"auto"
This config option controls the behaviour of running the Xvfb server. It is
necessary because draw.io
will not work without an X-server, see
this issue.
The auto
mode (on unix-like systems) will detect whether the program is
running in a headless environment through the $DISPLAY
environment variable,
and act as if it were set to True
. If running on Windows, or the $DISPLAY
environment variable contains some value (i.e. run in an X-server on a
developer's machine).
Setting the value to True
will start a virtual X framebuffer through the
Xvfb
command before running any draw.io
commands, and stop it afterwards.
Setting the value to False
will run the draw.io
binary as normal.
Usage
The extension can be used through the drawio
directive, as per below:
.. drawio:: example.drawio
The directive can also be configured with a variety of options.
Format
- Formal Name:
:format:
- Default Value:
"png"
- Possible Values:
"png"
,"jpg"
, or"svg"
This option controls the output file format of this specific directive. It
provides similar functionality to that of the drawio_output_format
config
option but at a more granular level.
Alt Text
- Formal Name:
:alt:
This option sets the img tag's alt
attribute. For more information on its
functionality, see the Mozilla web documentation.
Format
- Formal Name:
:format:
- Default Value:
"png"
- Possible Values:
"png"
,"jpg"
, or"svg"
This option controls the output file format of this specific directive. It
provides similar functionality to that of the drawio_output_format
config
option but at a more granular level.
Alignment
- Formal Name:
:align:
- Possible Values:
"left"
,"center"
, or"right"
This option allows control over the alignment of the image on the page.
Page Index
- Formal Name:
:page-index:
- Default Value:
0
- Possible Values: any integer
This option allows you to select a particular page from a draw.io file to create the image from.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sphinxcontrib-drawio-0.0.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 537c6a5356d58332bdb25d3b5bd291c50051b98cb8a9f469fe5ca0f66379f223 |
|
MD5 | 6a9d755eed7ccb485355301385dd10f3 |
|
BLAKE2b-256 | 1f39c17d97f3f3d7e63bcc6d64e361457101f0c5f07ad144b7d466ee0e4dfa36 |
Hashes for sphinxcontrib_drawio-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f8bd4544d2dfaf2b00fc27ab1be34582ba2b2dc1fade333ef8a5e3c6f00f186 |
|
MD5 | 46bb2c56a2c239ccec0b5f776fe23d35 |
|
BLAKE2b-256 | f1690e7450265fd463145531c714dff0fe248cfccbc199f98a68244100753d3f |