diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2017-03-06 08:09:27 -0500 |
|---|---|---|
| committer | Jonathan Corbet <corbet@lwn.net> | 2017-03-09 04:59:26 -0500 |
| commit | db6ccf23e8ba40fc2e8914ec9c0eb950df71d9fe (patch) | |
| tree | 2f5646aff5210a2669cdb8a624fc40f2797836d5 /Documentation/doc-guide | |
| parent | c3c53600f62b5fa92acf3a7f5eb71bacb25f6b01 (diff) | |
docs-rst: automatically convert Graphviz and SVG images
This patch brings scalable figure, image handling and a concept to
embed *render* markups:
* DOT (http://www.graphviz.org)
* SVG
For image handling use the 'image' replacement::
.. kernel-image:: svg_image.svg
:alt: simple SVG image
For figure handling use the 'figure' replacement::
.. kernel-figure:: svg_image.svg
:alt: simple SVG image
SVG image example
Embed *render* markups (or languages) like Graphviz's **DOT** is
provided by the *render* directive.::
.. kernel-render:: DOT
:alt: foobar digraph
:caption: Embedded **DOT** (Graphviz) code.
digraph foo {
"bar" -> "baz";
}
The *render* directive is a concept to integrate *render* markups and
languages, yet supported markups:
* DOT: render embedded Graphviz's **DOT**
* SVG: render embedded Scalable Vector Graphics (**SVG**)
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Tested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> (v2 - v5)
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de> (v1, v6)
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Diffstat (limited to 'Documentation/doc-guide')
| -rw-r--r-- | Documentation/doc-guide/hello.dot | 3 | ||||
| -rw-r--r-- | Documentation/doc-guide/sphinx.rst | 98 | ||||
| -rw-r--r-- | Documentation/doc-guide/svg_image.svg | 10 |
3 files changed, 109 insertions, 2 deletions
diff --git a/Documentation/doc-guide/hello.dot b/Documentation/doc-guide/hello.dot new file mode 100644 index 000000000000..504621dfc595 --- /dev/null +++ b/Documentation/doc-guide/hello.dot | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | graph G { | ||
| 2 | Hello -- World | ||
| 3 | } | ||
diff --git a/Documentation/doc-guide/sphinx.rst b/Documentation/doc-guide/sphinx.rst index 532d65b70500..731334de3efd 100644 --- a/Documentation/doc-guide/sphinx.rst +++ b/Documentation/doc-guide/sphinx.rst | |||
| @@ -34,8 +34,9 @@ format-specific subdirectories under ``Documentation/output``. | |||
| 34 | 34 | ||
| 35 | To generate documentation, Sphinx (``sphinx-build``) must obviously be | 35 | To generate documentation, Sphinx (``sphinx-build``) must obviously be |
| 36 | installed. For prettier HTML output, the Read the Docs Sphinx theme | 36 | installed. For prettier HTML output, the Read the Docs Sphinx theme |
| 37 | (``sphinx_rtd_theme``) is used if available. For PDF output, ``rst2pdf`` is also | 37 | (``sphinx_rtd_theme``) is used if available. For PDF output you'll also need |
| 38 | needed. All of these are widely available and packaged in distributions. | 38 | ``XeLaTeX`` and ``convert(1)`` from ImageMagick (https://www.imagemagick.org). |
| 39 | All of these are widely available and packaged in distributions. | ||
| 39 | 40 | ||
| 40 | To pass extra options to Sphinx, you can use the ``SPHINXOPTS`` make | 41 | To pass extra options to Sphinx, you can use the ``SPHINXOPTS`` make |
| 41 | variable. For example, use ``make SPHINXOPTS=-v htmldocs`` to get more verbose | 42 | variable. For example, use ``make SPHINXOPTS=-v htmldocs`` to get more verbose |
| @@ -232,3 +233,96 @@ Rendered as: | |||
| 232 | * .. _`last row`: | 233 | * .. _`last row`: |
| 233 | 234 | ||
| 234 | - column 3 | 235 | - column 3 |
| 236 | |||
| 237 | |||
| 238 | Figures & Images | ||
| 239 | ================ | ||
| 240 | |||
| 241 | If you want to add an image, you should use the ``kernel-figure`` and | ||
| 242 | ``kernel-image`` directives. E.g. to insert a figure with a scalable | ||
| 243 | image format use SVG (:ref:`svg_image_example`):: | ||
| 244 | |||
| 245 | .. kernel-figure:: svg_image.svg | ||
| 246 | :alt: simple SVG image | ||
| 247 | |||
| 248 | SVG image example | ||
| 249 | |||
| 250 | .. _svg_image_example: | ||
| 251 | |||
| 252 | .. kernel-figure:: svg_image.svg | ||
| 253 | :alt: simple SVG image | ||
| 254 | |||
| 255 | SVG image example | ||
| 256 | |||
| 257 | The kernel figure (and image) directive support **DOT** formated files, see | ||
| 258 | |||
| 259 | * DOT: http://graphviz.org/pdf/dotguide.pdf | ||
| 260 | * Graphviz: http://www.graphviz.org/content/dot-language | ||
| 261 | |||
| 262 | A simple example (:ref:`hello_dot_file`):: | ||
| 263 | |||
| 264 | .. kernel-figure:: hello.dot | ||
| 265 | :alt: hello world | ||
| 266 | |||
| 267 | DOT's hello world example | ||
| 268 | |||
| 269 | .. _hello_dot_file: | ||
| 270 | |||
| 271 | .. kernel-figure:: hello.dot | ||
| 272 | :alt: hello world | ||
| 273 | |||
| 274 | DOT's hello world example | ||
| 275 | |||
| 276 | Embed *render* markups (or languages) like Graphviz's **DOT** is provided by the | ||
| 277 | ``kernel-render`` directives.:: | ||
| 278 | |||
| 279 | .. kernel-render:: DOT | ||
| 280 | :alt: foobar digraph | ||
| 281 | :caption: Embedded **DOT** (Graphviz) code | ||
| 282 | |||
| 283 | digraph foo { | ||
| 284 | "bar" -> "baz"; | ||
| 285 | } | ||
| 286 | |||
| 287 | How this will be rendered depends on the installed tools. If Graphviz is | ||
| 288 | installed, you will see an vector image. If not the raw markup is inserted as | ||
| 289 | *literal-block* (:ref:`hello_dot_render`). | ||
| 290 | |||
| 291 | .. _hello_dot_render: | ||
| 292 | |||
| 293 | .. kernel-render:: DOT | ||
| 294 | :alt: foobar digraph | ||
| 295 | :caption: Embedded **DOT** (Graphviz) code | ||
| 296 | |||
| 297 | digraph foo { | ||
| 298 | "bar" -> "baz"; | ||
| 299 | } | ||
| 300 | |||
| 301 | The *render* directive has all the options known from the *figure* directive, | ||
| 302 | plus option ``caption``. If ``caption`` has a value, a *figure* node is | ||
| 303 | inserted. If not, a *image* node is inserted. A ``caption`` is also needed, if | ||
| 304 | you want to refer it (:ref:`hello_svg_render`). | ||
| 305 | |||
| 306 | Embedded **SVG**:: | ||
| 307 | |||
| 308 | .. kernel-render:: SVG | ||
| 309 | :caption: Embedded **SVG** markup | ||
| 310 | :alt: so-nw-arrow | ||
| 311 | |||
| 312 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 313 | <svg xmlns="http://www.w3.org/2000/svg" version="1.1" ...> | ||
| 314 | ... | ||
| 315 | </svg> | ||
| 316 | |||
| 317 | .. _hello_svg_render: | ||
| 318 | |||
| 319 | .. kernel-render:: SVG | ||
| 320 | :caption: Embedded **SVG** markup | ||
| 321 | :alt: so-nw-arrow | ||
| 322 | |||
| 323 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 324 | <svg xmlns="http://www.w3.org/2000/svg" | ||
| 325 | version="1.1" baseProfile="full" width="70px" height="40px" viewBox="0 0 700 400"> | ||
| 326 | <line x1="180" y1="370" x2="500" y2="50" stroke="black" stroke-width="15px"/> | ||
| 327 | <polygon points="585 0 525 25 585 50" transform="rotate(135 525 25)"/> | ||
| 328 | </svg> | ||
diff --git a/Documentation/doc-guide/svg_image.svg b/Documentation/doc-guide/svg_image.svg new file mode 100644 index 000000000000..5405f85b8137 --- /dev/null +++ b/Documentation/doc-guide/svg_image.svg | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <!-- originate: https://commons.wikimedia.org/wiki/File:Variable_Resistor.svg --> | ||
| 3 | <svg xmlns="http://www.w3.org/2000/svg" | ||
| 4 | version="1.1" baseProfile="full" | ||
| 5 | width="70px" height="40px" viewBox="0 0 700 400"> | ||
| 6 | <line x1="0" y1="200" x2="700" y2="200" stroke="black" stroke-width="20px"/> | ||
| 7 | <rect x="100" y="100" width="500" height="200" fill="white" stroke="black" stroke-width="20px"/> | ||
| 8 | <line x1="180" y1="370" x2="500" y2="50" stroke="black" stroke-width="15px"/> | ||
| 9 | <polygon points="585 0 525 25 585 50" transform="rotate(135 525 25)"/> | ||
| 10 | </svg> | ||
