sphinx_gallery.directives#

Custom Sphinx directives.

Functions#

sphinx_gallery.directives.depart_imgsg_html(self, node)[source]#

HTML depart node visitor function.

Classes#

class sphinx_gallery.directives.ImageSg(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]#

Implements a directive to allow an optional hidpi image.

Meant to be used with the image_srcset configuration option.

e.g.:

.. image-sg:: /plot_types/basic/images/sphx_glr_bar_001.png
    :alt: bar
    :srcset: /plot_types/basic/images/sphx_glr_bar_001.png,
             /plot_types/basic/images/sphx_glr_bar_001_2_00x.png 2.00x
    :class: sphx-glr-single-img

The resulting html is:

<img src="sphx_glr_bar_001_hidpi.png"
    srcset="_images/sphx_glr_bar_001.png,
            _images/sphx_glr_bar_001_2_00x.png 2x",
    alt="bar"
    class="sphx-glr-single-img" />
final_argument_whitespace = False#

May the final argument contain whitespace?

has_content = False#

May the directive have content?

option_spec = {'alt': <function unchanged>, 'class': <function class_option>, 'srcset': <function unchanged>}#

Mapping of option names to validator functions.

optional_arguments = 3#

Number of optional arguments after the required arguments.

required_arguments = 1#

Number of required directive arguments.

run()[source]#

Update node contents.