Skip to content
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

Revive sage live doc using jupyter-sphinx #36144

Merged
merged 42 commits into from
Oct 31, 2023

Conversation

kwankyu
Copy link
Collaborator

@kwankyu kwankyu commented Aug 27, 2023

We fix #33320 and #24367.

We also upgrade jupyter-sphinx standard package to the latest version 0.4.0: https://github.com/jupyter/jupyter-sphinx/releases/tag/v0.4.0, and patch it to facilitate live doc.

By default, live doc depends on https://github.com/sagemath/sage-binder-env for binder (remote jupyter server).

To showcase the live doc, we edited "A Tour of Sage" doc and some parts of sage doc. Visit

Click the activate button to activate live doc The button is hidden to the right middle side of the browser. After clicked, the activate button shows the status of the launching kernel.

Be patient if the kernel loads slow. It may take several minutes. Sometimes it may be stuck in the "launching" state. In that case, reload the page and try again.

Note that %display latex is the default. You should use %display plain to get plain textual output.

Preparation

./sage -i jupyterlab

If things do not work as expected, first remove the existing documentation by

make doc-clean doc-uninstall

Build static doc

export SAGE_LIVE_DOC=no    # default
make -j4

Build live doc with the default Binder repo

export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=binder    # default
make -j4

Build live doc with a custom Binder repo

export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=binder:sagemath/sage-binder-env    # default
make -j4

The kernel is "sagemath".

Build live doc with a local server

export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=http://localhost:8889
export SAGE_JUPYTER_SERVER_TOKEN=secret              # default 
make -j4

and run a local jupyter server before browsing the documentation.

./sage --notebook=jupyterlab \
  --ServerApp.token='secret' \
  --ServerApp.allow_origin='null' \
  --ServerApp.disable_check_xsrf=true \
  --ServerApp.port=8889 \
  --ServerApp.open_browser=false 

Build live doc selectively

First build static doc

make -j4

and then build live doc selectively either by

./sage --docbuild --live-doc a_tour_of_sage html

or

export SAGE_JUPYTER_SERVER=http://localhost:8889
export SAGE_JUPYTER_SERVER_TOKEN=secret              # default 
./sage --docbuild --live-doc a_tour_of_sage html

with a local server.

📝 Checklist

  • The title is concise, informative, and self-explanatory.
  • The description explains in detail what this PR is about.
  • I have linked a relevant issue or discussion.
  • I have created tests covering the changes.
  • I have updated the documentation accordingly.

Related upstream issues:

@kwankyu kwankyu changed the title Rework sage live doc Rework on sage live doc using jupyter-sphinx Aug 27, 2023
@kwankyu kwankyu changed the title Rework on sage live doc using jupyter-sphinx Revive sage live doc using jupyter-sphinx Aug 27, 2023
@kwankyu kwankyu marked this pull request as ready for review August 28, 2023 06:04
@mkoeppe
Copy link
Contributor

mkoeppe commented Aug 28, 2023

With furo in dark mode, it looks like this:
Screenshot 2023-08-28 at 10 47 45 AM

@kwankyu
Copy link
Collaborator Author

kwankyu commented Aug 29, 2023

Try this.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kwankyu requested changes for this PR

@dimpase
Copy link
Member

dimpase commented Sep 9, 2023

I've merged sagemath/sage-binder-env#16 - can you use the official thing now?

@kwankyu
Copy link
Collaborator Author

kwankyu commented Sep 9, 2023

Great! Thanks.

@kwankyu kwankyu requested review from github-actions[bot] and removed request for github-actions[bot] September 10, 2023 05:18
@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 26, 2023

Still the same

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

That is surprising!

I made it sure that in the furo auto mode, the change of the system light/dark mode setting takes effect.
Screenshot 2023-10-27 at 1 53 03 AM

Screenshot 2023-10-27 at 1 52 50 AM

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 26, 2023

which browser are you testing with? My tests are with Chrome on macOS; and the dark-mode-screenshot tool uses Chromium

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 26, 2023

Same problem also with Safari on macOS

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

chrome on macos sonoma

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 26, 2023

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

The same on safari:

Screenshot 2023-10-27 at 2 04 39 AM Screenshot 2023-10-27 at 2 04 51 AM

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

It may be the cache problem... Would you turn this on "Disable cache"?

Screenshot 2023-10-27 at 2 10 28 AM

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 26, 2023

The portion of the page that you screenshotted is also OK for me. The problem shows, as my previous screenshots have shown, a bit further down.

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

Yes, I got it!

I must have fixed this before... or no... I will check.

No, right.

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

Basically we are fixing jupyter-sphinx that doesn't support dark mode. As the maintainer is not very responsive, we have to deal with that here.

Should be fixed now. Thanks for catching this!

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

The portion of the page that you screenshotted is also OK for me. The problem shows, as my previous screenshots have shown, a bit further down.

I missed that before...

@mkoeppe
Copy link
Contributor

mkoeppe commented Oct 26, 2023

Yes! It's working!

Copy link
Contributor

