Skip to content

Update jupyter-sphinx to version 0.5.3 and pin thebe to version 0.8.2 #37637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build/pkgs/jupyter_sphinx/checksums.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
tarball=jupyter_sphinx-VERSION.tar.gz
sha1=fb2abdd5e35da0886b12d45a6373c4dbcc24b244
md5=130daa6be810976c9f8e30aa04011e50
cksum=2882523000
sha1=85e6e1665488fac3131da2e3ab9648037c0d1da9
md5=397d3b20c8df015bf6a1e50d0208590d
cksum=524174657
upstream_url=https://pypi.io/packages/source/j/jupyter_sphinx/jupyter_sphinx-VERSION.tar.gz
2 changes: 1 addition & 1 deletion build/pkgs/jupyter_sphinx/package-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.0.p0
0.5.3.p0
Original file line number Diff line number Diff line change
@@ -1,57 +1,63 @@
From 5bffbe38302c695123779f87300d84090b4bd118 Mon Sep 17 00:00:00 2001
From 7951c3183b422bc7afe115952ef7ae15b79e45d3 Mon Sep 17 00:00:00 2001
From: Kwankyu Lee <ekwankyu@gmail.com>
Date: Mon, 28 Aug 2023 00:18:59 +0900
Subject: [PATCH] Patch for sage live doc

---
jupyter_sphinx/__init__.py | 4 ++--
jupyter_sphinx/execute.py | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
jupyter_sphinx/execute.py | 17 +++++++++++++++++
2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/jupyter_sphinx/__init__.py b/jupyter_sphinx/__init__.py
index 34af884..b7ca8ee 100644
index 34af884..920131c 100644
--- a/jupyter_sphinx/__init__.py
+++ b/jupyter_sphinx/__init__.py
@@ -31,7 +31,7 @@ from .thebelab import ThebeButton, ThebeButtonNode, ThebeOutputNode, ThebeSource
REQUIRE_URL_DEFAULT = (
"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"
)
-THEBELAB_URL_DEFAULT = "https://unpkg.com/thebelab@^0.4.0"
+THEBELAB_URL_DEFAULT = "https://unpkg.com/thebe@latest/lib/index.js"
+THEBELAB_URL_DEFAULT = "https://unpkg.com/thebe@0.8.2/lib/index.js"

logger = logging.getLogger(__name__)

@@ -186,7 +186,7 @@ def setup(app):
app.add_config_value("jupyter_sphinx_embed_url", None, "html")

# thebelab config, can be either a filename or a dict
- app.add_config_value("jupyter_sphinx_thebelab_config", None, "html")
+ app.add_config_value("jupyter_sphinx_thebelab_config", None, "env")
app.add_config_value("jupyter_sphinx_thebelab_url", THEBELAB_URL_DEFAULT, "html")

# linenos config
diff --git a/jupyter_sphinx/execute.py b/jupyter_sphinx/execute.py
index 558a26b..de44455 100644
index cb473cf..898d86b 100644
--- a/jupyter_sphinx/execute.py
+++ b/jupyter_sphinx/execute.py
@@ -152,6 +152,17 @@ class ExecuteJupyterCells(SphinxTransform):
@@ -152,6 +152,23 @@ class ExecuteJupyterCells(SphinxTransform):
kernel_name = default_kernel
file_name = next(default_names)

+ # Save time when jupyter notebook execution is not necessary
+ if not any(not "execute" in node or node["execute"] for node in nodes):
+ # mimics empty cell output for each node
+ if all("execute" in node and not node["execute"] for node in nodes):
+ notebook = blank_nb(kernel_name)
+ try:
+ cm_language = notebook.metadata.language_info.codemirror_mode.name
+ except AttributeError:
+ cm_language = notebook.metadata.kernelspec.language
+ # Mimic empty cell output for each node
+ for node in nodes:
+ source = node.children[0]
+ source.attributes["classes"].append("code_cell")
+ node.attributes["cm_language"] = kernel_name
+ node += CellOutputNode(classes=["cell_output"])
+ node.attributes["cm_language"] = cm_language
+ if len(node.children) < 2:
+ node += CellOutputNode(classes=["cell_output"])
+ apply_styling(node, thebe_config)
+ continue
+
# Add empty placeholder cells for non-executed nodes so nodes
# and cells can be zipped and the provided input/output
# can be inserted later
--
2.42.0
--
2.44.0