You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to reproduce original GMT arguments in PyGMT documentation #631
The GMT documentation has many instances where bold and italicized fonts are mixed, looking something like:
+nargs
The PyGMT documentation has been rather inconsistent with this (see mentions at #525 (comment) and #620 (comment)).
What we should do is to standardize how we want +nargs to be written in the documentation. This is a bit complicated, but boils down to (at least) two options:
For consistency, always use """triple double quotes""" around docstrings. Use r"""raw triple double quotes""" if you use any backslashes in your docstrings. For Unicode docstrings, use u"""Unicode triple-quoted strings""".
So, instead of using r" **+n**\ *args* " for each individual cases, we should use r for the whole docstring, e.g.,
def function():
r"""
A long docstring string.
We now can write doctsrings with backslashes **+n**\ *args*
"""
@seisman I like this convention for explaining literal titles and the associated arguments that go with them. Are you thinking there should be similar formatting in the string of arguments given in the doctstring?
Ping @GenericMappingTools/python, @GenericMappingTools/python-maintainers and @GenericMappingTools/python-contributors for thoughts on #631 (comment) and #631 (comment).
I think making the entire docstring a raw string is the way to go; I think a double backslash might be confusing to some, and copying directly from GMT makes life easier.
I can write this up in CONTRIBUTING.md when we come to a consensus.
Is the convention for documenting defaults in PyGMT set? In GMT, it is typically brackets [ ] without any explanation before the default. I remember a comment in which @seisman mentioned that "[Default is ...]" is more clear than just "[...]", but I couldn't find that comment again.
In GMT, it is typically brackets [ ] without any explanation before the default. I remember a comment in which @seisman mentioned that "[Default is ...]" is more clear than just "[...]",
Yes, it's open for discussions. The GMT documentation sometimes also uses "[Default is ...]".
Activity
seisman commentedon Dec 17, 2020
This is what PEP-257 says:
So, instead of using
r" **+n**\ *args* "for each individual cases, we should userfor the whole docstring, e.g.,seisman commentedon Dec 18, 2020
As pointed out by @weiji14, the PyGMT documentation is inconsistently using italics, bold, and
codestrings.I think we can following these conventions:
codefor Python function parametersThis is a good example of what it looks like (https://www.pygmt.org/dev/tutorials/frames.html):
seisman commentedon Dec 18, 2020
Ping @GenericMappingTools/python @willschlitzer for thoughts on this.
willschlitzer commentedon Dec 19, 2020
@seisman I like this convention for explaining literal titles and the associated arguments that go with them. Are you thinking there should be similar formatting in the string of arguments given in the doctstring?
seisman commentedon Dec 19, 2020
Yes, but need feedbacks first.
seisman commentedon Dec 22, 2020
Ping @GenericMappingTools/python for comments.
seisman commentedon Dec 29, 2020
Ping @GenericMappingTools/python, @GenericMappingTools/python-maintainers and @GenericMappingTools/python-contributors for thoughts on #631 (comment) and #631 (comment).
weiji14 commentedon Dec 29, 2020
Let's go with Option 1 (using the raw string). Easier to copy from GMT, and avoids messy backslashes. Also agree on the backtick
codeblocks.Will need to document this (with an example) somewhere in CONTRIBUTING.md
willschlitzer commentedon Dec 29, 2020
I think making the entire docstring a raw string is the way to go; I think a double backslash might be confusing to some, and copying directly from GMT makes life easier.
I can write this up in CONTRIBUTING.md when we come to a consensus.
seisman commentedon Dec 29, 2020
At least three of the maintainers agree with this. I think we can do it now.
seisman commentedon Dec 30, 2020
As most of us agree with the new docstring conventions, we should do:
9 remaining items
seisman commentedon Feb 12, 2021
Great! Please try your best to follow the standards as documented here (https://github.com/GenericMappingTools/pygmt/blob/master/CONTRIBUTING.md#example-code-standards).
There may be some cases that are not covered by the standards. We can discuss more later.
Update the docstrings in the plotting modules (#881)
maxrjones commentedon Feb 19, 2021
Is the convention for documenting defaults in PyGMT set? In GMT, it is typically brackets [ ] without any explanation before the default. I remember a comment in which @seisman mentioned that "[Default is ...]" is more clear than just "[...]", but I couldn't find that comment again.
seisman commentedon Feb 19, 2021
Yes, it's open for discussions. The GMT documentation sometimes also uses "[Default is ...]".
maxrjones commentedon Feb 20, 2021
Moving forward is seems that the GMT documentation will be going with "[Default is ...]" (see GenericMappingTools/gmt#4834).
Update docstrings links for return classes (#954)
seisman commentedon Mar 27, 2021
I think we can document it in the "Example code standards" section, then close the issue, right?
maxrjones commentedon Mar 29, 2021
Yes, I can add that guideline after #1126 is merged.
Update the docstrings in the plotting modules (GenericMappingTools#881)
Update docstrings links for return classes (GenericMappingTools#954)