@mkoeppe mkoeppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great improvement. Let's merge it and make sure that it becomes available in our documentation for 10.2

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

As live doc is totally optional, it is left to users and the project how to use it.

Currently a major obstacle is of course slow (and sometimes failing) kernel loading from the Binder repo. It seems that there is not much left to do in this regard on our side, and perhaps neither on Binder side too.

For individual users, running a local server is the best way to use live doc. Running and experimenting with the code examples right in the live doc would improve accessibility of the vast features of Sage. In this regard, many code examples should be refactored to facilitate live doc.

For the project, I am not sure. I hope that live doc be available in all online documentation, but because of the major obstacle, this needs more thought and discussion.

@kwankyu
Copy link
Collaborator Author

kwankyu commented Oct 26, 2023

Thank you all!

@github-actions
Copy link

Documentation preview for this PR (built with commit 857741c; changes) is ready! 🎉

vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 28, 2023
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

We fix sagemath#33320 and  sagemath#24367.

We also upgrade jupyter-sphinx standard package to the latest version
0.4.0: https://github.com/jupyter/jupyter-sphinx/releases/tag/v0.4.0,
and patch it to facilitate live doc.

By default, live doc depends on https://github.com/sagemath/sage-binder-
env for binder (remote jupyter server).

To showcase the live doc, we edited "A Tour of Sage"  doc and some parts
of sage doc. Visit

