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

Recommend r"""docstring""" over """docstring""" #25998

Closed
MareoRaft mannequin opened this issue Aug 4, 2018 · 1 comment · Fixed by #37508
Closed

Recommend r"""docstring""" over """docstring""" #25998

MareoRaft mannequin opened this issue Aug 4, 2018 · 1 comment · Fixed by #37508

Comments

@MareoRaft
Copy link
Mannequin

MareoRaft mannequin commented Aug 4, 2018

The general conventions webpage https://doc.sagemath.org/html/en/developer/coding_basics.html#latex-typesetting says that both docstring syntaxes (r"""docstring""" and """docstring""") are valid (which is true), but fails to recommend one over the other.

Since it is a conventions webpage, I think it is appropriate to recommend r"""docstring""" over the latter here. The r convention is nicer because you don't need double backslashes in latex code, which is shorter and makes it easier to copy latex code from docstrings to a latex document and vice-versa. Moreover, the webpage says that we follow the PEP257 conventions (https://www.python.org/dev/peps/pep-0257/) which themselves say 'Use r"""raw triple double quotes""" if you use any backslashes in your docstrings.'

Happy to make the changes myself once everyone is on board.

Component: documentation

Keywords: convention, raw

Author: Matthew Lancellotti

Issue created by migration from https://trac.sagemath.org/ticket/25998

@MareoRaft MareoRaft mannequin added this to the sage-8.4 milestone Aug 4, 2018
@bgillesp
Copy link
Contributor

bgillesp commented Aug 9, 2018

comment:1

Seems like a potentially good suggestion, but to clarify, do you think that this should be only in reference to docstrings containing LaTeX commands (the subsection linked in the description), or do you think it should be a universal recommendation for all docstrings?

If for all docstrings, this seems like a modestly significant convention change (though still possibly a good one), as usage of raw versus non-raw docstrings is all over the place in Sage currently. On the technical side, specifying raw docstrings would sacrifice the ability to use quoted characters, although I imagine this is not a frequently used feature in Sage docstrings.

Personally I'm happiest with "pythonic" conventions that specify a single correct manner of doing something, as long as it doesn't impose undue technical restrictions, so a universal recommendation for the r"""docstring""" convention sounds like a positive tweak to me. Interested what other more experienced developers think of this.

@mkoeppe mkoeppe removed this from the sage-8.4 milestone Dec 29, 2022
vbraun pushed a commit to vbraun/sage that referenced this issue Mar 30, 2024
…trings

    
- Resolves sagemath#25998

<!-- ^ 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 sagemath#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 sagemath#12345". -->



### 📝 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,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
    
URL: sagemath#37508
Reported by: Matthias Köppe
Reviewer(s): Kwankyu Lee
@mkoeppe mkoeppe added this to the sage-10.4 milestone Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants