Skip to content

Commit 3fc4e38

Browse files
authored
atempt to solve thebe file issue (WIP) (#227)
1 parent d43642f commit 3fc4e38

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

jupyter_sphinx/__init__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
import docutils
66
import ipywidgets
77
from IPython.lib.lexers import IPython3Lexer, IPythonTracebackLexer
8+
from sphinx.application import Sphinx
89
from sphinx.errors import ExtensionError
910
from sphinx.util import logging
10-
from sphinx.util.fileutil import copy_asset
11+
from sphinx.util.fileutil import copy_asset_file
1112

1213
from ._version import __version__
1314
from .ast import (
@@ -91,7 +92,7 @@ def visit_thebe_source(self, node):
9192

9293

9394
# Sphinx callback functions
94-
def builder_inited(app):
95+
def builder_inited(app: Sphinx):
9596
"""
9697
2 cases
9798
case 1: ipywidgets 7, with require
@@ -113,17 +114,17 @@ def builder_inited(app):
113114
app.add_js_file(embed_url)
114115

115116

116-
def copy_file(src, dst):
117-
if not (dst / src.name).exists():
118-
copy_asset(str(src), str(dst))
117+
def copy_file(src: Path, dst: Path):
118+
"""wrapper of copy_asset_file to handle path"""
119+
copy_asset_file(str(src.resolve()), str(dst.resolve()))
119120

120121

121-
def build_finished(app, env):
122+
def build_finished(app: Sphinx, env):
122123
if app.builder.format != "html":
123124
return
124125

125126
module_dir = Path(__file__).parent
126-
static = Path(app.outdir) / "_static"
127+
static = Path(app.builder.outdir) / "_static"
127128

128129
# Copy stylesheet
129130
src = module_dir / "css" / "jupyter-sphinx.css"
@@ -141,7 +142,7 @@ def build_finished(app, env):
141142

142143
##############################################################################
143144
# Main setup
144-
def setup(app):
145+
def setup(app: Sphinx):
145146
"""A temporary setup function so that we can use it here and in execute.
146147
147148
This should be removed and converted into `setup` after a deprecation

0 commit comments

Comments
 (0)