-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
Detect and use system MathJax-3.x #36098
Conversation
src/sage_docbuild/conf.py
Outdated
@@ -374,7 +374,7 @@ def set_intersphinx_mappings(app, config): | |||
if os.environ.get('SAGE_USE_CDNS', 'no') == 'yes': | |||
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" | |||
else: | |||
mathjax_path = 'mathjax/tex-chtml.js' | |||
mathjax_path = 'tex-chtml.js' | |||
html_common_static_path += [MATHJAX_DIR] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change does not break the documentation, but has a problem which is the reason of the prefix mathjax/
.
This is the content of the directory _static
built by Sphinx (with the PR):
$ cd _static/
$ ls
_sphinx_javascript_frameworks_compat.js mml-svg.js
a11y node-main.js
adaptors output
basic.css pdf.png
check-solid.svg plot_directive.css
clipboard.min.js plus.png
copy-button.svg pygments.css
copybutton.css sageicon.png
copybutton.js sagelogo.png
copybutton_funcs.js scripts
core.js searchtools.js
custom-furo.css skeleton.css
debug.css sphinx_highlight.js
doctools.js sre
documentation_options.js startup.js
favicon.ico styles
file.png tex-chtml-full.js
input tex-chtml.js
jquery-3.6.0.js tex-mml-chtml.js
jquery.js tex-mml-svg.js
jupyter-sphinx.css tex-svg-full.js
language_data.js tex-svg.js
latest.js thebe-sage.js
loader.js thebelab-helper.js
logo_sagemath_black.svg thebelab.css
logo_sagemath_white.svg ui
minus.png underscore-1.13.1.js
mml-chtml.js underscore.js
Note that all mathjax files are mixed with other static files while the original (without this PR) _static
directory looks like this:
$ cd _static/
$ ls
_sphinx_javascript_frameworks_compat.js logo_sagemath_white.svg
basic.css mathjax <----------------------------------
check-solid.svg minus.png
clipboard.min.js pdf.png
copy-button.svg plot_directive.css
copybutton.css plus.png
copybutton.js pygments.css
copybutton_funcs.js sageicon.png
custom-furo.css sagelogo.png
debug.css scripts
doctools.js searchtools.js
documentation_options.js skeleton.css
favicon.ico sphinx_highlight.js
file.png styles
jquery-3.6.0.js thebe-sage.js
jquery.js thebelab-helper.js
jupyter-sphinx.css thebelab.css
language_data.js underscore-1.13.1.js
logo_sagemath_black.svg underscore.js
Note that all mathjax files are in the subdirectory mathjax
.
I think this is a regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change does not break the documentation, but has a problem which is the reason of the prefix
mathjax/
...Note that all mathjax files are mixed with other static files while the original (without this PR)
_static
directory looks like this:...
Note that all mathjax files are in the subdirectory
mathjax
.I think this is a regression.
It's messy, but does it hurt anything?
That directory contains all of sphinx's build files and it's sphinx that decides what to put in there. We also see jquery.js and underscore.js (two independent projects) in that directory. If it were up to me the images, css, and javascript would all be in a separate directory, but I don't think moving just one javascript file into a subfolder makes things any cleaner or more consistent.
In any case, I changed it because the system mathjax may not live in a directory called "mathjax". Do you see an easy way around that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, _static
directory is already a mess, but now mathjax becomes a mess too. mathjax comprises of many javascript files and directories containing data files. Mixing all of them with other files in _static
directory makes the situation worse. We do (I did) look into _static
directory from time to time to fix things. It's better to keep it tidy as much as we can.
@@ -374,7 +374,7 @@ def set_intersphinx_mappings(app, config): | |||
if os.environ.get('SAGE_USE_CDNS', 'no') == 'yes': | |||
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" | |||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An "easy" fix would be to cut out the last path component of MATHJAX_DIR
and prepend it to tex-chtml.js
to make up mathjax_path
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the lines L377,378.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This would not work...
AS_IF([test x$sage_spkg_install_mathjax = xyes], [ | ||
# Our spkg-src script adds an extra "mathjax" | ||
SAGE_MATHJAX_DIR='${prefix}'/share/mathjax/mathjax | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There seems no easy fix. A trick is to add ".." to '${prefix}'/share/mathjax/mathjax
here so that we use ".." to indicate that this is an spkg mathjax, and then use the indicator to differentiate how to tell sphinx where to find mathjax in conf.py
. Yes, this is ugly...
Previously we copied mathjax to sphinx's _static output directory and then referenced it with a path relative to _static. This commit references it by absolute path on the filesystem, solving two problems: 1. It doesn't waste space; there are multiple _static directories, and mathjax was copied to all of them 2. It avoids polluting _static with mathjax files Closes: sagemath#30296
87a88b1
to
ab1649c
Compare
I don't see any reason to copy mathjax into |
Documentation preview for this PR (built with commit ab1649c; changes) is ready! 🎉 |
I like that idea. One concern is that the sage documentation becomes dependent on the mathjax external to it. This may break, for example, @haraldschilly's script for publishing the documenation to |
Or for the better, @haraldschilly can set |
Could conda be supported? See #30296 (comment) |
I'm happy to support every other distro, I only need to know where mathjax is installed. What is |
See also #25111 (comment) for a related issue. |
Perhaps it is |
I will set this positive review tomorrow if there's no more input for mathjax installation paths, as it already improves the situation. |
Thank you! |
This already broke the documentation previews for PRs. |
An easy fix on the side of documentation previews is to use When we do it, I suggest to use "SAGE_LIVE_DOC=yes" too (needs review #36144.) |
The docbuild is zipping up a subtree:
and then publishing that somewhere. Now that |
Right. I think this diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml
index 3635980d15..eb4f81f303 100644
--- a/.github/workflows/doc-build.yml
+++ b/.github/workflows/doc-build.yml
@@ -82,6 +82,8 @@ jobs:
# incremental docbuild may introduce broken links (inter-file references) though build succeeds
run: |
set -ex
+ export SAGE_USE_CDNS=yes
+ export SAGE_LIVE_DOC=yes
mv /sage/local/share/doc/sage/html/en/.git /sage/.git-doc
make doc-clean doc-uninstall sagelib-clean && git clean -fx src/sage
mkdir -p /sage/local/share/doc/sage/html/en/ && mv /sage/.git-doc /sage/local/share/doc/sage/html/en/.git would suffice (also for future live doc :-) @mkoeppe ? |
I created an issue #36159 to track this. |
Resolves #30296