1
- """Manipulating the Sphinx AST with Jupyter objects"""
1
+ """Manipulating the Sphinx AST with Jupyter objects. """
2
2
3
3
import json
4
4
import warnings
@@ -34,9 +34,7 @@ def load_content(cell, location, logger):
34
34
env .note_dependency (rel_filename )
35
35
if cell .content :
36
36
logger .warning (
37
- 'Ignoring inline code in Jupyter cell included from "{}"' .format (
38
- rel_filename
39
- ),
37
+ 'Ignoring inline code in Jupyter cell included from "{}"' .format (rel_filename ),
40
38
location = location ,
41
39
)
42
40
try :
@@ -60,9 +58,7 @@ def get_highlights(cell, content, location, logger):
60
58
hl_lines = parselinenos (emphasize_linespec , nlines )
61
59
if any (i >= nlines for i in hl_lines ):
62
60
logger .warning (
63
- "Line number spec is out of range(1-{}): {}" .format (
64
- nlines , emphasize_linespec
65
- ),
61
+ "Line number spec is out of range(1-{}): {}" .format (nlines , emphasize_linespec ),
66
62
location = location ,
67
63
)
68
64
hl_lines = [i + 1 for i in hl_lines if i < nlines ]
@@ -78,7 +74,7 @@ class JupyterCell(Directive):
78
74
executed when the directive is parsed, but later during a doctree
79
75
transformation.
80
76
81
- Arguments
77
+ Arguments:
82
78
---------
83
79
filename : str (optional)
84
80
If provided, a path to a file containing code.
@@ -166,7 +162,7 @@ def run(self):
166
162
class CellInput (Directive ):
167
163
"""Define a code cell to be included verbatim but not executed.
168
164
169
- Arguments
165
+ Arguments:
170
166
---------
171
167
filename : str (optional)
172
168
If provided, a path to a file containing code.
@@ -237,7 +233,7 @@ def run(self):
237
233
class CellOutput (Directive ):
238
234
"""Define an output cell to be included verbatim.
239
235
240
- Arguments
236
+ Arguments:
241
237
---------
242
238
filename : str (optional)
243
239
If provided, a path to a file containing output.
@@ -323,12 +319,10 @@ def __init__(self, rawsource="", *children, **attributes):
323
319
super ().__init__ ("" , * children , mimetypes = attributes ["mimetypes" ])
324
320
325
321
def render_as (self , visitor ):
326
- """Determine which node to show based on the visitor"""
322
+ """Determine which node to show based on the visitor. """
327
323
try :
328
324
# Or should we go to config via the node?
329
- priority = visitor .builder .env .app .config [
330
- "render_priority_" + visitor .builder .format
331
- ]
325
+ priority = visitor .builder .env .app .config ["render_priority_" + visitor .builder .format ]
332
326
except (AttributeError , KeyError ):
333
327
# Not sure what do to, act as a container and show everything just in case.
334
328
return super ()
@@ -367,9 +361,7 @@ def __init__(self, rawsource="", *children, **attributes):
367
361
super ().__init__ ("" , view_spec = attributes ["view_spec" ])
368
362
369
363
def html (self ):
370
- return ipywidgets .embed .widget_view_template .format (
371
- view_spec = json .dumps (self ["view_spec" ])
372
- )
364
+ return ipywidgets .embed .widget_view_template .format (view_spec = json .dumps (self ["view_spec" ]))
373
365
374
366
375
367
class JupyterWidgetStateNode (docutils .nodes .Element ):
@@ -414,7 +406,7 @@ def cell_output_to_nodes(outputs, write_stderr, out_dir, thebe_config, inline=Fa
414
406
inline: False
415
407
Whether the nodes will be placed in-line with the text.
416
408
417
- Returns
409
+ Returns:
418
410
-------
419
411
to_add : list of docutils nodes
420
412
Each output, converted into a docutils node.
@@ -509,9 +501,7 @@ def output2sphinx(data, mime_type, metadata, out_dir, inline=False):
509
501
math_node = math_block
510
502
511
503
if mime_type == "text/html" :
512
- return docutils .nodes .raw (
513
- text = data , format = "html" , classes = ["output" , "text_html" ]
514
- )
504
+ return docutils .nodes .raw (text = data , format = "html" , classes = ["output" , "text_html" ])
515
505
elif mime_type == "text/plain" :
516
506
return literal_node (
517
507
text = data ,
0 commit comments