Output Renderer¶
A Sphinx post-transform, to convert notebook outpus to AST nodes.
-
class
myst_nb.render_outputs.CellOutputsToNodes(document, startnode=None)¶ Bases:
sphinx.transforms.post_transforms.SphinxPostTransformUse the builder context to transform a CellOutputNode into Sphinx nodes.
-
default_priority= 4¶
-
run()¶ main method of post transforms.
Subclasses should override this method instead of
apply().
-
-
exception
myst_nb.render_outputs.MystNbEntryPointError¶ Bases:
sphinx.errors.SphinxError-
category= 'MyST NB Renderer Load'¶
-
-
myst_nb.render_outputs.load_renderer(name) → myst_nb.render_outputs.CellOutputRendererBase¶ Load a renderer, given a name within the
myst_nb.mime_renderentry point group
-
class
myst_nb.render_outputs.CellOutputRendererBase(document: docutils.nodes.document, node: myst_nb.nodes.CellOutputBundleNode, sphinx_dir: str)¶ Bases:
abc.ABCAn abstract base class for rendering Notebook outputs to docutils nodes.
Subclasses should implement the
rendermethod.-
__init__(document: docutils.nodes.document, node: myst_nb.nodes.CellOutputBundleNode, sphinx_dir: str)¶ - Parameters
sphinx_dir – Sphinx “absolute path” to the output folder, so it is a relative path to the source folder prefixed with
/.
-
add_name(node: docutils.nodes.Node, name: str)¶ Append name to node[‘names’].
Also normalize the name string and register it as explicit target.
-
add_source_and_line(*nodes: List[docutils.nodes.Node])¶ Add the source and line recursively to all nodes.
-
cell_output_to_nodes(data_priority: List[str]) → List[docutils.nodes.Node]¶ Convert a jupyter cell with outputs and filenames to doctree nodes.
- Parameters
outputs – a list of outputs from a Jupyter cell
data_priority – media type by priority.
- Returns
list of docutils nodes
-
make_error(error_msg: str) → docutils.nodes.system_message¶ Raise an exception or generate a warning if appropriate, and return a system_message node
-
-
class
myst_nb.render_outputs.CellOutputRenderer(document: docutils.nodes.document, node: myst_nb.nodes.CellOutputBundleNode, sphinx_dir: str)¶ Bases:
myst_nb.render_outputs.CellOutputRendererBase-
render(mime_type: str, output: nbformat.notebooknode.NotebookNode, index: int) → List[docutils.nodes.Node]¶ Take a MIME bundle and MIME type, and return zero or more nodes.
-