Skip to content

Commit

Permalink
sagemathgh-37637: Update jupyter-sphinx to version 0.5.3 and pin theb…
Browse files Browse the repository at this point in the history
…e 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
  • Loading branch information
Release Manager committed Mar 31, 2024
2 parents d57101d + c4c26ee commit db00f22
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
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

0 comments on commit db00f22

Please sign in to comment.