Skip to content

Commit 294eed4

Browse files
author
Release Manager
committed
gh-37546: Sphinx ext links for Sage source files <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes #12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes #12345". --> In the documentation, we can now write `` :sage_root:`src/setup.py` `` or `` :sage_root:`src/doc/en/installation` ``, and it will be formatted uniformly, and a link to the file in the repository will be created. - Rebased version of #33756 Fixes #33756. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [ ] 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. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #37546 Reported by: Matthias Köppe Reviewer(s): David Coudert, Kwankyu Lee
2 parents 14da417 + def8e56 commit 294eed4

File tree

20 files changed

+135
-137
lines changed

20 files changed

+135
-137
lines changed

src/doc/de/tutorial/sagetex.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Tutorial und den Abschnitt "Make SageTeX known to TeX" des `Sage installation gu
1515
Installationsanleitung führen) um weitere Informationen zu erhalten.
1616

1717
Hier stellen wir ein sehr kurzes Beispiel vor wie man SageTeX nutzt.
18-
Die komplette Dokumentation finden Sie unter ``SAGE_ROOT/venv/share/texmf/tex/latex/sagetex``,
18+
Die komplette Dokumentation finden Sie unter :file:`SAGE_ROOT/venv/share/texmf/tex/latex/sagetex`,
1919
wobei ``SAGE_ROOT`` das Installationsverzeichnis von Sage ist. Dieses Verzeichnis
2020
enthält die Dokumentation, eine Beispieldatei und einige nützliche Python Skripte.
2121

@@ -103,4 +103,4 @@ an den Sage Befehlen in Ihrem Dokument vorgenommen haben.
103103

104104
Es gibt noch viel mehr über SageTeX zu sagen, aber da sowohl Sage alsauch
105105
LaTeX komplexe und mächtige Werkzeuge sind, sollten Sie die Dokumentation
106-
über SageTeX in ``SAGE_ROOT/venv/share/texmf/tex/latex/sagetex`` lesen.
106+
über SageTeX in :file:`SAGE_ROOT/venv/share/texmf/tex/latex/sagetex` lesen.

src/doc/en/developer/coding_basics.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ of several different types of polynomial rings.
123123

124124
If you want to create a new directory (`package
125125
<https://docs.python.org/3/tutorial/modules.html#packages>`_) in the
126-
Sage library ``SAGE_ROOT/src/sage`` (say, ``measure_theory``), that
126+
Sage library :sage_root:`src/sage` (say, ``measure_theory``), that
127127
directory will usually contain an empty file ``__init__.py``, which
128128
marks the directory as an ordinary package (see
129129
:ref:`section_namespace_packages`), and also a file ``all.py``,
@@ -141,7 +141,7 @@ framework::
141141
lazy_import('sage.measure_theory.borel_measure', 'BorelMeasure')
142142
lazy_import('sage.measure_theory.banach_tarski', 'BanachTarskiParadox')
143143

144-
Then in the file ``SAGE_ROOT/src/sage/all.py``, add a line ::
144+
Then in the file :sage_root:`src/sage/all.py`, add a line ::
145145

146146
from sage.measure_theory.all import *
147147

@@ -176,16 +176,16 @@ included in one of the following places:
176176

177177
- Older code in the Sage library accesses
178178
the package data in more direct ways. For example,
179-
``SAGE_ROOT/src/sage/interfaces/maxima.py`` uses the file
180-
``SAGE_ROOT/src/sage/interfaces/maxima.lisp`` at runtime, so it
179+
:sage_root:`src/sage/interfaces/maxima.py` uses the file
180+
:sage_root:`src/sage/interfaces/maxima.lisp` at runtime, so it
181181
refers to it as::
182182

183183
os.path.join(os.path.dirname(__file__), 'sage-maxima.lisp')
184184

185-
- In an appropriate subdirectory of ``SAGE_ROOT/src/sage/ext_data/``.
185+
- In an appropriate subdirectory of :sage_root:`src/sage/ext_data/`.
186186
(At runtime, it is then available in the directory indicated by
187187
``SAGE_EXTCODE``). For example, if ``file`` is placed in
188-
``SAGE_ROOT/src/sage/ext_data/directory/`` it can be accessed with ::
188+
:sage_root:`src/sage/ext_data/directory/` it can be accessed with ::
189189

190190
from sage.env import SAGE_EXTCODE
191191
file = os.path.join(SAGE_EXTCODE, 'directory', 'file')
@@ -194,7 +194,7 @@ included in one of the following places:
194194

