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

Use URLs to online Sage documents for JupyterLab #36246

Merged
merged 4 commits into from
Oct 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 29 additions & 15 deletions src/sage/repl/ipython_kernel/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,54 +94,68 @@ def help_links(self):

See the Jupyter documentation.

.. NOTE::

Urls starting with "kernelspecs" are prepended by the
browser with the appropriate path.

EXAMPLES::

sage: from sage.repl.ipython_kernel.kernel import SageKernel
sage: sk = SageKernel.__new__(SageKernel)
sage: sk.help_links
[{'text': 'Sage Documentation',
'url': 'kernelspecs/sagemath/doc/html/en/index.html'},
'url': 'https://doc.sagemath.org/html/en/index.html'},
...]
"""
# DEPRECATED: The URLs in the form 'kernelspecs/...' were used for
# classical Jupyter notebooks. For instance,
#
# 'kernelspecs/sagemath/doc/html/en/index.html'
#
# is constructed by kernel_url('doc/html/en/index.html'), but these
# URLs of local files don't work for JupyterLab. Hence all URLs here
# have been replaced with URLs of online documents.

from sage.repl.ipython_kernel.install import SageKernelSpec
identifier = SageKernelSpec.identifier()

def kernel_url(x):
# URLs starting with 'kernelspecs' are prepended by the
# browser with the appropriate path
return 'kernelspecs/{0}/{1}'.format(identifier, x)

return [
{
'text': 'Sage Documentation',
'url': kernel_url('doc/html/en/index.html'),
'url': "https://doc.sagemath.org/html/en/index.html",
},
{
'text': 'A Tour of Sage',
'url': "https://doc.sagemath.org/html/en/a_tour_of_sage/index.html",
},
{
'text': 'Tutorial',
'url': kernel_url('doc/html/en/tutorial/index.html'),
'url': "https://doc.sagemath.org/html/en/tutorial/index.html",
},
{
'text': 'Thematic Tutorials',
'url': kernel_url('doc/html/en/thematic_tutorials/index.html'),
'url': "https://doc.sagemath.org/html/en/thematic_tutorials/index.html",
},
{
'text': 'FAQs',
'url': kernel_url('doc/html/en/faq/index.html'),
'text': 'PREP Tutorials',
'url': "https://doc.sagemath.org/html/en/prep/index.html",
},
{
'text': 'PREP Tutorials',
'url': kernel_url('doc/html/en/prep/index.html'),
'text': 'Constructions',
'url': "https://doc.sagemath.org/html/en/constructions/index.html",
},
{
'text': 'FAQ',
'url': "https://doc.sagemath.org/html/en/faq/index.html",
},
{
'text': 'Reference',
'url': kernel_url('doc/html/en/reference/index.html'),
'url': "https://doc.sagemath.org/html/en/reference/index.html",
},
{
'text': "Developer's Guide",
'url': kernel_url('doc/html/en/developer/index.html'),
'url': "https://doc.sagemath.org/html/en/developer/index.html",
},
{
'text': "Python",
Expand Down
Loading