Skip to content

Commit 406189e

Browse files
authored
Merge pull request plone#1462 from plone/contrib-card-image
Add documentation to contributing for Graphviz, specifying the width …
2 parents 1c1b480 + 0313bff commit 406189e

File tree

2 files changed

+114
-17
lines changed

2 files changed

+114
-17
lines changed

docs/contributing/myst-reference.md

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,30 +99,69 @@ Use [Shimmer](http://example.com) for cleaner whiter teeth.
9999
Use [Shimmer](http://example.com) for cleaner whiter teeth.
100100

101101

102-
#### Images and figures
102+
### 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

110-
Paths to images and figures must resolve in both the main documentation and the submodule's documentation, if present.
111111

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.
112+
(static-assets-label)=
114113

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

119-
Note that the HTML attribute `class` must be set to `inline` to render the image inline at `1rem`.
116+
When the documentation is in a submodule, paths to static assets—including, images, figures, and videos—must resolve in both the main documentation and the submodule's documentation.
120117

121-
The above syntax renders as shown below.
118+
Inside the `docs` directory, place static assets in the `/_static/` directory, and preferably inside a subdirectory named after the part or page of the documentation.
119+
For example, in the `volto` submodule, inside its `src/docs` directory, place an image at `/_static/user-manual/block-left-add-icon.png`.
120+
In your markup, use that same `docs`-root-relative path for the target, such as `/_static/user-manual/block-left-add-icon.png`.
121+
Don't use file-relative paths.
122122

123-
> You can copy <img alt="Copy icon" src="/_static/copy.svg" class="inline"> blocks.
123+
Configuration in the `conf.py` files for the main documentation and its submodules handle the resolution of `docs`-root-relative paths for you.
124124

125-
Images and figures should always include `alt` text.
125+
126+
#### Width of media
127+
128+
The main content area of a page in the documentation is 743 pixels wide.
129+
When taking screenshots or videos, resize your browser window, or try to limit the width of your media to 740 pixels.
130+
This will preserve legibility of images.
131+
132+
133+
(enhance-images-label)=
134+
135+
#### Enhance images
136+
137+
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.
138+
139+
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.
140+
141+
The following MyST example will display as shown below.
142+
143+
`````md
144+
````{card}
145+
```{image} /_static/caching/caching-disabled.png
146+
:alt: Caching Control Panel
147+
:target: /_static/caching/caching-disabled.png
148+
```
149+
+++
150+
_Caching Control Panel_
151+
````
152+
`````
153+
154+
````{card}
155+
```{image} /_static/caching/caching-disabled.png
156+
:alt: Caching Control Panel
157+
:target: /_static/caching/caching-disabled.png
158+
```
159+
+++
160+
_Caching Control Panel_
161+
````
162+
163+
164+
#### Accessibility with `alt` text
126165

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

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

175+
The following MyST example will display as shown below.
176+
136177
````md
137178
```{image} /_static/standards.png
138179
:alt: XKCD "Standards" comic strip
@@ -143,6 +184,26 @@ Accessibility is part of the [Plone brand and identity](https://plone.org/access
143184
:alt: XKCD "Standards" comic strip
144185
```
145186

187+
188+
#### Inline images
189+
190+
For inline images, we use the MyST extension [`html_image`](https://myst-parser.readthedocs.io/en/latest/syntax/optional.html#html-images).
191+
Example syntax is shown below.
192+
193+
```html
194+
You can copy <img alt="Copy icon" src="../../_images/copy.svg" class="inline"> blocks.
195+
```
196+
197+
Note that the HTML attribute `class` must be set to `inline` to render the image inline at `1rem`.
198+
199+
The above syntax renders as shown below.
200+
201+
> You can copy <img alt="Copy icon" src="/_static/copy.svg" class="inline"> blocks.
202+
203+
Images and figures should always include `alt` text.
204+
205+
The following MyST example will display as shown below.
206+
146207
````md
147208
```{eval-rst}
148209
.. figure:: /_static/voting_flowchart.png
@@ -182,7 +243,7 @@ Accessibility is part of the [Plone brand and identity](https://plone.org/access
182243
```
183244

184245

185-
#### Video
246+
### Video
186247

187248
To embed local videos, such as recordings of demonstrating the user interface, we require that the videos be saved as `.mp4` for greatest compatibility, usability, accessibility, and reduced file size.
188249

@@ -194,24 +255,59 @@ If you include audio, it is helpful to include closed captions or a transcript.
194255
It is helpful to include overlays of key strokes, and mouse and other input gestures, to describe how to interact with the user interface.
195256

196257
Paths to videos must resolve in both the main documentation and the submodule's documentation, if present.
258+
See {ref}`static-assets-label` for details.
197259

198-
Example syntax is shown below.
260+
Example MyST syntax is shown below.
199261

200-
````
262+
````md
201263
```{video} /_static/user-manual/blocks/block-copy-cut.mp4
202264
:width: 100%
203265
```
204266
````
205267

206268
Note that the path must be absolute to support both submodules and the main documentation.
269+
Don't use file-relative paths.
207270
The above MyST markup renders as shown below.
208271

209272
```{video} /_static/user-manual/blocks/block-copy-cut.mp4
210273
:width: 100%
211274
```
212275

213276

214-
#### Code block
277+
### Diagrams and graphs with Graphviz
278+
279+
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.
280+
281+
The following MyST example will display as shown below.
282+
283+
````markdown
284+
```{eval-rst}
285+
.. graphviz::
286+
:align: center
287+
288+
digraph viewstructure {
289+
{
290+
node [margin=5,shape=box]
291+
}
292+
ZCML -> {Python, Template};
293+
}
294+
```
295+
````
296+
297+
```{eval-rst}
298+
.. graphviz::
299+
:align: center
300+
301+
digraph viewstructure {
302+
{
303+
node [margin=5,shape=box]
304+
}
305+
ZCML -> {Python, Template};
306+
}
307+
```
308+
309+
310+
### Code block
215311

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

@@ -251,7 +347,7 @@ print("my 1st line")
251347
print(f"my {a}nd line")
252348
```
253349

254-
#### Escape literal backticks inline
350+
### Escape literal backticks inline
255351

256352
```md
257353
This is MyST syntax for term ``{term}`React` ``
@@ -260,7 +356,7 @@ This is MyST syntax for term ``{term}`React` ``
260356
This is MyST syntax for term ``{term}`React` ``
261357

262358

263-
#### Glossary terms
359+
### Glossary terms
264360

265361
Add a term to the {ref}`glossary-label`, located at {file}`/glossary.md`.
266362

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)