195195
In all cases, the files must be listed (explicitly or via wildcards) in
196196
the section ``options.package_data`` of the file
197-
``SAGE_ROOT/pkgs/sagemath-standard/setup.cfg.m4`` (or the corresponding
197+
:sage_root:`pkgs/sagemath-standard/setup.cfg.m4` (or the corresponding
198198
file of another distribution).
199199

200200
Large data files should not be added to the Sage source tree. Instead, it
@@ -270,7 +270,7 @@ The top of each Sage code file should follow this format::
270270
# https://www.gnu.org/licenses/
271271
# ****************************************************************************
272272

273-
As an example, see ``SAGE_ROOT/src/sage/rings/integer.pyx``, which contains the
273+
As an example, see :sage_root:`src/sage/rings/integer.pyx`, which contains the
274274
implementation for `\ZZ`. The names of the people who made major contributions
275275
to the file appear in the ``AUTHORS`` section. You can add your name to the
276276
list if you belong to the people, but refrain from being verbose in the
@@ -432,7 +432,7 @@ information. You can use the existing functions of Sage as templates.
432432
433433
The bibliographical reference should go in Sage's master
434434
bibliography file,
435-
:file:`SAGE_ROOT/src/doc/en/reference/references/index.rst`:
435+
:sage_root:`src/doc/en/reference/references/index.rst`:
436436

437437
.. CODE-BLOCK:: rest
438438
@@ -605,7 +605,7 @@ Sage's master **BIBLIOGRAPHY** file
605605

606606
All bibliographical references should be stored in the master
607607
bibliography file,
608-
:file:`SAGE_ROOT/src/doc/en/reference/references/index.rst`, in the
608+
:sage_root:`src/doc/en/reference/references/index.rst`, in the
609609
format
610610

611611
.. CODE-BLOCK:: rest
@@ -919,7 +919,7 @@ LaTeX-formatted ``\\Bold{Z}`` in the html manual, and as ``Z`` in the
919919
interactive help. Other examples: ``\\GF{q}`` (`\GF{q}`) and ``\\Zmod{p}``
920920
(`\Zmod{p}`).
921921

922-
See the file ``SAGE_ROOT/src/sage/misc/latex_macros.py`` for a full list and
922+
See the file :sage_root:`src/sage/misc/latex_macros.py` for a full list and
923923
for details about how to add more macros.
924924

925925
.. _section-doctest-writing:
@@ -968,13 +968,13 @@ written.
968968

969969
Note that **TestSuites** are an automatic way to generate some of these
970970
tests in specific situations. See
971-
``SAGE_ROOT/src/sage/misc/sage_unittest.py``.
971+
:sage_root:`src/sage/misc/sage_unittest.py`.
972972

973973
**The syntax:**
974974

975975
- **Environment:** doctests should work if you copy/paste them in Sage's
976976
interactive console. For example, the function ``AA()`` in the file
977-
``SAGE_ROOT/src/sage/algebras/steenrod/steenrod_algebra.py`` includes an
977+
:sage_root:`src/sage/algebras/steenrod/steenrod_algebra.py` includes an
978978
EXAMPLES block containing the following::
979979

980980
sage: from sage.algebras.steenrod.steenrod_algebra import AA as A
@@ -1001,7 +1001,7 @@ written.
10011001
- **Writing files:** If a test outputs to a file, the file should be a
10021002
temporary file. Use :func:`tmp_filename` to get a temporary filename, or
10031003
:func:`tmp_dir` to get a temporary directory. An example from
1004-
``SAGE_ROOT/src/sage/plot/graphics.py``)::
1004+
:sage_root:`src/sage/plot/graphics.py`)::
10051005

10061006
sage: plot(x^2 - 5, (x, 0, 5), ymin=0).save(tmp_filename(ext='.png'))
10071007

@@ -1445,14 +1445,14 @@ put ``.. linkall`` anywhere in the file, on a line by itself. (For
14451445
clarity, it might be best to put it near the top of the file.) Then
14461446
``sage -t`` will act as if there were a ``.. link`` before each
14471447
verbatim environment. The file
1448-
``SAGE_ROOT/src/doc/en/tutorial/interfaces.rst`` contains a
1448+
:sage_root:`src/doc/en/tutorial/interfaces.rst` contains a
14491449
``.. linkall`` directive, for example.
14501450

14511451
You can also put ``.. skip`` right before a verbatim environment to
14521452
have that example skipped when testing the file. This goes in the
14531453
same place as the ``.. link`` in the previous example.
14541454

1455-
See the files in ``SAGE_ROOT/src/doc/en/tutorial/`` for many
1455+
See the files in :sage_root:`src/doc/en/tutorial/` for many
14561456
examples of how to include automated testing in reST documentation for
14571457
Sage.
14581458

