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

Developer guide: Recommend raw strings for all docstrings #37508

Merged
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
8 changes: 6 additions & 2 deletions src/doc/en/developer/coding_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,9 @@ You are strongly encouraged to:

- Use LaTeX typesetting (see :ref:`section-latex-typeset`).

- Use raw strings (``r"""..."""``), regardless of whether the docstring
currently contains any backslashes or not.

- Liberally describe what the examples do.

.. NOTE::
Expand Down Expand Up @@ -779,8 +782,7 @@ In Sage's documentation LaTeX code is allowed and is marked with **backticks**:
```x^2 + y^2 = 1``` yields `x^2 + y^2 = 1`.

**Backslashes:** For LaTeX commands containing backslashes, either use double
backslashes or begin the docstring with a ``r"""`` instead of ``"""``. Both of
the following are valid::
backslashes or begin the docstring with a ``r"""`` instead of ``"""``::

kwankyu marked this conversation as resolved.
Show resolved Hide resolved
def cos(x):
"""
Expand All @@ -792,6 +794,8 @@ the following are valid::
Return `\sin(x)`.
"""

We strongly suggest to use the latter.

**MATH block:** This is similar to the LaTeX syntax ``\[<math expression>\]``
(or ``$$<math expression>$$``). For instance:

Expand Down
Loading