@@ -201,16 +201,13 @@ class JupyterWidgetViewNode(docutils.nodes.Element):
201
201
outputs this doctree node is rendered generically.
202
202
"""
203
203
204
- def __init__ (self , view_spec ):
205
- super ().__init__ ('' , view_spec = view_spec )
204
+ def __init__ (self , rawsource = '' , * children , ** attributes ):
205
+ super ().__init__ ('' , view_spec = attributes [ ' view_spec' ] )
206
206
207
207
def html (self ):
208
208
return ipywidgets .embed .widget_view_template .format (
209
209
view_spec = json .dumps (self ['view_spec' ]))
210
210
211
- def text (self ):
212
- return '[ widget ]'
213
-
214
211
215
212
class JupyterWidgetStateNode (docutils .nodes .Element ):
216
213
"""Appended to doctree if any Jupyter cell produced a widget as output.
@@ -223,8 +220,8 @@ class JupyterWidgetStateNode(docutils.nodes.Element):
223
220
from all script tags on the page of the correct mimetype.
224
221
"""
225
222
226
- def __init__ (self , state ):
227
- super ().__init__ ('' , state = state )
223
+ def __init__ (self , rawsource = '' , * children , ** attributes ):
224
+ super ().__init__ ('' , state = attributes [ ' state' ] )
228
225
229
226
def html (self ):
230
227
# TODO: render into a separate file if 'html-manager' starts fully
@@ -323,7 +320,7 @@ def apply(self):
323
320
attach_outputs (output_nodes , node )
324
321
325
322
if contains_widgets (notebook ):
326
- doctree .append (JupyterWidgetStateNode (get_widgets (notebook )))
323
+ doctree .append (JupyterWidgetStateNode (state = get_widgets (notebook )))
327
324
328
325
329
326
### Roles
@@ -448,7 +445,7 @@ def cell_output_to_nodes(cell, data_priority, dir):
448
445
format = 'html' ,
449
446
))
450
447
elif mime_type == WIDGET_VIEW_MIMETYPE :
451
- to_add .append (JupyterWidgetViewNode (data ))
448
+ to_add .append (JupyterWidgetViewNode (view_spec = data ))
452
449
453
450
return to_add
454
451
@@ -625,17 +622,13 @@ def visit_widget_html(self, node):
625
622
self .body .append (node .html ())
626
623
raise docutils .nodes .SkipNode
627
624
628
- def visit_widget_text (self , node ):
629
- self .body .append (node .text ())
630
- raise docutils .nodes .SkipNode
631
-
632
625
app .add_node (
633
626
JupyterWidgetViewNode ,
634
627
html = (visit_widget_html , None ),
635
- latex = (visit_widget_text , None ),
636
- textinfo = (visit_widget_text , None ),
637
- text = (visit_widget_text , None ),
638
- man = (visit_widget_text , None ),
628
+ latex = (skip , None ),
629
+ textinfo = (skip , None ),
630
+ text = (skip , None ),
631
+ man = (skip , None ),
639
632
)
640
633
# JupyterWidgetStateNode holds the widget state JSON,
641
634
# but is only rendered in HTML documents.
0 commit comments