bundles / papyri 0.0.10 / papyri / directives / make_image_handler
function
papyri.directives:make_image_handler
source: /papyri/directives.py :544
Signature
def make_image_handler ( doc_path : Path | None , asset_store : Callable[[str, bytes], None] | None , module : str , version : str , doc_root : Path | None = None ) → Callable[[str, dict[str, str], str], list[Any]] Summary
Return an .. image:: directive handler bound to the given asset context.
Extended Summary
The returned callable has the standard (argument, options, content) handler signature and can be registered in DirectiveVisiter._handlers like any other handler.
Path resolution rules:
http:///https://URIs →Imagenode (no download).Paths starting with
/→ resolved relative to doc_root (Sphinx absolute-path convention, e.g./_images/foo.png). Falls back to anImagenode with a warning when doc_root isNone.All other paths → resolved relative to doc_path (sibling-relative). Falls back to an
Imagenode with a warning when doc_path isNone.
Parameters
doc_pathDirectory of the RST or Python source file being processed. Used to resolve relative image paths.
Nonedisables local-file embedding for relative paths.asset_storeCallable
(name, data)that stores raw bytes under name in the bundle'sassets/directory.Nonedisables local-file embedding.moduleRoot module name for the bundle (used to build the
RefInfo).versionBundle version string (used to build the
RefInfo).doc_rootRoot of the documentation tree. Used to resolve
/-prefixed (Sphinx-absolute) paths such as/_images/foo.png.Nonedisables resolution of those paths.
Aliases
-
papyri.directives.make_image_handler