Skip to content

Commit

Permalink
atempt to solve thebe file issue (WIP) (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
12rambau committed Dec 29, 2023
1 parent d43642f commit 3fc4e38
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions jupyter_sphinx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import docutils
import ipywidgets
from IPython.lib.lexers import IPython3Lexer, IPythonTracebackLexer
from sphinx.application import Sphinx
from sphinx.errors import ExtensionError
from sphinx.util import logging
from sphinx.util.fileutil import copy_asset
from sphinx.util.fileutil import copy_asset_file

from ._version import __version__
from .ast import (
Expand Down Expand Up @@ -91,7 +92,7 @@ def visit_thebe_source(self, node):


# Sphinx callback functions
def builder_inited(app):
def builder_inited(app: Sphinx):
"""
2 cases
case 1: ipywidgets 7, with require
Expand All @@ -113,17 +114,17 @@ def builder_inited(app):
app.add_js_file(embed_url)


def copy_file(src, dst):
if not (dst / src.name).exists():
copy_asset(str(src), str(dst))
def copy_file(src: Path, dst: Path):
"""wrapper of copy_asset_file to handle path"""
copy_asset_file(str(src.resolve()), str(dst.resolve()))


def build_finished(app, env):
def build_finished(app: Sphinx, env):
if app.builder.format != "html":
return

module_dir = Path(__file__).parent
static = Path(app.outdir) / "_static"
static = Path(app.builder.outdir) / "_static"

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

##############################################################################
# Main setup
def setup(app):
def setup(app: Sphinx):
"""A temporary setup function so that we can use it here and in execute.
This should be removed and converted into `setup` after a deprecation
Expand Down

0 comments on commit 3fc4e38

Please sign in to comment.