Skip to content

Commit

Permalink
Some documentation improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
user202729 committed Nov 9, 2024
1 parent 1b3f398 commit 040dcc9
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
12 changes: 8 additions & 4 deletions src/doc/en/developer/coding_in_cython.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ There are several ways to create and build Cython code in Sage.
%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).
#. Create an ``.spyx`` file and :ref:`attach or load it <Attaching or loading .spyx files>`
from the :ref:`command line <The Sage 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).

#. Use ``%%cython`` cell magic in the command line.
Refer to :meth:`sage.repl.ipython_extension.SageMagics.cython`.

#. Create a ``.pyx`` file and add it to the Sage library.
Then run ``sage -b`` to rebuild Sage.
Expand Down
4 changes: 2 additions & 2 deletions src/doc/en/reference/repl/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ 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 :ref:`the Sage
tutorial <tutorial>`.

Running Sage
------------
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
13 changes: 10 additions & 3 deletions src/sage/repl/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ 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.
INPUT:
- ``filename`` -- string (denoting a filename or URL) or a :class:`Path` object
Expand All @@ -97,13 +102,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 <The Sage 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

0 comments on commit 040dcc9

Please sign in to comment.