1- """Manipulating the Sphinx AST with Jupyter objects"""
1+ """Manipulating the Sphinx AST with Jupyter objects. """
22
33import json
44import warnings
@@ -34,9 +34,7 @@ def load_content(cell, location, logger):
3434 env .note_dependency (rel_filename )
3535 if cell .content :
3636 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 ),
4038 location = location ,
4139 )
4240 try :
@@ -60,9 +58,7 @@ def get_highlights(cell, content, location, logger):
6058 hl_lines = parselinenos (emphasize_linespec , nlines )
6159 if any (i >= nlines for i in hl_lines ):
6260 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 ),
6662 location = location ,
6763 )
6864 hl_lines = [i + 1 for i in hl_lines if i < nlines ]
@@ -78,7 +74,7 @@ class JupyterCell(Directive):
7874 executed when the directive is parsed, but later during a doctree
7975 transformation.
8076
81- Arguments
77+ Arguments:
8278 ---------
8379 filename : str (optional)
8480 If provided, a path to a file containing code.
@@ -166,7 +162,7 @@ def run(self):
166162class CellInput (Directive ):
167163 """Define a code cell to be included verbatim but not executed.
168164
169- Arguments
165+ Arguments:
170166 ---------
171167 filename : str (optional)
172168 If provided, a path to a file containing code.
@@ -237,7 +233,7 @@ def run(self):
237233class CellOutput (Directive ):
238234 """Define an output cell to be included verbatim.
239235
240- Arguments
236+ Arguments:
241237 ---------
242238 filename : str (optional)
243239 If provided, a path to a file containing output.
@@ -323,12 +319,10 @@ def __init__(self, rawsource="", *children, **attributes):
323319 super ().__init__ ("" , * children , mimetypes = attributes ["mimetypes" ])
324320
325321 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. """
327323 try :
328324 # 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 ]
332326 except (AttributeError , KeyError ):
333327 # Not sure what do to, act as a container and show everything just in case.
334328 return super ()
@@ -367,9 +361,7 @@ def __init__(self, rawsource="", *children, **attributes):
367361 super ().__init__ ("" , view_spec = attributes ["view_spec" ])
368362
369363 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" ]))
373365
374366
375367class JupyterWidgetStateNode (docutils .nodes .Element ):
@@ -414,7 +406,7 @@ def cell_output_to_nodes(outputs, write_stderr, out_dir, thebe_config, inline=Fa
414406 inline: False
415407 Whether the nodes will be placed in-line with the text.
416408
417- Returns
409+ Returns:
418410 -------
419411 to_add : list of docutils nodes
420412 Each output, converted into a docutils node.
@@ -509,9 +501,7 @@ def output2sphinx(data, mime_type, metadata, out_dir, inline=False):
509501 math_node = math_block
510502
511503 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" ])
515505 elif mime_type == "text/plain" :
516506 return literal_node (
517507 text = data ,
0 commit comments