Skip to content

Commit 893c9f6

Browse files
authored
Merge branch 'main' into pre-commit
2 parents 402aeca + 0106bd2 commit 893c9f6

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

.devcontainer/devcontainer.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "Python 3",
3+
"image": "mcr.microsoft.com/devcontainers/python:1-3.11-bullseye",
4+
"features": {
5+
"ghcr.io/devcontainers-contrib/features/hatch:2": {},
6+
"ghcr.io/devcontainers-contrib/features/pre-commit:2": {}
7+
},
8+
"postCreateCommand": "pre-commit install"
9+
}

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 (
@@ -89,7 +90,7 @@ def visit_thebe_source(self, node):
8990

9091

9192
# Sphinx callback functions
92-
def builder_inited(app):
93+
def builder_inited(app: Sphinx):
9394
"""Init the build.
9495
9596
2 cases
@@ -108,17 +109,17 @@ def builder_inited(app):
108109
app.add_js_file(embed_url)
109110

110111

111-
def copy_file(src, dst):
112-
if not (dst / src.name).exists():
113-
copy_asset(str(src), str(dst))
112+
def copy_file(src: Path, dst: Path):
113+
"""wrapper of copy_asset_file to handle path"""
114+
copy_asset_file(str(src.resolve()), str(dst.resolve()))
114115

115116

116-
def build_finished(app, env):
117+
def build_finished(app: Sphinx, env):
117118
if app.builder.format != "html":
118119
return
119120

120121
module_dir = Path(__file__).parent
121-
static = Path(app.outdir) / "_static"
122+
static = Path(app.builder.outdir) / "_static"
122123

123124
# Copy stylesheet
124125
src = module_dir / "css" / "jupyter-sphinx.css"
@@ -136,7 +137,7 @@ def build_finished(app, env):
136137

137138
##############################################################################
138139
# Main setup
139-
def setup(app):
140+
def setup(app: Sphinx):
140141
"""A temporary setup function so that we can use it here and in execute.
141142
142143
This should be removed and converted into `setup` after a deprecation

0 commit comments

Comments
 (0)