Skip to content

Commit db00f22

Browse files
author
Release Manager
committed
sagemathgh-37637: Update jupyter-sphinx to version 0.5.3 and pin thebe to version 0.8.2 <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> jupyter-sphinx that we are shipping was patched to use thebe@latest, which is the cause of the current breakdown of the sage live doc. The patch to jupyter-sphinx is partly based on jupyter/jupyter-sphinx#231 ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#37637 Reported by: Kwankyu Lee Reviewer(s): Matthias Köppe
2 parents d57101d + c4c26ee commit db00f22

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
tarball=jupyter_sphinx-VERSION.tar.gz
2-
sha1=fb2abdd5e35da0886b12d45a6373c4dbcc24b244
3-
md5=130daa6be810976c9f8e30aa04011e50
4-
cksum=2882523000
2+
sha1=85e6e1665488fac3131da2e3ab9648037c0d1da9
3+
md5=397d3b20c8df015bf6a1e50d0208590d
4+
cksum=524174657
55
upstream_url=https://pypi.io/packages/source/j/jupyter_sphinx/jupyter_sphinx-VERSION.tar.gz
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.4.0.p0
1+
0.5.3.p0
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,63 @@
1-
From 5bffbe38302c695123779f87300d84090b4bd118 Mon Sep 17 00:00:00 2001
1+
From 7951c3183b422bc7afe115952ef7ae15b79e45d3 Mon Sep 17 00:00:00 2001
22
From: Kwankyu Lee <[email protected]>
33
Date: Mon, 28 Aug 2023 00:18:59 +0900
44
Subject: [PATCH] Patch for sage live doc
55

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

1111
diff --git a/jupyter_sphinx/__init__.py b/jupyter_sphinx/__init__.py
12-
index 34af884..b7ca8ee 100644
12+
index 34af884..920131c 100644
1313
--- a/jupyter_sphinx/__init__.py
1414
+++ b/jupyter_sphinx/__init__.py
1515
@@ -31,7 +31,7 @@ from .thebelab import ThebeButton, ThebeButtonNode, ThebeOutputNode, ThebeSource
1616
REQUIRE_URL_DEFAULT = (
1717
"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js"
1818
)
1919
-THEBELAB_URL_DEFAULT = "https://unpkg.com/thebelab@^0.4.0"
20-
+THEBELAB_URL_DEFAULT = "https://unpkg.com/thebe@latest/lib/index.js"
21-
20+
+THEBELAB_URL_DEFAULT = "https://unpkg.com/thebe@0.8.2/lib/index.js"
21+
2222
logger = logging.getLogger(__name__)
23-
23+
2424
@@ -186,7 +186,7 @@ def setup(app):
2525
app.add_config_value("jupyter_sphinx_embed_url", None, "html")
26-
26+
2727
# thebelab config, can be either a filename or a dict
2828
- app.add_config_value("jupyter_sphinx_thebelab_config", None, "html")
2929
+ app.add_config_value("jupyter_sphinx_thebelab_config", None, "env")
3030
app.add_config_value("jupyter_sphinx_thebelab_url", THEBELAB_URL_DEFAULT, "html")
31-
31+
3232
# linenos config
3333
diff --git a/jupyter_sphinx/execute.py b/jupyter_sphinx/execute.py
34-
index 558a26b..de44455 100644
34+
index cb473cf..898d86b 100644
3535
--- a/jupyter_sphinx/execute.py
3636
+++ b/jupyter_sphinx/execute.py
37-
@@ -152,6 +152,17 @@ class ExecuteJupyterCells(SphinxTransform):
37+
@@ -152,6 +152,23 @@ class ExecuteJupyterCells(SphinxTransform):
3838
kernel_name = default_kernel
3939
file_name = next(default_names)
40-
40+
4141
+ # Save time when jupyter notebook execution is not necessary
42-
+ if not any(not "execute" in node or node["execute"] for node in nodes):
43-
+ # mimics empty cell output for each node
42+
+ if all("execute" in node and not node["execute"] for node in nodes):
43+
+ notebook = blank_nb(kernel_name)
44+
+ try:
45+
+ cm_language = notebook.metadata.language_info.codemirror_mode.name
46+
+ except AttributeError:
47+
+ cm_language = notebook.metadata.kernelspec.language
48+
+ # Mimic empty cell output for each node
4449
+ for node in nodes:
4550
+ source = node.children[0]
4651
+ source.attributes["classes"].append("code_cell")
47-
+ node.attributes["cm_language"] = kernel_name
48-
+ node += CellOutputNode(classes=["cell_output"])
52+
+ node.attributes["cm_language"] = cm_language
53+
+ if len(node.children) < 2:
54+
+ node += CellOutputNode(classes=["cell_output"])
4955
+ apply_styling(node, thebe_config)
5056
+ continue
5157
+
5258
# Add empty placeholder cells for non-executed nodes so nodes
5359
# and cells can be zipped and the provided input/output
5460
# can be inserted later
55-
--
56-
2.42.0
61+
--
62+
2.44.0
5763

0 commit comments

Comments
 (0)