Skip to content

Commit c009627

Browse files
committed
Add documentation to contributing for Graphviz, specifying the width of media, and use cards to enhance the display of images.
1 parent a77c542 commit c009627

File tree

2 files changed

+94
-11
lines changed

2 files changed

+94
-11
lines changed

docs/contributing/myst-reference.md

Lines changed: 93 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,54 @@ Use [Shimmer](http://example.com) for cleaner whiter teeth.
102102
#### Images and figures
103103

104104
[Figures](https://docutils.sourceforge.io/docs/ref/rst/directives.html#figure) allow a caption and legend, whereas [images](https://docutils.sourceforge.io/docs/ref/rst/directives.html#images) do not.
105+
However we can {ref}`enhance images with cards <enhance-images-label>` to add a caption and more features.
105106

106107
Use `image` for anything but diagrams.
107108

108109
Use `figure` for diagrams.
109110

110111
Paths to images and figures must resolve in both the main documentation and the submodule's documentation, if present.
111112

112-
For inline images, we use the MyST extension [`html_image`](https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#html-images).
113-
Example syntax is shown below.
114113

115-
```html
116-
You can copy <img alt="Copy icon" src="../../_images/copy.svg" class="inline"> blocks.
117-
```
114+
##### Width of media
118115

119-
Note that the HTML attribute `class` must be set to `inline` to render the image inline at `1rem`.
116+
The main content area of a page in the documentation is 743 pixels wide.
117+
When taking screenshots or videos, resize your browser window, or try to limit the width of your media to 740 pixels.
118+
This will preserve legibility of images.
120119

121-
The above syntax renders as shown below.
122120

123-
> You can copy <img alt="Copy icon" src="/_static/copy.svg" class="inline"> blocks.
121+
(enhance-images-label)=
124122

125-
Images and figures should always include `alt` text.
123+
##### Enhance images
124+
125+
We use cards from the Sphinx extension [`sphinx-design`](https://sphinx-design.readthedocs.io/en/latest/cards.html) to enhance the display and functionality of images.
126+
127+
Cards allow the display of a caption, create a link to the source image to display when it is too large to fit within the documentation page without scaling, and add a border to demarcate the image from the page's white background.
128+
129+
The following MyST example will display as shown below.
130+
131+
`````md
132+
````{card}
133+
```{image} /_static/caching/caching-disabled.png
134+
:alt: Caching Control Panel
135+
:target: /_static/caching/caching-disabled.png
136+
```
137+
+++
138+
_Caching Control Panel_
139+
````
140+
`````
141+
142+
````{card}
143+
```{image} /_static/caching/caching-disabled.png
144+
:alt: Caching Control Panel
145+
:target: /_static/caching/caching-disabled.png
146+
```
147+
+++
148+
_Caching Control Panel_
149+
````
150+
151+
152+
##### Accessibility with `alt` text
126153

127154
From [Web Accessibility In Mind (WebAIM)](https://webaim.org/techniques/alttext/):
128155

@@ -133,6 +160,8 @@ From [Web Accessibility In Mind (WebAIM)](https://webaim.org/techniques/alttext/
133160
134161
Accessibility is part of the [Plone brand and identity](https://plone.org/accessibility).
135162

163+
The following MyST example will display as shown below.
164+
136165
````md
137166
```{image} /_static/standards.png
138167
:alt: XKCD "Standards" comic strip
@@ -143,6 +172,26 @@ Accessibility is part of the [Plone brand and identity](https://plone.org/access
143172
:alt: XKCD "Standards" comic strip
144173
```
145174

175+
176+
##### Inline images
177+
178+
For inline images, we use the MyST extension [`html_image`](https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#html-images).
179+
Example syntax is shown below.
180+
181+
```html
182+
You can copy <img alt="Copy icon" src="../../_images/copy.svg" class="inline"> blocks.
183+
```
184+
185+
Note that the HTML attribute `class` must be set to `inline` to render the image inline at `1rem`.
186+
187+
The above syntax renders as shown below.
188+
189+
> You can copy <img alt="Copy icon" src="/_static/copy.svg" class="inline"> blocks.
190+
191+
Images and figures should always include `alt` text.
192+
193+
The following MyST example will display as shown below.
194+
146195
````md
147196
```{eval-rst}
148197
.. figure:: /_static/voting_flowchart.png
@@ -195,9 +244,9 @@ It is helpful to include overlays of key strokes, and mouse and other input gest
195244

196245
Paths to videos must resolve in both the main documentation and the submodule's documentation, if present.
197246

198-
Example syntax is shown below.
247+
Example MyST syntax is shown below.
199248

200-
````
249+
````md
201250
```{video} /_static/user-manual/blocks/block-copy-cut.mp4
202251
:width: 100%
203252
```
@@ -211,6 +260,39 @@ The above MyST markup renders as shown below.
211260
```
212261

213262

263+
#### Diagrams and graphs with Graphviz
264+
265+
We use [Graphviz](https://graphviz.org/download/) and its Sphinx extension [`sphinx.ext.graphviz`](https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html) to render diagrams and graph visualizations.
266+
267+
The following MyST example will display as shown below.
268+
269+
````markdown
270+
```{eval-rst}
271+
.. graphviz::
272+
:align: center
273+
274+
digraph viewstructure {
275+
{
276+
node [margin=5,shape=box]
277+
}
278+
ZCML -> {Python, Template};
279+
}
280+
```
281+
````
282+
283+
```{eval-rst}
284+
.. graphviz::
285+
:align: center
286+
287+
digraph viewstructure {
288+
{
289+
node [margin=5,shape=box]
290+
}
291+
ZCML -> {Python, Template};
292+
}
293+
```
294+
295+
214296
#### Code block
215297

216298
A Python code snippet without reStructuredText options, using a simple fence.

docs/contributing/sphinx-extensions.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ myst:
1313

1414
We use several Sphinx extensions to enhance the presentation of Plone documentation.
1515

16+
- [`sphinx.ext.graphviz`](https://www.sphinx-doc.org/en/master/usage/extensions/graphviz.html) allows you to embed [Graphviz](https://graphviz.org/download/) graphs in your documents.
1617
- [`sphinx.ext.intersphinx`](https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html) provides linking between separate projects that use Sphinx for documentation.
1718
- [`sphinx.ext.todo`](https://www.sphinx-doc.org/en/master/usage/extensions/todo.html) adds support for todo items.
1819
- [`sphinx_copybutton`](https://sphinx-copybutton.readthedocs.io/en/latest/index.html) adds a little "copy" button to the right of code blocks.

0 commit comments

Comments
 (0)