API Reference

This page documents the internal Python API of sphinx-lightbox. The public authoring interface is standard Sphinx image and figure markup plus the .. lightbox:: directive. The Python API below is primarily useful for contributors.

Extension Setup

lightbox.lightbox.setup(app: Sphinx) ExtensionMetadata[source]

Nodes

class lightbox.lightbox.LightboxContainer(rawsource: str = '', *children, **attributes: Any)[source]

Outer wrapper grouping the trigger thumbnail and the overlay.

class lightbox.lightbox.LightboxTrigger(rawsource: str = '', *children, **attributes: Any)[source]

Thumbnail image that opens the lightbox when clicked.

class lightbox.lightbox.LightboxOverlay(rawsource: str = '', *children, **attributes: Any)[source]

Full-size image overlay with caption and close control.

Directive

class lightbox.lightbox.LightboxDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)[source]
final_argument_whitespace = True

May the final argument contain whitespace?

has_content = False

May the directive have content?

option_spec = {'alt': <function unchanged>, 'caption': <function unchanged>, 'class': <function unchanged>, 'latex-width': <function unchanged>, 'percentage': <function positive_int_list>}

Mapping of option names to validator functions.

optional_arguments = 0

Number of optional arguments after the required arguments.

required_arguments = 1

Number of required directive arguments.

Transforms

lightbox.lightbox.transform_lightbox_images(app: Sphinx, doctree: document, docname: str) None[source]

Convert standard image/figure nodes with class lightbox for HTML builds.

Assign per-document gallery metadata to lightbox overlays.