Skip to content

Commit fc80abe

Browse files
author
Release Manager
committed
sagemathgh-38224: `configure --disable-notebook`: Also disable `jupyter_sphinx` <!-- ^ 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` is only needed for the live documentation and for some illustrations in `src/doc/en/tutorial/latex.rst`. We conditionalize the use of this extension using a Feature. `configure --disable-notebook` now also disables `jupyter_sphinx`, to avoid pulling in lots of Jupyter packages via its dependencies (including `jsonschema`, which has gotten itself a Rust-based dependency, see sagemath#38219). This implements the policy for use of platform-dependent wheels proposed in sagemath#38219 ("if a platform-dependent ``wheel`` package is a standard package, there must be a ``configure`` option that disables it"). We also repair the mechanism for conditional documentation based on feature tags. In particular, the link for Boolean polynomials is restored. https://doc-pr-38224-- sagemath.netlify.app/html/en/reference/polynomial_rings/#boolean- polynomials ### 📝 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 and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> - Depends on sagemath#38468 (merged here) URL: sagemath#38224 Reported by: Matthias Köppe Reviewer(s): Kwankyu Lee
2 parents 5d3a5d7 + 33a114c commit fc80abe

File tree

40 files changed

+240
-28
lines changed

40 files changed

+240
-28
lines changed

.ci/create-changes-html.sh

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/bin/sh
22
if [ $# != 2 ]; then
3-
echo >&2 "usage: $0 BASE_DOC_COMMIT DOC_REPO"
4-
echo >&2 "creates CHANGES.html in the current directory"
5-
echo >&2 "for the diffs of DOC_REPO against BASE_DOC_COMMIT"
3+
echo >&2 "Usage: $0 DIFF_TEXT DOC_REPO"
4+
echo >&2 "This script generates a CHANGES.html file in the current directory"
5+
echo >&2 "and adds anchor targets in the documents within DOC_REPO"
6+
echo >&2 "based on the diff hunks in the DIFF_TEXT file."
67
exit 1
78
fi
8-
BASE_DOC_COMMIT="$1"
9+
DIFF_TEXT="$1"
910
DOC_REPOSITORY="$2"
1011

1112
# Create CHANGES.html
@@ -52,11 +53,10 @@ diffParagraphs.forEach(paragraph => {
5253
EOF
5354
echo '</head>' >> CHANGES.html
5455
echo '<body>' >> CHANGES.html
55-
(cd $DOC_REPOSITORY && git diff $BASE_DOC_COMMIT -- "*.html") > diff.txt
5656
python3 - << EOF
5757
import os, re, html
5858
from itertools import chain
59-
with open('diff.txt', 'r') as f:
59+
with open('$DIFF_TEXT', 'r') as f:
6060
diff_text = f.read()
6161
diff_blocks = re.split(r'^(?=diff --git)', diff_text, flags=re.MULTILINE)
6262
out_blocks = []
@@ -83,12 +83,21 @@ for block in diff_blocks:
8383
hunk_lines = []
8484
search_result = re.search(r'@@ -(\d+),(\d+) \+(\d+),(\d+)', line)
8585
if search_result:
86-
line_number = int(search_result.group(3))
86+
line_number = int(search_result.group(3)) - 1
8787
span = int(search_result.group(4))
8888
for i in chain(range(line_number, line_number + span), range(line_number - 1, -1, -1)):
89-
if content[i].startswith('<') and not content[i].startswith('</'):
89+
try:
90+
ln = content[i]
91+
except IndexError:
92+
continue
93+
for idx, char in enumerate(ln):
94+
if not char.isspace():
95+
break
96+
else:
97+
idx = len(ln)
98+
if ln.startswith('<', idx) and not ln.startswith('</', idx):
9099
count += 1
91-
content[i] = f'<span id="hunk{count}" style="visibility: hidden;"></span>' + content[i]
100+
content[i] = ln[:idx] + f'<span id="hunk{count}" style="visibility: hidden;"></span>' + ln[idx:]
92101
hunks.append(f'<p class="hunk"><a href="{path}#hunk{count}" class="hunk" target="_blank">hunk #{count}</a></p>')
93102
break
94103
hunk_lines.append(line)
@@ -107,4 +116,4 @@ EOF
107116
cat diff.html >> CHANGES.html
108117
echo '</body>' >> CHANGES.html
109118
echo '</html>' >> CHANGES.html
110-
rm diff.txt diff.html
119+
rm diff.html

.github/workflows/doc-build.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,10 @@ jobs:
204204
-e 's;#L[0-9]*";";' \
205205
&& git commit -a -m 'wipe-out')
206206
# Since HEAD is at commit 'wipe-out', HEAD~1 is commit 'new' (new doc), HEAD~2 is commit 'old' (old doc)
207-
.ci/create-changes-html.sh $(cd doc && git rev-parse HEAD~2) doc
208-
# Restore the new doc with changes made in create-changes-html.sh but dropping changes by "wipe out"
209-
(cd doc && git stash -q && git checkout -q -f HEAD~1 && git stash pop -q)
207+
(cd doc && git diff $(git rev-parse HEAD~2) -- "*.html") > diff.txt
208+
# Restore the new doc dropping changes by "wipe out"
209+
(cd doc && git checkout -q -f HEAD~1)
210+
.ci/create-changes-html.sh diff.txt doc
210211
# Sometimes rm -rf .git errors out because of some diehard hidden files
211212
# So we simply move it out of the doc directory
212213
(cd doc && mv .git ../git && mv .gitattributes ../gitattributes)

build/pkgs/sagemath_doc_html/dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
sagelib sphinx sphinx_copybutton sphinx_inline_tabs pplpy_doc | $(SAGERUNTIME) maxima networkx scipy sympy matplotlib pillow mathjax mpmath ipykernel jupyter_client conway_polynomials tachyon jmol ipywidgets jupyter_sphinx sage_docbuild elliptic_curves furo fpylll graphs
1+
sagelib sphinx sphinx_copybutton sphinx_inline_tabs pplpy_doc | $(SAGERUNTIME) maxima networkx scipy sympy matplotlib pillow mathjax mpmath ipykernel jupyter_client conway_polynomials tachyon jmol ipywidgets sage_docbuild elliptic_curves furo fpylll graphs
22

33
# Building the documentation has many dependencies, because all
44
# documented modules are imported and because we use matplotlib to
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jupyter_sphinx

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ AC_ARG_ENABLE([cvxopt],
450450
AC_ARG_ENABLE([notebook],
451451
AS_HELP_STRING([--disable-notebook],
452452
[disable build of the Jupyter notebook and related packages]), [
453-
for pkg in notebook nbconvert beautifulsoup4 sagenb_export nbformat nbclient terminado send2trash prometheus_client mistune pandocfilters bleach defusedxml jsonschema jupyter_jsmol argon2_cffi argon2_cffi_bindings webencodings tinycss2 ipympl soupsieve fastjsonschema anyio arrow async_lru fqdn isoduration json5 jsonpointer jsonschema_specifications jupyter_events jupyter_lsp jupyter_server jupyter_server_terminals jupyterlab jupyterlab_server jupyterlab_pygments jupyterlab_mathjax2 notebook_shim overrides python_json_logger pyyaml referencing rfc3339_validator rfc3986_validator sniffio types_python_dateutil uri_template webcolors websocket_client; do
453+
for pkg in notebook nbconvert beautifulsoup4 sagenb_export nbformat nbclient terminado send2trash prometheus_client mistune pandocfilters bleach defusedxml jsonschema jupyter_jsmol argon2_cffi argon2_cffi_bindings webencodings tinycss2 ipympl soupsieve fastjsonschema anyio arrow async_lru fqdn isoduration json5 jsonpointer jsonschema_specifications jupyter_events jupyter_lsp jupyter_server jupyter_server_terminals jupyterlab jupyterlab_server jupyterlab_pygments jupyterlab_mathjax2 jupyter_sphinx notebook_shim overrides python_json_logger pyyaml referencing rfc3339_validator rfc3986_validator sniffio types_python_dateutil uri_template webcolors websocket_client; do
454454
AS_VAR_SET([SAGE_ENABLE_$pkg], [$enableval])
455455
done
456456
])

src/doc/ca/intro/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from sage_docbuild.conf import release
1414
from sage_docbuild.conf import * # NOQA
1515

16+
17+
for tag in feature_tags():
18+
tags.add(tag)
19+
20+
1621
# Add any paths that contain custom static files (such as style sheets),
1722
# relative to this directory to html_static_path. They are copied after the
1823
# builtin static files, so a file named "default.css" will overwrite the

src/doc/de/a_tour_of_sage/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
from sage_docbuild.conf import release
1616
from sage_docbuild.conf import * # NOQA
1717

18+
19+
for tag in feature_tags():
20+
tags.add(tag)
21+
22+
1823
# Add any paths that contain custom static files (such as style sheets),
1924
# relative to this directory to html_static_path. They are copied after the
2025
# builtin static files, so a file named "default.css" will overwrite the

src/doc/de/thematische_anleitungen/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from sage_docbuild.conf import release
1414
from sage_docbuild.conf import * # NOQA
1515

16+
17+
for tag in feature_tags():
18+
tags.add(tag)
19+
20+
1621
# Add any paths that contain custom static files (such as style sheets),
1722
# relative to this directory to html_static_path. They are copied after the
1823
# builtin static files, so a file named "default.css" will overwrite the

src/doc/de/tutorial/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from sage_docbuild.conf import release
1414
from sage_docbuild.conf import * # NOQA
1515

16+
17+
for tag in feature_tags():
18+
tags.add(tag)
19+
20+
1621
# Add any paths that contain custom static files (such as style sheets),
1722
# relative to this directory to html_static_path. They are copied after the
1823
# builtin static files, so a file named "default.css" will overwrite the

src/doc/el/a_tour_of_sage/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
from sage_docbuild.conf import release
1414
from sage_docbuild.conf import * # NOQA
1515

16+
17+
for tag in feature_tags():
18+
tags.add(tag)
19+
20+
1621
# Add any paths that contain custom static files (such as style sheets),
1722
# relative to this directory to html_static_path. They are copied after the
1823
# builtin static files, so a file named "default.css" will overwrite the

0 commit comments

Comments
 (0)