ogpy.adapters.sphinx module

OGPy Sphinx adapter.

class ogpy.adapters.sphinx.OGPDomain(env: BuildEnvironment)

Bases: Domain

Domain to manage contents metadata.

This has client and cache store.

property browser_name: str
property caches: dict[str, Tuple[types.Metadata | types.MetadataFuzzy, int]]

Cache storage for OGP metadata.

directives: dict[str, type[Directive]] = {'figure': <class 'ogpy.adapters.sphinx.OGPFigureDirective'>, 'image': <class 'ogpy.adapters.sphinx.OGPImageDirective'>}

directive name -> directive class

label = 'OGPy Image manageent'

domain label: longer, more descriptive (used in messages)

name = 'ogp'

domain name: should be short, but unique

process_doc(env: BuildEnvironment, docname: str, document: nodes.document)

Find images flagged as mark-ogpy and replace uri by metadata.

property use_browser: bool
class ogpy.adapters.sphinx.OGPFigureDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: Figure

Extended directive for og-image as figure style.

User pass content url as arguments instead of image url. In extension process, it converts from content to image.

option_spec = {'align': <function Figure.align>, 'alt': <function unchanged>, 'class': <function class_option>, 'figclass': <function class_option>, 'figwidth': <function Figure.figwidth_value>, 'height': <function length_or_unitless>, 'loading': <function Image.loading>, 'name': <function unchanged>, 'scale': <function percentage>, 'width': <function length_or_percentage_or_unitless>}

Mapping of option names to validator functions.

run()
class ogpy.adapters.sphinx.OGPImageDirective(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine)

Bases: Image

Extended directive for og-image.

User pass content url as arguments instead of image url. In extension process, it converts from content to image.

option_spec = {'align': <function Image.align>, 'alt': <function unchanged>, 'class': <function class_option>, 'height': <function length_or_unitless>, 'loading': <function Image.loading>, 'name': <function unchanged>, 'scale': <function percentage>, 'width': <function length_or_percentage_or_unitless>}

Mapping of option names to validator functions.

run()
ogpy.adapters.sphinx.setup(app: Sphinx)

Entrypoint as Sphinx-extension.