@@ -363,8 +363,8 @@ def attach_outputs(output_nodes, node, thebe_config, cm_language):
363
363
if not node .attributes ["hide_code" ]: # only add css if code is displayed
364
364
node .attributes ["classes" ] = ["jupyter_container" ]
365
365
366
- input_node = _return_first_node_type (node , CellInputNode )
367
- outputbundle_node = _return_first_node_type (node , CellOutputBundleNode )
366
+ input_node = _find_only_child_by_type (node , CellInputNode )
367
+ outputbundle_node = _find_only_child_by_type (node , CellOutputBundleNode )
368
368
output_node = CellOutputNode (classes = ["cell_output" ])
369
369
if thebe_config :
370
370
# Move the source from the input node into the thebe_source node
@@ -425,7 +425,7 @@ def apply(self):
425
425
thebe_config = self .config .jupyter_sphinx_thebelab_config
426
426
427
427
for cell_node in self .document .traverse (JupyterCellNode ):
428
- output_bundle_node = _return_first_node_type (
428
+ output_bundle_node = _find_only_child_by_type (
429
429
cell_node , CellOutputBundleNode
430
430
)
431
431
# Create doctree nodes for cell outputs.
@@ -451,7 +451,7 @@ def apply(self):
451
451
col .process_doc (self .app , node )
452
452
453
453
454
- def _return_first_node_type (node , node_type ):
454
+ def _find_only_child_by_type (node , node_type ):
455
455
found_nodes = list (node .traverse (node_type ))
456
456
if len (found_nodes ) == 0 :
457
457
raise ValueError ("Found no nodes of type %s in node %s" % (node_type , node ))
0 commit comments