Skip to content

Commit 86adda3

Browse files
committed
blackifying
1 parent 78740a5 commit 86adda3

File tree

9 files changed

+462
-408
lines changed

9 files changed

+462
-408
lines changed

doc/source/conf.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,28 @@
99
import os
1010
import sys
1111

12-
sys.path.insert(0, os.path.abspath('../..'))
12+
sys.path.insert(0, os.path.abspath("../.."))
1313

1414
import jupyter_sphinx
1515

16-
project = 'Jupyter Sphinx'
17-
copyright = '2019, Jupyter Development Team'
18-
author = 'Jupyter Development Team'
16+
project = "Jupyter Sphinx"
17+
copyright = "2019, Jupyter Development Team"
18+
author = "Jupyter Development Team"
1919

2020
# The full version, including alpha/beta/rc tags
2121
release = jupyter_sphinx.__version__
2222
# The short X.Y version
23-
version = release[:len(release) - len(release.lstrip('0123456789.'))].rstrip('.')
23+
version = release[: len(release) - len(release.lstrip("0123456789."))].rstrip(".")
2424

25-
master_doc = 'index'
25+
master_doc = "index"
2626

27-
extensions = [
28-
'sphinx.ext.mathjax',
29-
'jupyter_sphinx',
30-
]
27+
extensions = ["sphinx.ext.mathjax", "jupyter_sphinx"]
3128

32-
html_theme = 'alabaster'
29+
html_theme = "alabaster"
3330
html_theme_options = {
3431
"github_user": "jupyter",
3532
"github_repo": "jupyter-sphinx",
3633
"github_banner": True,
3734
}
3835

39-
jupyter_sphinx_thebelab_config = {
40-
"binderOptions": {
41-
"repo": "jupyter/jupyter-sphinx",
42-
},
43-
}
36+
jupyter_sphinx_thebelab_config = {"binderOptions": {"repo": "jupyter/jupyter-sphinx"}}

jupyter_sphinx/__init__.py

Lines changed: 59 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@
88
from sphinx.util.fileutil import copy_asset
99
from IPython.lib.lexers import IPythonTracebackLexer, IPython3Lexer
1010

11-
from .ast import JupyterCell, JupyterCellNode, JupyterWidgetViewNode, JupyterWidgetStateNode, WIDGET_VIEW_MIMETYPE, jupyter_download_role
11+
from .ast import (
12+
JupyterCell,
13+
JupyterCellNode,
14+
JupyterWidgetViewNode,
15+
JupyterWidgetStateNode,
16+
WIDGET_VIEW_MIMETYPE,
17+
jupyter_download_role,
18+
)
1219
from .execute import JupyterKernelNode, JupyterKernel, ExecuteJupyterCells
1320
from .thebelab import ThebeButton, ThebeButtonNode, ThebeOutputNode, ThebeSourceNode
1421

15-
REQUIRE_URL_DEFAULT = 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js'
16-
THEBELAB_URL_DEFAULT = 'https://unpkg.com/thebelab@^0.4.0'
22+
REQUIRE_URL_DEFAULT = (
23+
"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"
24+
)
25+
THEBELAB_URL_DEFAULT = "https://unpkg.com/thebelab@^0.4.0"
1726

1827
logger = logging.getLogger(__name__)
1928

@@ -27,36 +36,42 @@ def builder_inited(app):
2736
require_url = app.config.jupyter_sphinx_require_url
2837
if require_url:
2938
app.add_js_file(require_url)
30-
embed_url = app.config.jupyter_sphinx_embed_url or ipywidgets.embed.DEFAULT_EMBED_REQUIREJS_URL
39+
embed_url = (
40+
app.config.jupyter_sphinx_embed_url
41+
or ipywidgets.embed.DEFAULT_EMBED_REQUIREJS_URL
42+
)
3143
else:
32-
embed_url = app.config.jupyter_sphinx_embed_url or ipywidgets.embed.DEFAULT_EMBED_SCRIPT_URL
44+
embed_url = (
45+
app.config.jupyter_sphinx_embed_url
46+
or ipywidgets.embed.DEFAULT_EMBED_SCRIPT_URL
47+
)
3348
if embed_url:
3449
app.add_js_file(embed_url)
3550

3651
# add jupyter-sphinx css
37-
app.add_css_file('jupyter-sphinx.css')
52+
app.add_css_file("jupyter-sphinx.css")
3853
# Check if a thebelab config was specified
3954
if app.config.jupyter_sphinx_thebelab_config:
40-
app.add_js_file('thebelab-helper.js')
41-
app.add_css_file('thebelab.css')
55+
app.add_js_file("thebelab-helper.js")
56+
app.add_css_file("thebelab.css")
4257

4358

4459
def build_finished(app, env):
45-
if app.builder.format != 'html':
60+
if app.builder.format != "html":
4661
return
4762

4863
# Copy stylesheet
49-
src = os.path.join(os.path.dirname(__file__), 'css')
50-
dst = os.path.join(app.outdir, '_static')
64+
src = os.path.join(os.path.dirname(__file__), "css")
65+
dst = os.path.join(app.outdir, "_static")
5166
copy_asset(src, dst)
5267

5368
thebe_config = app.config.jupyter_sphinx_thebelab_config
5469
if not thebe_config:
5570
return
5671

5772
# Copy all thebelab related assets
58-
src = os.path.join(os.path.dirname(__file__), 'thebelab')
59-
dst = os.path.join(app.outdir, '_static')
73+
src = os.path.join(os.path.dirname(__file__), "thebelab")
74+
dst = os.path.join(app.outdir, "_static")
6075
copy_asset(src, dst)
6176

6277

@@ -69,42 +84,38 @@ def _setup(app):
6984
# Configuration
7085

