doxtr-drawio 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- doxtr_drawio-0.1.0/LICENSE +19 -0
- doxtr_drawio-0.1.0/MANIFEST.in +6 -0
- doxtr_drawio-0.1.0/PKG-INFO +270 -0
- doxtr_drawio-0.1.0/README.md +248 -0
- doxtr_drawio-0.1.0/dev-requirements.txt +2 -0
- doxtr_drawio-0.1.0/doxtr_drawio.egg-info/PKG-INFO +270 -0
- doxtr_drawio-0.1.0/doxtr_drawio.egg-info/SOURCES.txt +76 -0
- doxtr_drawio-0.1.0/doxtr_drawio.egg-info/dependency_links.txt +1 -0
- doxtr_drawio-0.1.0/doxtr_drawio.egg-info/requires.txt +1 -0
- doxtr_drawio-0.1.0/doxtr_drawio.egg-info/top_level.txt +1 -0
- doxtr_drawio-0.1.0/requirements.txt +3 -0
- doxtr_drawio-0.1.0/setup.cfg +36 -0
- doxtr_drawio-0.1.0/setup.py +5 -0
- doxtr_drawio-0.1.0/sphinxcontrib/drawio/__init__.py +456 -0
- doxtr_drawio-0.1.0/sphinxcontrib/drawio/drawio.css +8 -0
- doxtr_drawio-0.1.0/tests/conftest.py +128 -0
- doxtr_drawio-0.1.0/tests/roots/test-align/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-align/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-align/index.rst +11 -0
- doxtr_drawio-0.1.0/tests/roots/test-alt/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-alt/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-alt/index.rst +3 -0
- doxtr_drawio-0.1.0/tests/roots/test-bad-config/conf.py +9 -0
- doxtr_drawio-0.1.0/tests/roots/test-bad-config/index.rst +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-bad-config2/conf.py +9 -0
- doxtr_drawio-0.1.0/tests/roots/test-bad-config2/index.rst +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-figure/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-figure/conf.py +9 -0
- doxtr_drawio-0.1.0/tests/roots/test-figure/index.rst +9 -0
- doxtr_drawio-0.1.0/tests/roots/test-image/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-image/circle.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-image/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-image/index.rst +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-imgconverter/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-imgconverter/conf.py +9 -0
- doxtr_drawio-0.1.0/tests/roots/test-imgconverter/index.rst +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-layer-not-exist/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-layer-not-exist/index.rst +4 -0
- doxtr_drawio-0.1.0/tests/roots/test-layer-not-exist/layers.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-layer-selection/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-layer-selection/index.rst +23 -0
- doxtr_drawio-0.1.0/tests/roots/test-layer-selection/layers.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-index/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-index/index.rst +18 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-index/pages.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-index-out-of-range/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-index-out-of-range/index.rst +4 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-index-out-of-range/pages.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-name/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-name/index.rst +10 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-name/pages.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-name-and-page-index/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-name-and-page-index/index.rst +5 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-name-and-page-index/pages.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-name-not-exist/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-name-not-exist/index.rst +5 -0
- doxtr_drawio-0.1.0/tests/roots/test-page-name-not-exist/pages.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-reference/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-reference/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-reference/index.rst +2 -0
- doxtr_drawio-0.1.0/tests/roots/test-scale/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-scale/conf.py +10 -0
- doxtr_drawio-0.1.0/tests/roots/test-scale/index.rst +18 -0
- doxtr_drawio-0.1.0/tests/roots/test-transparency/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-transparency/conf.py +9 -0
- doxtr_drawio-0.1.0/tests/roots/test-transparency/index.rst +10 -0
- doxtr_drawio-0.1.0/tests/roots/test-warnings/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-warnings/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-warnings/index.rst +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-width-height/box.drawio +1 -0
- doxtr_drawio-0.1.0/tests/roots/test-width-height/conf.py +7 -0
- doxtr_drawio-0.1.0/tests/roots/test-width-height/index.rst +11 -0
- doxtr_drawio-0.1.0/tests/test_caching.py +25 -0
- doxtr_drawio-0.1.0/tests/test_compat.py +29 -0
- doxtr_drawio-0.1.0/tests/test_options.py +182 -0
- doxtr_drawio-0.1.0/tests/test_pdf.py +34 -0
- doxtr_drawio-0.1.0/tests/test_update.py +31 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (c) 2019 Modelmat
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
15
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
16
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
18
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
19
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: doxtr-drawio
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Doxtr-maintained Sphinx extension to include draw.io files (fork of sphinxcontrib-drawio)
|
|
5
|
+
Home-page: https://github.com/doxtr/doxtr-drawio
|
|
6
|
+
Author: Modelmat
|
|
7
|
+
Author-email: modelmat@outlook.com.au
|
|
8
|
+
Maintainer: Jens Frey
|
|
9
|
+
License: MIT
|
|
10
|
+
Project-URL: Homepage, https://github.com/doxtr/doxtr-drawio
|
|
11
|
+
Project-URL: Repository, https://github.com/doxtr/doxtr-drawio
|
|
12
|
+
Project-URL: Upstream, https://github.com/Modelmat/sphinxcontrib-drawio
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Framework :: Sphinx :: Extension
|
|
17
|
+
Requires-Python: >=3.6
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: sphinx>=2
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
# doxtr-drawio
|
|
24
|
+
|
|
25
|
+
Doxtr-maintained fork of `sphinxcontrib-drawio`, providing a Sphinx Extension adding the `drawio-image` and `drawio-figure` directives.
|
|
26
|
+
These are equivalent to the standard `image` and `figure` directives, but
|
|
27
|
+
accept the path to a `.drawio` file and additional options to control
|
|
28
|
+
exporting of the diagram to a suitable image format.
|
|
29
|
+
|
|
30
|
+
**Important:** This extension does not work on readthedocs as RTD does not allow
|
|
31
|
+
packages (e.g. drawio) to be installed. If you only require diagrams in a single
|
|
32
|
+
format, you can consider using editable SVGs or PNGs, accessible through
|
|
33
|
+
draw.io's File > Export menu.
|
|
34
|
+
|
|
35
|
+
The drawio-desktop package does not run without an x-server (e.g. when in a CI
|
|
36
|
+
environment), see [this issue](https://github.com/jgraph/drawio-desktop/issues/146).
|
|
37
|
+
The workaround is to install `xvfb` and set the `drawio_headless` configuration
|
|
38
|
+
option to `auto`.
|
|
39
|
+
|
|
40
|
+
If any other of the `draw.io` CLI tool's options are wanted, please file an
|
|
41
|
+
issue.
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
1. `python3 -m pip install doxtr-drawio`
|
|
46
|
+
2. In your sphinx config, add:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
extensions = [
|
|
50
|
+
"sphinxcontrib.drawio"
|
|
51
|
+
]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
3. Add the draw.io binary to `$PATH`. See [Options: Binary Path](#binary-path)
|
|
55
|
+
for more details and alternative solutions.
|
|
56
|
+
|
|
57
|
+
4. If running headless, install Xvfb, e.g. via `$ sudo apt install xvfb`.
|
|
58
|
+
|
|
59
|
+
## Options
|
|
60
|
+
These values are placed in the `conf.py` of your sphinx project.
|
|
61
|
+
|
|
62
|
+
### Binary Path
|
|
63
|
+
- *Formal Name*: `drawio_binary_path`
|
|
64
|
+
- *Default Value*: `None`
|
|
65
|
+
|
|
66
|
+
This allows for a specific override for the binary location. By default, this
|
|
67
|
+
chooses the `drawio` (or `draw.io.exe`) binary accessible in `$PATH`. However,
|
|
68
|
+
if this file does not exist, it picks the platform-appropriate path:
|
|
69
|
+
|
|
70
|
+
- Windows: `C:\Program Files\draw.io\draw.io.exe`
|
|
71
|
+
- Linux: `/opt/drawio/drawio` or `/opt/draw.io/drawio` (older versions)
|
|
72
|
+
- MacOS: `/Applications/draw.io.app/Contents/MacOS/draw.io`.
|
|
73
|
+
|
|
74
|
+
### Headless Mode
|
|
75
|
+
- *Formal Name*: `drawio_headless`
|
|
76
|
+
- *Default Value*: `"auto"`
|
|
77
|
+
- *Possible Values*: `True`, `False`, or `"auto"`
|
|
78
|
+
|
|
79
|
+
This config option controls the behaviour of running the Xvfb server. It is
|
|
80
|
+
necessary because `draw.io` will not work without an X-server, see
|
|
81
|
+
[this issue](https://github.com/jgraph/drawio-desktop/issues/146).
|
|
82
|
+
|
|
83
|
+
The `auto` mode will detect whether the program is running in a headless
|
|
84
|
+
environment through the `$DISPLAY` environment variable, and act as if it were
|
|
85
|
+
set to `True`. If not running on Linux, or the `$DISPLAY` environment variable
|
|
86
|
+
contains some value (i.e. running in an X-server on a developer's machine), it
|
|
87
|
+
will act as it it were set to `False`.
|
|
88
|
+
|
|
89
|
+
Setting the value to `True` will start a virtual X framebuffer through the
|
|
90
|
+
`Xvfb` command before running any `draw.io` commands, and stop it afterwards.
|
|
91
|
+
|
|
92
|
+
Setting the value to `False` will run the `draw.io` binary as normal.
|
|
93
|
+
|
|
94
|
+
### Default Output Format
|
|
95
|
+
- *Formal Name*: `drawio_builder_export_format`
|
|
96
|
+
- *Default Value*: `{}`
|
|
97
|
+
|
|
98
|
+
This config option controls the default export file format for each Sphinx
|
|
99
|
+
builder. It accepts a dictionary mapping builder names to image formats. The
|
|
100
|
+
builder name should match the name of a [Sphinx builder](https://www.sphinx-doc.org/en/master/usage/builders/index.html)
|
|
101
|
+
(e.g., `"html"`, `"latex"`). Accepted values for the export format are `"png"`,
|
|
102
|
+
`"jpg"`, `"svg"` and `"pdf"`. If no format is set for a given builder, its
|
|
103
|
+
preferred image format is used, that is, the first format listed in a builder's
|
|
104
|
+
_supported_image_types_ that draw.io is capable of exporting to (eg. SVG for
|
|
105
|
+
HTML, PDF for LaTeX).
|
|
106
|
+
|
|
107
|
+
### Default Export Scale
|
|
108
|
+
- *Formal Name*: `drawio_default_export_scale`
|
|
109
|
+
- *Default Value*: `100`
|
|
110
|
+
- *Possible Values*: any positive integer
|
|
111
|
+
|
|
112
|
+
This config option sets the default export scale for all diagrams. This scales
|
|
113
|
+
the size of the diagram. So if you take a diagram that by default would output
|
|
114
|
+
a image with a resolution of 50x50 pixels and a scale of 200, you will obtain an
|
|
115
|
+
image with a resolution that is approximately 100x100 pixels. By default draw.io
|
|
116
|
+
*usually* outputs relatively low resolution images, so this setting can be used
|
|
117
|
+
to remedy that.
|
|
118
|
+
|
|
119
|
+
This setting will get automatically overridden if the `scale` is set for a
|
|
120
|
+
individual diagram in the directive. If either `export-width` or `export-height`
|
|
121
|
+
are set for an image, this option will have no effect on the generated image.
|
|
122
|
+
|
|
123
|
+
### Default Transparency
|
|
124
|
+
- *Formal Name*: `drawio_default_transparency`
|
|
125
|
+
- *Default Value*: `False`
|
|
126
|
+
- *Possible Values*: `True` or `False`
|
|
127
|
+
|
|
128
|
+
This changes the background transparency for diagrams exported in *png* format.
|
|
129
|
+
This will be overridden if the transparency is set for a individual diagram in
|
|
130
|
+
the directive. If the output format isn't *png*, it will not affect the image
|
|
131
|
+
exported.
|
|
132
|
+
|
|
133
|
+
### Disable Verbose Electron
|
|
134
|
+
- *Formal Name*: `drawio_disable_verbose_electron`
|
|
135
|
+
- *Default Value*: `False`
|
|
136
|
+
- *Possible Values*: `True` or `False`
|
|
137
|
+
|
|
138
|
+
Electron's verbose logging is turned on by default to help troubleshoot certain
|
|
139
|
+
errors produced by the drawio app, but can be disabled if it causes a logging
|
|
140
|
+
conflict. This option only affects the output when the drawio app errors. See the
|
|
141
|
+
[Electron docs](https://www.electronjs.org/docs/latest/api/command-line-switches#--enable-loggingfile)
|
|
142
|
+
for more info.
|
|
143
|
+
|
|
144
|
+
### Disable Shared Memory Usage
|
|
145
|
+
- *Formal Name*: `drawio_disable_dev_shm_usage`
|
|
146
|
+
- *Default Value*: `False`
|
|
147
|
+
- *Possible Values*: `True` or `False`
|
|
148
|
+
|
|
149
|
+
By default, Docker runs a container with a `/dev/shm` shared memory space of 64MB.
|
|
150
|
+
This is typically too small for Chrome (Electron) and will cause Chrome to throw
|
|
151
|
+
an error. Launching the browser with the `--disable-dev-shm-usage` flag will write
|
|
152
|
+
shared memory files into `/tmp` instead of `/dev/shm`.
|
|
153
|
+
|
|
154
|
+
### Disable GPU
|
|
155
|
+
- *Formal Name*: `drawio_disable_gpu`
|
|
156
|
+
- *Default Value*: `False`
|
|
157
|
+
- *Possible Values*: `True` or `False`
|
|
158
|
+
|
|
159
|
+
By default, Chrome (Electron) uses GPU processes which can cause errors when
|
|
160
|
+
running in environments that are not set up for it. This option disables those
|
|
161
|
+
GPU processes and uses the CPU instead.
|
|
162
|
+
|
|
163
|
+
### No Sandbox
|
|
164
|
+
- *Formal Name*: `drawio_no_sandbox`
|
|
165
|
+
- *Default Value*: `False`
|
|
166
|
+
- *Possible Values*: `True` or `False`
|
|
167
|
+
|
|
168
|
+
This option may be needed to work in a docker container. You should probably
|
|
169
|
+
only enable it if you are experiencing issues. See https://github.com/jgraph/drawio-desktop/issues/144
|
|
170
|
+
for more info.
|
|
171
|
+
|
|
172
|
+
## Usage
|
|
173
|
+
The extension can be used through the `drawio-image` directive. For example:
|
|
174
|
+
```
|
|
175
|
+
.. drawio-image:: example.drawio
|
|
176
|
+
:export-scale: 150
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
There's also a `drawio-figure` directive that mimics the `figure` directive:
|
|
180
|
+
```
|
|
181
|
+
.. drawio-figure:: example.drawio
|
|
182
|
+
:format: png
|
|
183
|
+
|
|
184
|
+
An example diagram
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The directives can be configured with options to control the export of the
|
|
188
|
+
draw.io diagram to a bitmap or vector image. These options are documented below.
|
|
189
|
+
|
|
190
|
+
Additionally, `drawio-image` accepts all of the options supported by the
|
|
191
|
+
[image directive](https://docutils.sourceforge.io/docs/ref/rst/directives.html#image).
|
|
192
|
+
These options apply to the image as exported by draw.io. Similarly,
|
|
193
|
+
`drawio-figure` accepts all options supported by the [figure directive](https://docutils.sourceforge.io/docs/ref/rst/directives.html#figure).
|
|
194
|
+
|
|
195
|
+
### Format
|
|
196
|
+
- *Formal Name*: `:format:`
|
|
197
|
+
- *Default Value*: `"png"`
|
|
198
|
+
- *Possible Values*: `"png"`, `"jpg"`, `"svg"` or `"pdf"`
|
|
199
|
+
|
|
200
|
+
This option controls the output file format of *this specific* directive.
|
|
201
|
+
|
|
202
|
+
### Page Index
|
|
203
|
+
- *Formal Name*: `:page-index:`
|
|
204
|
+
- *Default Value*: `0`
|
|
205
|
+
- *Possible Values*: any integer
|
|
206
|
+
|
|
207
|
+
This option allows you to select a particular page from a draw.io file to
|
|
208
|
+
export. Note that an invalid page-index will revert to one of the other valid
|
|
209
|
+
pages (draw.io binary functionality). `page-name` and `page-index` cannot
|
|
210
|
+
coexist, if you set both options, an error will be reported.
|
|
211
|
+
|
|
212
|
+
### Page Name
|
|
213
|
+
- *Formal Name*: `:page-name:`
|
|
214
|
+
- *Default Value*: value of `:page-index:`, else the first page
|
|
215
|
+
- *Possible Values*: any string
|
|
216
|
+
|
|
217
|
+
This option allows you to select a particular page by its name from a draw.io
|
|
218
|
+
file to export. `page-name` and `page-index` cannot coexist, if you set both
|
|
219
|
+
options, an error will be reported. If `:page-name:` is not found in the draw.io
|
|
220
|
+
file, an error will be reported too.
|
|
221
|
+
|
|
222
|
+
### Export Scale
|
|
223
|
+
- *Formal Name*: `:export-scale:`
|
|
224
|
+
- *Default Value*: `drawio_default_export_scale` set in conf.py
|
|
225
|
+
- *Possible Values*: any positive integer
|
|
226
|
+
|
|
227
|
+
This scales the size of the output image. So if you take a diagram that by
|
|
228
|
+
default would output a image with a resolution of 50x50 pixels and a scale of
|
|
229
|
+
200, you will obtain an image with a resolution that is approximately 100x100
|
|
230
|
+
pixels. By default draw.io *usually* outputs relatively low-resolution images,
|
|
231
|
+
so this setting can be used to remedy that. This overrides the
|
|
232
|
+
`drawio_default_export_scale` set in conf.py for this specific diagram. If
|
|
233
|
+
either `export-width` or `export-height` are set for a given image,
|
|
234
|
+
`export-scale` will have no effect on the generated image.
|
|
235
|
+
|
|
236
|
+
### Export Width
|
|
237
|
+
- *Formal Name*: `:export-width:`
|
|
238
|
+
- *Possible Values*: any positive integer
|
|
239
|
+
|
|
240
|
+
This fits the generated image into the specified width, preserving aspect ratio.
|
|
241
|
+
When exporting to a bitmap image, this specifies the width in pixels. For PDF,
|
|
242
|
+
a value of 100 corresponds to 1.00 inches.
|
|
243
|
+
|
|
244
|
+
### Export Height
|
|
245
|
+
- *Formal Name*: `:export-height:`
|
|
246
|
+
- *Possible Values*: any positive integer
|
|
247
|
+
|
|
248
|
+
This fits the generated image into the specified height, preserving aspect
|
|
249
|
+
ratio. When exporting to a bitmap image, this specifies the height in pixels.
|
|
250
|
+
For PDF, a value of 100 corresponds to 1.00 inches.
|
|
251
|
+
|
|
252
|
+
### Transparency
|
|
253
|
+
- *Formal Name*: `:transparency:`
|
|
254
|
+
- *Default Value*: `drawio_default_transparency` set in conf.py
|
|
255
|
+
- *Possible Values*: `"true"` or `"false"`
|
|
256
|
+
|
|
257
|
+
This changes the background transparency for diagrams exported to `png` files.
|
|
258
|
+
Will override `drawio_default_transparency` which was set in conf.py for this
|
|
259
|
+
specific diagram. If this setting is specified while the output format is not
|
|
260
|
+
`png` it will have no effect on the generated image
|
|
261
|
+
|
|
262
|
+
### Layer Selection
|
|
263
|
+
- *Formal Name*: `:layer-selection:`
|
|
264
|
+
- *Possible Values*: comma separated list of integers
|
|
265
|
+
|
|
266
|
+
This option allows you to select one or more layers from a draw.io file to
|
|
267
|
+
export. Note that draw.io uses 0 as the lowest layer, which is usually the
|
|
268
|
+
*Background* layer.
|
|
269
|
+
If not specified, all visible layers will be exported (draw.io binary functionality).
|
|
270
|
+
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# doxtr-drawio
|
|
2
|
+
|
|
3
|
+
Doxtr-maintained fork of `sphinxcontrib-drawio`, providing a Sphinx Extension adding the `drawio-image` and `drawio-figure` directives.
|
|
4
|
+
These are equivalent to the standard `image` and `figure` directives, but
|
|
5
|
+
accept the path to a `.drawio` file and additional options to control
|
|
6
|
+
exporting of the diagram to a suitable image format.
|
|
7
|
+
|
|
8
|
+
**Important:** This extension does not work on readthedocs as RTD does not allow
|
|
9
|
+
packages (e.g. drawio) to be installed. If you only require diagrams in a single
|
|
10
|
+
format, you can consider using editable SVGs or PNGs, accessible through
|
|
11
|
+
draw.io's File > Export menu.
|
|
12
|
+
|
|
13
|
+
The drawio-desktop package does not run without an x-server (e.g. when in a CI
|
|
14
|
+
environment), see [this issue](https://github.com/jgraph/drawio-desktop/issues/146).
|
|
15
|
+
The workaround is to install `xvfb` and set the `drawio_headless` configuration
|
|
16
|
+
option to `auto`.
|
|
17
|
+
|
|
18
|
+
If any other of the `draw.io` CLI tool's options are wanted, please file an
|
|
19
|
+
issue.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
1. `python3 -m pip install doxtr-drawio`
|
|
24
|
+
2. In your sphinx config, add:
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
extensions = [
|
|
28
|
+
"sphinxcontrib.drawio"
|
|
29
|
+
]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
3. Add the draw.io binary to `$PATH`. See [Options: Binary Path](#binary-path)
|
|
33
|
+
for more details and alternative solutions.
|
|
34
|
+
|
|
35
|
+
4. If running headless, install Xvfb, e.g. via `$ sudo apt install xvfb`.
|
|
36
|
+
|
|
37
|
+
## Options
|
|
38
|
+
These values are placed in the `conf.py` of your sphinx project.
|
|
39
|
+
|
|
40
|
+
### Binary Path
|
|
41
|
+
- *Formal Name*: `drawio_binary_path`
|
|
42
|
+
- *Default Value*: `None`
|
|
43
|
+
|
|
44
|
+
This allows for a specific override for the binary location. By default, this
|
|
45
|
+
chooses the `drawio` (or `draw.io.exe`) binary accessible in `$PATH`. However,
|
|
46
|
+
if this file does not exist, it picks the platform-appropriate path:
|
|
47
|
+
|
|
48
|
+
- Windows: `C:\Program Files\draw.io\draw.io.exe`
|
|
49
|
+
- Linux: `/opt/drawio/drawio` or `/opt/draw.io/drawio` (older versions)
|
|
50
|
+
- MacOS: `/Applications/draw.io.app/Contents/MacOS/draw.io`.
|
|
51
|
+
|
|
52
|
+
### Headless Mode
|
|
53
|
+
- *Formal Name*: `drawio_headless`
|
|
54
|
+
- *Default Value*: `"auto"`
|
|
55
|
+
- *Possible Values*: `True`, `False`, or `"auto"`
|
|
56
|
+
|
|
57
|
+
This config option controls the behaviour of running the Xvfb server. It is
|
|
58
|
+
necessary because `draw.io` will not work without an X-server, see
|
|
59
|
+
[this issue](https://github.com/jgraph/drawio-desktop/issues/146).
|
|
60
|
+
|
|
61
|
+
The `auto` mode will detect whether the program is running in a headless
|
|
62
|
+
environment through the `$DISPLAY` environment variable, and act as if it were
|
|
63
|
+
set to `True`. If not running on Linux, or the `$DISPLAY` environment variable
|
|
64
|
+
contains some value (i.e. running in an X-server on a developer's machine), it
|
|
65
|
+
will act as it it were set to `False`.
|
|
66
|
+
|
|
67
|
+
Setting the value to `True` will start a virtual X framebuffer through the
|
|
68
|
+
`Xvfb` command before running any `draw.io` commands, and stop it afterwards.
|
|
69
|
+
|
|
70
|
+
Setting the value to `False` will run the `draw.io` binary as normal.
|
|
71
|
+
|
|
72
|
+
### Default Output Format
|
|
73
|
+
- *Formal Name*: `drawio_builder_export_format`
|
|
74
|
+
- *Default Value*: `{}`
|
|
75
|
+
|
|
76
|
+
This config option controls the default export file format for each Sphinx
|
|
77
|
+
builder. It accepts a dictionary mapping builder names to image formats. The
|
|
78
|
+
builder name should match the name of a [Sphinx builder](https://www.sphinx-doc.org/en/master/usage/builders/index.html)
|
|
79
|
+
(e.g., `"html"`, `"latex"`). Accepted values for the export format are `"png"`,
|
|
80
|
+
`"jpg"`, `"svg"` and `"pdf"`. If no format is set for a given builder, its
|
|
81
|
+
preferred image format is used, that is, the first format listed in a builder's
|
|
82
|
+
_supported_image_types_ that draw.io is capable of exporting to (eg. SVG for
|
|
83
|
+
HTML, PDF for LaTeX).
|
|
84
|
+
|
|
85
|
+
### Default Export Scale
|
|
86
|
+
- *Formal Name*: `drawio_default_export_scale`
|
|
87
|
+
- *Default Value*: `100`
|
|
88
|
+
- *Possible Values*: any positive integer
|
|
89
|
+
|
|
90
|
+
This config option sets the default export scale for all diagrams. This scales
|
|
91
|
+
the size of the diagram. So if you take a diagram that by default would output
|
|
92
|
+
a image with a resolution of 50x50 pixels and a scale of 200, you will obtain an
|
|
93
|
+
image with a resolution that is approximately 100x100 pixels. By default draw.io
|
|
94
|
+
*usually* outputs relatively low resolution images, so this setting can be used
|
|
95
|
+
to remedy that.
|
|
96
|
+
|
|
97
|
+
This setting will get automatically overridden if the `scale` is set for a
|
|
98
|
+
individual diagram in the directive. If either `export-width` or `export-height`
|
|
99
|
+
are set for an image, this option will have no effect on the generated image.
|
|
100
|
+
|
|
101
|
+
### Default Transparency
|
|
102
|
+
- *Formal Name*: `drawio_default_transparency`
|
|
103
|
+
- *Default Value*: `False`
|
|
104
|
+
- *Possible Values*: `True` or `False`
|
|
105
|
+
|
|
106
|
+
This changes the background transparency for diagrams exported in *png* format.
|
|
107
|
+
This will be overridden if the transparency is set for a individual diagram in
|
|
108
|
+
the directive. If the output format isn't *png*, it will not affect the image
|
|
109
|
+
exported.
|
|
110
|
+
|
|
111
|
+
### Disable Verbose Electron
|
|
112
|
+
- *Formal Name*: `drawio_disable_verbose_electron`
|
|
113
|
+
- *Default Value*: `False`
|
|
114
|
+
- *Possible Values*: `True` or `False`
|
|
115
|
+
|
|
116
|
+
Electron's verbose logging is turned on by default to help troubleshoot certain
|
|
117
|
+
errors produced by the drawio app, but can be disabled if it causes a logging
|
|
118
|
+
conflict. This option only affects the output when the drawio app errors. See the
|
|
119
|
+
[Electron docs](https://www.electronjs.org/docs/latest/api/command-line-switches#--enable-loggingfile)
|
|
120
|
+
for more info.
|
|
121
|
+
|
|
122
|
+
### Disable Shared Memory Usage
|
|
123
|
+
- *Formal Name*: `drawio_disable_dev_shm_usage`
|
|
124
|
+
- *Default Value*: `False`
|
|
125
|
+
- *Possible Values*: `True` or `False`
|
|
126
|
+
|
|
127
|
+
By default, Docker runs a container with a `/dev/shm` shared memory space of 64MB.
|
|
128
|
+
This is typically too small for Chrome (Electron) and will cause Chrome to throw
|
|
129
|
+
an error. Launching the browser with the `--disable-dev-shm-usage` flag will write
|
|
130
|
+
shared memory files into `/tmp` instead of `/dev/shm`.
|
|
131
|
+
|
|
132
|
+
### Disable GPU
|
|
133
|
+
- *Formal Name*: `drawio_disable_gpu`
|
|
134
|
+
- *Default Value*: `False`
|
|
135
|
+
- *Possible Values*: `True` or `False`
|
|
136
|
+
|
|
137
|
+
By default, Chrome (Electron) uses GPU processes which can cause errors when
|
|
138
|
+
running in environments that are not set up for it. This option disables those
|
|
139
|
+
GPU processes and uses the CPU instead.
|
|
140
|
+
|
|
141
|
+
### No Sandbox
|
|
142
|
+
- *Formal Name*: `drawio_no_sandbox`
|
|
143
|
+
- *Default Value*: `False`
|
|
144
|
+
- *Possible Values*: `True` or `False`
|
|
145
|
+
|
|
146
|
+
This option may be needed to work in a docker container. You should probably
|
|
147
|
+
only enable it if you are experiencing issues. See https://github.com/jgraph/drawio-desktop/issues/144
|
|
148
|
+
for more info.
|
|
149
|
+
|
|
150
|
+
## Usage
|
|
151
|
+
The extension can be used through the `drawio-image` directive. For example:
|
|
152
|
+
```
|
|
153
|
+
.. drawio-image:: example.drawio
|
|
154
|
+
:export-scale: 150
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
There's also a `drawio-figure` directive that mimics the `figure` directive:
|
|
158
|
+
```
|
|
159
|
+
.. drawio-figure:: example.drawio
|
|
160
|
+
:format: png
|
|
161
|
+
|
|
162
|
+
An example diagram
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The directives can be configured with options to control the export of the
|
|
166
|
+
draw.io diagram to a bitmap or vector image. These options are documented below.
|
|
167
|
+
|
|
168
|
+
Additionally, `drawio-image` accepts all of the options supported by the
|
|
169
|
+
[image directive](https://docutils.sourceforge.io/docs/ref/rst/directives.html#image).
|
|
170
|
+
These options apply to the image as exported by draw.io. Similarly,
|
|
171
|
+
`drawio-figure` accepts all options supported by the [figure directive](https://docutils.sourceforge.io/docs/ref/rst/directives.html#figure).
|
|
172
|
+
|
|
173
|
+
### Format
|
|
174
|
+
- *Formal Name*: `:format:`
|
|
175
|
+
- *Default Value*: `"png"`
|
|
176
|
+
- *Possible Values*: `"png"`, `"jpg"`, `"svg"` or `"pdf"`
|
|
177
|
+
|
|
178
|
+
This option controls the output file format of *this specific* directive.
|
|
179
|
+
|
|
180
|
+
### Page Index
|
|
181
|
+
- *Formal Name*: `:page-index:`
|
|
182
|
+
- *Default Value*: `0`
|
|
183
|
+
- *Possible Values*: any integer
|
|
184
|
+
|
|
185
|
+
This option allows you to select a particular page from a draw.io file to
|
|
186
|
+
export. Note that an invalid page-index will revert to one of the other valid
|
|
187
|
+
pages (draw.io binary functionality). `page-name` and `page-index` cannot
|
|
188
|
+
coexist, if you set both options, an error will be reported.
|
|
189
|
+
|
|
190
|
+
### Page Name
|
|
191
|
+
- *Formal Name*: `:page-name:`
|
|
192
|
+
- *Default Value*: value of `:page-index:`, else the first page
|
|
193
|
+
- *Possible Values*: any string
|
|
194
|
+
|
|
195
|
+
This option allows you to select a particular page by its name from a draw.io
|
|
196
|
+
file to export. `page-name` and `page-index` cannot coexist, if you set both
|
|
197
|
+
options, an error will be reported. If `:page-name:` is not found in the draw.io
|
|
198
|
+
file, an error will be reported too.
|
|
199
|
+
|
|
200
|
+
### Export Scale
|
|
201
|
+
- *Formal Name*: `:export-scale:`
|
|
202
|
+
- *Default Value*: `drawio_default_export_scale` set in conf.py
|
|
203
|
+
- *Possible Values*: any positive integer
|
|
204
|
+
|
|
205
|
+
This scales the size of the output image. So if you take a diagram that by
|
|
206
|
+
default would output a image with a resolution of 50x50 pixels and a scale of
|
|
207
|
+
200, you will obtain an image with a resolution that is approximately 100x100
|
|
208
|
+
pixels. By default draw.io *usually* outputs relatively low-resolution images,
|
|
209
|
+
so this setting can be used to remedy that. This overrides the
|
|
210
|
+
`drawio_default_export_scale` set in conf.py for this specific diagram. If
|
|
211
|
+
either `export-width` or `export-height` are set for a given image,
|
|
212
|
+
`export-scale` will have no effect on the generated image.
|
|
213
|
+
|
|
214
|
+
### Export Width
|
|
215
|
+
- *Formal Name*: `:export-width:`
|
|
216
|
+
- *Possible Values*: any positive integer
|
|
217
|
+
|
|
218
|
+
This fits the generated image into the specified width, preserving aspect ratio.
|
|
219
|
+
When exporting to a bitmap image, this specifies the width in pixels. For PDF,
|
|
220
|
+
a value of 100 corresponds to 1.00 inches.
|
|
221
|
+
|
|
222
|
+
### Export Height
|
|
223
|
+
- *Formal Name*: `:export-height:`
|
|
224
|
+
- *Possible Values*: any positive integer
|
|
225
|
+
|
|
226
|
+
This fits the generated image into the specified height, preserving aspect
|
|
227
|
+
ratio. When exporting to a bitmap image, this specifies the height in pixels.
|
|
228
|
+
For PDF, a value of 100 corresponds to 1.00 inches.
|
|
229
|
+
|
|
230
|
+
### Transparency
|
|
231
|
+
- *Formal Name*: `:transparency:`
|
|
232
|
+
- *Default Value*: `drawio_default_transparency` set in conf.py
|
|
233
|
+
- *Possible Values*: `"true"` or `"false"`
|
|
234
|
+
|
|
235
|
+
This changes the background transparency for diagrams exported to `png` files.
|
|
236
|
+
Will override `drawio_default_transparency` which was set in conf.py for this
|
|
237
|
+
specific diagram. If this setting is specified while the output format is not
|
|
238
|
+
`png` it will have no effect on the generated image
|
|
239
|
+
|
|
240
|
+
### Layer Selection
|
|
241
|
+
- *Formal Name*: `:layer-selection:`
|
|
242
|
+
- *Possible Values*: comma separated list of integers
|
|
243
|
+
|
|
244
|
+
This option allows you to select one or more layers from a draw.io file to
|
|
245
|
+
export. Note that draw.io uses 0 as the lowest layer, which is usually the
|
|
246
|
+
*Background* layer.
|
|
247
|
+
If not specified, all visible layers will be exported (draw.io binary functionality).
|
|
248
|
+
|