- https://deploy-preview-36144--sagemath-
tobias.netlify.app/a_tour_of_sage or
- https://deploy-preview-36144--sagemath-
tobias.netlify.app/tutorial/latex  (edited to resolve sagemath#24367)

**Click the activate button to activate live doc** The button is hidden
to the right middle side of the browser. After clicked, the activate
button shows the status of the launching kernel.

**Be patient if the kernel loads slow.  It may take several minutes.**
Sometimes it may be stuck in the "launching" state. In that case, reload
the page and try again.

Note that `%display latex` is the default. You should use `%display
plain` to get plain textual output.

## Preparation

```
./sage -i jupyterlab
```

If things do not work as expected, first remove the existing
documentation by
```
make doc-clean doc-uninstall
```

## Build static doc

```
export SAGE_LIVE_DOC=no    # default
make -j4
```

## Build live doc with the default Binder repo

```
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=binder    # default
make -j4
```

## Build live doc with a custom Binder repo

```
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=binder:sagemath/sage-binder-env    # default
make -j4
```
The kernel is "sagemath".

## Build live doc with a local server

```
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=http://localhost:8889
export SAGE_JUPYTER_SERVER_TOKEN=secret              # default
make -j4
```
 and run a local jupyter server before browsing the documentation.
```
./sage --notebook=jupyterlab \
  --ServerApp.token='secret' \
  --ServerApp.allow_origin='null' \
  --ServerApp.disable_check_xsrf=true \
  --ServerApp.port=8889 \
  --ServerApp.open_browser=false
```

## Build live doc selectively

First build static doc

```
make -j4
```
and then build live doc selectively either by

```
./sage --docbuild --live-doc a_tour_of_sage html
```
or
```
export SAGE_JUPYTER_SERVER=http://localhost:8889
export SAGE_JUPYTER_SERVER_TOKEN=secret              # default
./sage --docbuild --live-doc a_tour_of_sage html
```
with a local server.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [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.
- [x] I have updated the documentation accordingly.

Related upstream issues:
- jupyter/jupyter-sphinx#201
- jupyter/jupyter-sphinx#231
    
URL: sagemath#36144
Reported by: Kwankyu Lee
Reviewer(s): github-actions[bot], Kwankyu Lee, Matthias Köppe
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 28, 2023
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

We fix sagemath#33320 and  sagemath#24367.

We also upgrade jupyter-sphinx standard package to the latest version
0.4.0: https://github.com/jupyter/jupyter-sphinx/releases/tag/v0.4.0,
and patch it to facilitate live doc.

By default, live doc depends on https://github.com/sagemath/sage-binder-
env for binder (remote jupyter server).

To showcase the live doc, we edited "A Tour of Sage"  doc and some parts
of sage doc. Visit

- https://deploy-preview-36144--sagemath-
tobias.netlify.app/a_tour_of_sage or
- https://deploy-preview-36144--sagemath-
tobias.netlify.app/tutorial/latex  (edited to resolve sagemath#24367)

**Click the activate button to activate live doc** The button is hidden
to the right middle side of the browser. After clicked, the activate
button shows the status of the launching kernel.

**Be patient if the kernel loads slow.  It may take several minutes.**
Sometimes it may be stuck in the "launching" state. In that case, reload
the page and try again.

Note that `%display latex` is the default. You should use `%display
plain` to get plain textual output.

## Preparation

```
./sage -i jupyterlab
```

If things do not work as expected, first remove the existing
documentation by
```
make doc-clean doc-uninstall
```

## Build static doc

```
export SAGE_LIVE_DOC=no    # default
make -j4
```

## Build live doc with the default Binder repo

```
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=binder    # default
make -j4
```

## Build live doc with a custom Binder repo

```
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=binder:sagemath/sage-binder-env    # default
make -j4
```
The kernel is "sagemath".

## Build live doc with a local server

```
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=http://localhost:8889
export SAGE_JUPYTER_SERVER_TOKEN=secret              # default
make -j4
```
 and run a local jupyter server before browsing the documentation.
```
./sage --notebook=jupyterlab \
  --ServerApp.token='secret' \
  --ServerApp.allow_origin='null' \
  --ServerApp.disable_check_xsrf=true \
  --ServerApp.port=8889 \
  --ServerApp.open_browser=false
```

## Build live doc selectively

First build static doc

```
make -j4
```
and then build live doc selectively either by

```
./sage --docbuild --live-doc a_tour_of_sage html
```
or
```
export SAGE_JUPYTER_SERVER=http://localhost:8889
export SAGE_JUPYTER_SERVER_TOKEN=secret              # default
./sage --docbuild --live-doc a_tour_of_sage html
```
with a local server.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [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.
- [x] I have updated the documentation accordingly.

Related upstream issues:
- jupyter/jupyter-sphinx#201
- jupyter/jupyter-sphinx#231
    
URL: sagemath#36144
Reported by: Kwankyu Lee
Reviewer(s): github-actions[bot], Kwankyu Lee, Matthias Köppe
vbraun pushed a commit to vbraun/sage that referenced this pull request Oct 29, 2023
    
<!-- ^^^^^
Please provide a concise, informative and self-explanatory title.
Don't put issue numbers in there, do this in the PR body below.
For example, instead of "Fixes sagemath#1234" use "Introduce new method to
calculate 1+1"
-->
<!-- Describe your changes here in detail -->

We fix sagemath#33320 and  sagemath#24367.

We also upgrade jupyter-sphinx standard package to the latest version
0.4.0: https://github.com/jupyter/jupyter-sphinx/releases/tag/v0.4.0,
and patch it to facilitate live doc.

By default, live doc depends on https://github.com/sagemath/sage-binder-
env for binder (remote jupyter server).

To showcase the live doc, we edited "A Tour of Sage"  doc and some parts
of sage doc. Visit

- https://deploy-preview-36144--sagemath-
tobias.netlify.app/a_tour_of_sage or
- https://deploy-preview-36144--sagemath-
tobias.netlify.app/tutorial/latex  (edited to resolve sagemath#24367)

**Click the activate button to activate live doc** The button is hidden
to the right middle side of the browser. After clicked, the activate
button shows the status of the launching kernel.

**Be patient if the kernel loads slow.  It may take several minutes.**
Sometimes it may be stuck in the "launching" state. In that case, reload
the page and try again.

Note that `%display latex` is the default. You should use `%display
plain` to get plain textual output.

## Preparation

```
./sage -i jupyterlab
```

If things do not work as expected, first remove the existing
documentation by
```
make doc-clean doc-uninstall
```

## Build static doc

```
export SAGE_LIVE_DOC=no    # default
make -j4
```

## Build live doc with the default Binder repo

```
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=binder    # default
make -j4
```

## Build live doc with a custom Binder repo

```
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=binder:sagemath/sage-binder-env    # default
make -j4
```
The kernel is "sagemath".

## Build live doc with a local server

```
export SAGE_LIVE_DOC=yes
export SAGE_JUPYTER_SERVER=http://localhost:8889
export SAGE_JUPYTER_SERVER_TOKEN=secret              # default
make -j4
```
 and run a local jupyter server before browsing the documentation.
```
./sage --notebook=jupyterlab \
  --ServerApp.token='secret' \
  --ServerApp.allow_origin='null' \
  --ServerApp.disable_check_xsrf=true \
  --ServerApp.port=8889 \
  --ServerApp.open_browser=false
```

## Build live doc selectively

First build static doc

```
make -j4
```
and then build live doc selectively either by

```
./sage --docbuild --live-doc a_tour_of_sage html
```
or
```
export SAGE_JUPYTER_SERVER=http://localhost:8889
export SAGE_JUPYTER_SERVER_TOKEN=secret              # default
./sage --docbuild --live-doc a_tour_of_sage html
```
with a local server.

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->
<!-- If your change requires a documentation PR, please link it
appropriately -->
<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
<!-- Feel free to remove irrelevant items. -->

- [x] The title is concise, informative, and self-explanatory.
- [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.
- [x] I have updated the documentation accordingly.

Related upstream issues:
- jupyter/jupyter-sphinx#201
- jupyter/jupyter-sphinx#231
    
URL: sagemath#36144
Reported by: Kwankyu Lee
Reviewer(s): github-actions[bot], Kwankyu Lee, Matthias Köppe
@vbraun vbraun merged commit c59ebbb into sagemath:develop Oct 31, 2023
18 of 20 checks passed
@kwankyu kwankyu deleted the p/rework-on-live-sage-documentation branch December 13, 2023 11:48
@collares collares mentioned this pull request Jan 24, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rework on live sage documentation Confusing documentation on MathJax in light of use in Jupyter notebook
5 participants