7186
app.add_config_value(
72-
'jupyter_execute_kwargs',
87+
"jupyter_execute_kwargs",
7388
dict(timeout=-1, allow_errors=True, store_widget_state=True),
74-
'env'
89+
"env",
7590
)
91+
app.add_config_value("jupyter_execute_default_kernel", "python3", "env")
7692
app.add_config_value(
77-
'jupyter_execute_default_kernel',
78-
'python3',
79-
'env'
80-
)
81-
app.add_config_value(
82-
'jupyter_execute_data_priority',
93+
"jupyter_execute_data_priority",
8394
[
8495
WIDGET_VIEW_MIMETYPE,
85-
'application/javascript',
86-
'text/html',
87-
'image/svg+xml',
88-
'image/png',
89-
'image/jpeg',
90-
'text/latex',
91-
'text/plain'
96+
"application/javascript",
97+
"text/html",
98+
"image/svg+xml",
99+
"image/png",
100+
"image/jpeg",
101+
"text/latex",
102+
"text/plain",
92103
],
93-
'env',
104+
"env",
94105
)
95106

96107
# ipywidgets config
97-
app.add_config_value('jupyter_sphinx_require_url', REQUIRE_URL_DEFAULT, 'html')
98-
app.add_config_value('jupyter_sphinx_embed_url', None, 'html')
108+
app.add_config_value("jupyter_sphinx_require_url", REQUIRE_URL_DEFAULT, "html")
109+
app.add_config_value("jupyter_sphinx_embed_url", None, "html")
99110

100111
# thebelab config, can be either a filename or a dict
101-
app.add_config_value('jupyter_sphinx_thebelab_config', None, 'html')
112+
app.add_config_value("jupyter_sphinx_thebelab_config", None, "html")
102113

103-
app.add_config_value('jupyter_sphinx_thebelab_url', THEBELAB_URL_DEFAULT, 'html')
114+
app.add_config_value("jupyter_sphinx_thebelab_url", THEBELAB_URL_DEFAULT, "html")
104115

105116
# linenos config
106-
app.add_config_value('jupyter_sphinx_linenos', False, 'env')
107-
app.add_config_value('jupyter_sphinx_continue_linenos', False, 'env')
117+
app.add_config_value("jupyter_sphinx_linenos", False, "env")
118+
app.add_config_value("jupyter_sphinx_continue_linenos", False, "env")
108119

109120
# Used for nodes that do not need to be rendered
110121
def skip(self, node):
@@ -132,17 +143,16 @@ def visit_element_html(self, node):
132143

133144
# Used to render the ThebeSourceNode conditionally for non-HTML builders
134145
def visit_thebe_source(self, node):
135-
if node['hide_code']:
146+
if node["hide_code"]:
136147
raise docutils.nodes.SkipNode
137148
else:
138149
self.visit_container(node)
139150

140151
render_thebe_source = (
141152
visit_thebe_source,
142-
lambda self, node: self.depart_container(node)
153+
lambda self, node: self.depart_container(node),
143154
)
144155

145-
146156
# JupyterKernelNode is just a doctree marker for the
147157
# ExecuteJupyterCells transform, so we don't actually render it.
148158
app.add_node(
@@ -220,24 +230,21 @@ def visit_thebe_source(self, node):
220230
man=(skip, None),
221231
)
222232

223-
app.add_directive('jupyter-execute', JupyterCell)
224-
app.add_directive('jupyter-kernel', JupyterKernel)
225-
app.add_directive('thebe-button', ThebeButton)
226-
app.add_role('jupyter-download:notebook', jupyter_download_role)
227-
app.add_role('jupyter-download:script', jupyter_download_role)
233+
app.add_directive("jupyter-execute", JupyterCell)
234+
app.add_directive("jupyter-kernel", JupyterKernel)
235+
app.add_directive("thebe-button", ThebeButton)
236+
app.add_role("jupyter-download:notebook", jupyter_download_role)
237+
app.add_role("jupyter-download:script", jupyter_download_role)
228238
app.add_transform(ExecuteJupyterCells)
229239

230240
# For syntax highlighting
231-
app.add_lexer('ipythontb', IPythonTracebackLexer())
232-
app.add_lexer('ipython', IPython3Lexer())
241+
app.add_lexer("ipythontb", IPythonTracebackLexer())
242+
app.add_lexer("ipython", IPython3Lexer())
233243

234-
app.connect('builder-inited', builder_inited)
235-
app.connect('build-finished', build_finished)
244+
app.connect("builder-inited", builder_inited)
245+
app.connect("build-finished", build_finished)
236246

237-
return {
238-
'version': __version__,
239-
'parallel_read_safe': True,
240-
}
247+
return {"version": __version__, "parallel_read_safe": True}
241248

242249

243250
def setup(app):
@@ -246,4 +253,4 @@ def setup(app):
246253
This should be replaced with `_setup` after a deprecation cycle.
247254
"""
248255
out = _setup(app)
249-
return out
256+
return out

jupyter_sphinx/_version.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1-
version_info = (0, 2, 3, 'final')
1+
version_info = (0, 2, 3, "final")
22

3-
_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
3+
_specifier_ = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""}
44

5-
__version__ = '%s.%s.%s%s'%(version_info[0], version_info[1], version_info[2],
6-
'' if version_info[3]=='final' else _specifier_[version_info[3]]+str(version_info[4]))
5+
__version__ = "%s.%s.%s%s" % (
6+
version_info[0],
7+
version_info[1],
8+
version_info[2],
9+
""
10+
if version_info[3] == "final"
11+
else _specifier_[version_info[3]] + str(version_info[4]),
12+
)

0 commit comments

Comments
 (0)