src/doc/en/developer/coding_in_other.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ polynomial or matrix, will have our new method. So you can do
4343
``PariError`` in this case.
4444

4545
The ``gen`` class is defined in
46-
:file:`SAGE_ROOT/src/sage/libs/cypari2/gen.pyx`, and this is where we
46+
:sage_root:`src/sage/libs/cypari2/gen.pyx`, and this is where we
4747
add the method ``matfrobenius``:
4848

4949
.. CODE-BLOCK:: cython
@@ -194,7 +194,7 @@ Note the ``'"G"'`` which is evaluated in GAP as the string ``"G"``.
194194
The purpose of this section is to use this example to show how one
195195
might write a Python/Sage program whose input is, say, ``('G',2)`` and
196196
whose output is the matrix above (but as a Sage Matrix---see the code
197-
in the directory :file:`SAGE_ROOT/src/sage/matrix/` and the
197+
in the directory :sage_root:`src/sage/matrix/` and the
198198
corresponding parts of the Sage reference manual).
199199

200200
First, the input must be converted into strings consisting of legal
@@ -639,7 +639,7 @@ asynchronous because it derives from the Sage class ``Expect``, which
639639
handles the communication between Sage and the external process.
640640

641641
For example, here is part of the file
642-
``SAGE_ROOT/src/sage/interfaces/octave.py``, which
642+
:sage_root:`src/sage/interfaces/octave.py`, which
643643
defines an interface between Sage and Octave, an open source program
644644
for doing numerical computations, among other things:
645645

@@ -751,5 +751,5 @@ documented.
751751

752752
These are only excerpts from ``octave.py``; check that file for more
753753
definitions and examples. Look at other files in the directory
754-
``SAGE_ROOT/src/sage/interfaces/`` for examples of interfaces to other
754+
:sage_root:`src/sage/interfaces/` for examples of interfaces to other
755755
software packages.

src/doc/en/developer/coding_in_python.rst

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ support the command ``latex``.
128128
illustrates LaTeX generation for your object.
129129

130130
#. You can use any macros included in ``amsmath``, ``amssymb``, or
131-
``amsfonts``, or the ones defined in
132-
``SAGE_ROOT/doc/commontex/macros.tex``.
131+
``amsfonts``, or the ones defined in :mod:`sage.misc.latex_macros`.
133132

134133
An example template for a ``_latex_`` method follows. Note that the
135134
``.. skip`` line should not be included in your code; it is here to
@@ -162,7 +161,7 @@ Print representation
162161
====================
163162

