Skip to content

Commit

Permalink
sagemathgh-38943: Some documentation improvement
Browse files Browse the repository at this point in the history
    
Just improve some documentation.

Apparently the existing documentation uses the absolute URL ``   * -
`Tutorial <../tutorial/index.html>`_`` e.g.
`sage/src/doc/en/developer/sage_manuals.rst`, none of them uses
`<tutorial>`. I tried using `<chapter-tutorial>` in https://github.com/s
agemath/sage/commit/955a09e746c7d9675d2a4c4f10558cec8d3eb948 but for
some reason it doesn't work, so I just end up deleting it.

### 📝 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. (not aware of one)
- [x] I have created tests covering the changes.
- [x] I have updated the documentation and checked the documentation
preview.

------

test failures have nothing to do with the change, see
sagemath#37295
    
URL: sagemath#38943
Reported by: user202729
Reviewer(s): Kwankyu Lee, user202729
  • Loading branch information
Release Manager committed Dec 13, 2024
2 parents a65c0b1 + 6267b0d commit a8a6485
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 24 deletions.
21 changes: 10 additions & 11 deletions src/doc/en/developer/coding_in_cython.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ up-to-date information or check out the
to get started immediately.


Writing cython code in Sage
Writing Cython code in Sage
===========================

There are several ways to create and build Cython code in Sage.

#. In the Sage Notebook, begin any cell with ``%cython``. When you
evaluate that cell,
#. In the Sage notebook or the Sage command line, begin any cell with
a line containing ``%%cython``. When you evaluate that cell,

#. It is saved to a file.

Expand All @@ -53,22 +53,21 @@ There are several ways to create and build Cython code in Sage.
program that was compiled to create the ``.so`` file.

#. A ``cpdef`` or ``def`` function, say ``testfunction``, defined in
a ``%cython`` cell in a worksheet can be imported and made available
in a different ``%cython`` cell within the same worksheet by
a ``%%cython`` cell in a worksheet can be imported and made available
in a different ``%%cython`` cell within the same worksheet by
importing it as shown below::

%cython
%%cython
from __main__ import testfunction

#. Create an ``.spyx`` file and attach or load it from the command
line. This is similar to creating a ``%cython`` cell in the
notebook but works completely from the command line (and not from
the notebook).
Refer to :meth:`sage.repl.ipython_extension.SageMagics.cython`.

#. Create an ``.spyx`` file and attach or load it
from the command line.

#. Create a ``.pyx`` file and add it to the Sage library.
Then run ``sage -b`` to rebuild Sage.


Attaching or loading .spyx files
================================

Expand Down
6 changes: 4 additions & 2 deletions src/doc/en/reference/repl/index.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
.. _section-command-line:

The Sage Command Line
=====================

The Sage Read-Eval-Print-Loop (REPL) is based on IPython. In this
document, you'll find how the IPython integration works. You should
also be familiar with the documentation for IPython.

For more details about using the Sage command line, see the Sage
tutorial.
For more details about using the Sage command line, see `the Sage
tutorial <../../tutorial/index.html>`_.

Running Sage
------------
Expand Down
2 changes: 0 additions & 2 deletions src/doc/en/tutorial/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. _tutorial:

