API Reference#

MyST-NB-Bokeh enables gluing and pasting Bokeh plots when using the MyST-NB Sphinx extension.

class myst_nb_bokeh.BokehOutputRenderer(*args, **kwargs)#

Bases: MimeRenderPlugin

MyST-NB plugin that renders the custom Bokeh mimetype.

See the MyST-NB docs for further information.

static handle_mime(renderer, data, inline)#

A function that renders a mime type to docutils nodes, or returns None to reject.

Parameters:
Return type:

None | list[Element]

myst_nb_bokeh.JB_BOKEH_MIMETYPE: str = 'application/jupyter-book-bokeh-json'#

The mimetype that we use for JSON output from Bokeh. This is a custom mimetype to avoid conflicting with any actual mimetypes.

myst_nb_bokeh.add_our_configuration(app, _)#

Add the configuration for MyST-NB-Bokeh to the Sphinx configuration.

Designed to be connected to the 'config-inited' Sphinx event to ensure that all configuration sources have been read. The function signature is determined by the Sphinx API.

Parameters:
  • app (Sphinx) – The Sphinx application instance.

  • config – The Sphinx configuration instance.

  • _ (Config)

Return type:

None

myst_nb_bokeh.glue_bokeh(name, variable, display=False)#

Glue Bokeh figures into the cell output.

Parameters:
  • name (ID) – The name to give to the variable in the cell output. This name must be used when pasting this output in other cells.

  • variable (Model) – The object to be inserted into the cell output. Note that the object itself is not stored. Rather, this function inserts the JSON representation of the plot into the cell output, which must then be extracted and shown by the BokehOutputRenderer.

  • display (bool) – If True, the plot will be shown in the output of the cell. Useful for sanity checking the output. False by default.

Return type:

None

myst_nb_bokeh.setup(app)#

Set up the MyST-NB-Bokeh Sphinx extension.

This function is automatically called by Sphinx, as long as this extension is listed in the list of extensions in your Sphinx conf.py file.

Parameters:

app (Sphinx) – The Sphinx application, which is always passed by Sphinx during the initialization process.

Returns:

A dictionary containing the version of this extension.

Return type:

dict[str, str | bool]