164163
The standard Python printing method is ``__repr__(self)``. In Sage,
165-
that is for objects that derive from ``SageObject`` (which is
164+
that is for objects that derive from :class:`SageObject` (which is
166165
everything in Sage), instead define ``_repr_(self)``. This is
167166
preferable because if you only define ``_repr_(self)`` and not
168167
``__repr__(self)``, then users can rename your object to print however
@@ -171,7 +170,7 @@ the context.
171170

172171
Here is an example of the ``_latex_`` and ``_repr_`` functions for the
173172
``Pi`` class. It is from the file
174-
``SAGE_ROOT/src/sage/symbolic/constants.py``:
173+
:sage_root:`src/sage/symbolic/constants.py`:
175174

176175
.. CODE-BLOCK:: python
177176
@@ -202,7 +201,7 @@ matrix over a ring `R`. Then the Sage function ``matrix`` will work
202201
for this object.
203202

204203
The following is from
205-
``SAGE_ROOT/src/sage/graphs/generic_graph.py``:
204+
:sage_root:`src/sage/graphs/generic_graph.py`:
206205

207206
.. CODE-BLOCK:: python
208207
@@ -221,7 +220,7 @@ The following is from
221220
Similarly, provide a ``_vector_`` method for an object that can be
222221
coerced to a vector over a ring `R`. Then the Sage function ``vector``
223222
will work for this object. The following is from the file
224-
``SAGE_ROOT/src/sage/modules/free_module_element.pyx``:
223+
:sage_root:`src/sage/modules/free_module_element.pyx`:
225224

226225
.. CODE-BLOCK:: python
227226
@@ -298,11 +297,11 @@ creates the file ``foo.sage.py``.
298297

299298
The following files are relevant to preparsing in Sage:
300299

301-
#. ``SAGE_ROOT/src/bin/sage``
300+
#. :sage_root:`src/bin/sage`
302301

303-
#. ``SAGE_ROOT/src/bin/sage-preparse``
302+
#. :sage_root:`src/bin/sage-preparse`
304303

305-
#. ``SAGE_ROOT/src/sage/repl/preparse.py``
304+
#. :sage_root:`src/sage/repl/preparse.py`
306305

307306
In particular, the file ``preparse.py`` contains the Sage preparser
308307
code.
@@ -344,7 +343,7 @@ scope variable.
344343
345344
Certain objects, e.g. matrices, may start out mutable and become
346345
immutable later. See the file
347-
``SAGE_ROOT/src/sage/structure/mutability.py``.
346+
:sage_root:`src/sage/structure/mutability.py`.
348347

349348

350349
The __hash__ special method
@@ -538,15 +537,15 @@ large third-party modules. See also :ref:`section_dependencies_distributions`
538537
for a discussion of imports from the viewpoint of modularization.
539538

540539
First, you must avoid circular imports. For example, suppose that the
541-
file ``SAGE_ROOT/src/sage/algebras/steenrod_algebra.py``
540+
file :sage_root:`src/sage/algebras/steenrod_algebra.py`
542541
started with a line:
543542

544543
.. CODE-BLOCK:: python
545544
546545
from sage.sage.algebras.steenrod_algebra_bases import *
547546
548547
and that the file
549-
``SAGE_ROOT/src/sage/algebras/steenrod_algebra_bases.py``
548+
:sage_root:`src/sage/algebras/steenrod_algebra_bases.py`
550549
started with a line:
551550

552551
.. CODE-BLOCK:: python
@@ -647,17 +646,17 @@ When importing from other Python libraries that do not provide sufficient typing
647646
information, it is possible to augment the library's typing information for
648647
the purposes of typechecking the Sage library:
649648

650-
- Create typestub files and place them in the directory ``SAGE_ROOT/src/typings``.
649+
- Create typestub files and place them in the directory :file:`SAGE_ROOT/src/typings`.
651650
For example, the distribution **pplpy** provides the top-level package :mod:`ppl`,
652651
which publishes no typing information. We can create a typestub file
653-
``SAGE_ROOT/src/typings/ppl.pyi`` or ``SAGE_ROOT/src/typings/ppl/__init__.pyi``.
652+
:file:`SAGE_ROOT/src/typings/ppl.pyi` or :file:`SAGE_ROOT/src/typings/ppl/__init__.pyi`.
654653

655654
- When these typestub files are working well, it is preferable from the viewpoint
656655
of the Sage project that they are "upstreamed", i.e., contributed to the
657656
project that maintains the library. If a new version of the upstream library
658657
becomes available that provides the necessary typing information, we can
659658
update the package in the Sage distribution and remove the typestub files again
660-
from ``SAGE_ROOT/src/typings``.
659+
from :file:`SAGE_ROOT/src/typings`.
661660

662661
- As a fallback, when neither adding typing annotations to source files
663662
nor adding typestub files is welcomed by the upstream project, it is possible

src/doc/en/developer/doctesting.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ Parallel testing the whole Sage library
499499
=======================================
500500

501501
The main Sage library resides in the directory
502-
``SAGE_ROOT/src/``. We can use the syntax described above
502+
:sage_root:`src/`. We can use the syntax described above
503503
to doctest the main library using multiple threads. When doing release
504504
management or patching the main Sage library, a release manager would
505505
parallel test the library using 10 threads with the following command::
@@ -538,22 +538,22 @@ The differences are:
538538
set of tests. First the Sage standard documentation is tested,
539539
i.e. the documentation that resides in
540540

541-
* ``SAGE_ROOT/src/doc/common``
542-
* ``SAGE_ROOT/src/doc/en``
543-
* ``SAGE_ROOT/src/doc/fr``
541+
* :sage_root:`src/doc/common`
542+
* :sage_root:`src/doc/en`
543+
* :sage_root:`src/doc/fr`
544544

545545
Finally, the commands doctest the Sage library. For more details on
546-
these command, see the file ``SAGE_ROOT/Makefile``.
546+
these command, see the file :sage_root:`Makefile`.
547547

548548
* ``make testlong`` --- This command doctests the standard
549549
documentation:
550550

551-
* ``SAGE_ROOT/src/doc/common``
552-
* ``SAGE_ROOT/src/doc/en``
553-
* ``SAGE_ROOT/src/doc/fr``
551+
* :sage_root:`src/doc/common`
552+
* :sage_root:`src/doc/en`
553+
* :sage_root:`src/doc/fr`
554554

555555
and then the Sage library. Doctesting is run with the optional
556-
argument ``--long``. See the file ``SAGE_ROOT/Makefile`` for further
556+
argument ``--long``. See the file :sage_root:`Makefile` for further
557557
details.
558558

559559
* ``make ptest`` --- Similar to the commands ``make test`` and ``make

0 commit comments

Comments
 (0)