========================
Welcome to Sage Tutorial
========================
Expand Down
2 changes: 1 addition & 1 deletion src/sage/interacts/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Sage Interacts
Sage interacts are applications of the `@interact decorator <../../sagenb/notebook/interact.html>`_.
They are conveniently accessible in the Sage Notebook via ``interacts.[TAB].[TAB]()``.
They are conveniently accessible in the Sage notebook via ``interacts.[TAB].[TAB]()``.
The first ``[TAB]`` lists categories and the second ``[TAB]`` reveals the interact examples.
EXAMPLES:
Expand Down
6 changes: 6 additions & 0 deletions src/sage/misc/cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,9 @@ def cython_import_all(filename, globals, **kwds):
- ``filename`` -- string; name of a file that contains Cython
code
See the function :func:`sage.misc.cython.cython` for documentation
for the other inputs.
"""
m = cython_import(filename, **kwds)
for k, x in m.__dict__.items():
Expand Down Expand Up @@ -621,6 +624,9 @@ def compile_and_load(code, **kwds):
- ``code`` -- string containing code that could be in a .pyx file
that is attached or put in a %cython block in the notebook
See the function :func:`sage.misc.cython.cython` for documentation
for the other inputs.
OUTPUT: a module, which results from compiling the given code and
importing it
Expand Down
2 changes: 1 addition & 1 deletion src/sage/misc/persist.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def load(*filename, compress=True, verbose=True, **kwargs):
an ``.sobj`` extension added if it doesn't have one. Or, if the input
is a filename ending in ``.py``, ``.pyx``, ``.sage``, ``.spyx``,
``.f``, ``.f90`` or ``.m``, load that file into the current running
session.
session using :func:`sage.repl.load.load`.
Loaded files are not loaded into their own namespace, i.e., this is
much more like Python's ``execfile`` than Python's ``import``.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/plot/animate.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ def show(self, delay=None, iterations=None, **kwds):
sage: a.show(delay=50) # long time # optional -- ImageMagick
You can also make use of the HTML5 video element in the Sage Notebook::
You can also make use of the HTML5 video element in the Sage notebook::
sage: # long time, optional -- FFmpeg
sage: a.show(format='ogg')
Expand Down
8 changes: 6 additions & 2 deletions src/sage/repl/attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,12 @@ def attach(*files):
.. SEEALSO::
:meth:`~sage.repl.load.load` is the same as :func:`attach`, but
does not automatically reload a file when it changes.
:func:`~sage.repl.load.load` is the same as :func:`attach`, but
does not automatically reload a file when it changes unless
``attach=True`` is passed.
``%attach`` magic can also be used, see
:meth:`~sage.repl.ipython_extension.SageMagics.attach`.
EXAMPLES:
Expand Down
8 changes: 8 additions & 0 deletions src/sage/repl/ipython_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def runfile(self, s):
- ``s`` -- string; the file to be loaded
.. SEEALSO::
This is the same as :func:`~sage.repl.load.load`.
EXAMPLES::
sage: import os
Expand All @@ -133,6 +137,10 @@ def attach(self, s):
- ``s`` -- string. The file to be attached
.. SEEALSO::
This is the same as :func:`~sage.repl.attach.attach`.
EXAMPLES::
sage: from sage.repl.interpreter import get_test_shell
Expand Down
19 changes: 15 additions & 4 deletions src/sage/repl/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ def load(filename, globals, attach=False):
from t import *
.. NOTE::
The global ``load`` function is :func:`sage.misc.persist.load`,
which delegates to this function for code file formats.
``%runfile`` magic can also be used, see
:meth:`~sage.repl.ipython_extension.SageMagics.runfile`.
INPUT:
- ``filename`` -- string (denoting a filename or URL) or a :class:`Path` object
Expand All @@ -97,13 +105,15 @@ def load(filename, globals, attach=False):
- ``attach`` -- boolean (default: ``False``); whether to add the
file to the list of attached files
Loading an executable Sage script from the command prompt will run whatever
code is inside an
Loading an executable Sage script from the :ref:`command line <section-command-line>`
will run whatever code is inside an
::
if __name__ == "__main__":
section, as the condition on ``__name__`` will hold true (code run from the
command prompt is considered to be running in the ``__main__`` module.)
command line is considered to be running in the ``__main__`` module.)
EXAMPLES:
Expand Down Expand Up @@ -159,7 +169,8 @@ def load(filename, globals, attach=False):
sage: sage.repl.load.load('https://raw.githubusercontent.com/sagemath/sage-patchbot/3.0.0/sage_patchbot/util.py', globals()) # optional - internet
We attach a file::
We attach a file (note that :func:`~sage.repl.attach.attach`
is equivalent, but available at the global scope by default)::
sage: t = tmp_filename(ext='.py')
sage: with open(t, 'w') as f:
Expand Down

0 comments on commit a8a6485

Please sign in to comment.