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
Better way to document the aliases in docstrings #4011
In the initial version of the alias system, each GMT option flag is aliased to a single parameter PyGMT, so documenting the aliases in docstrings is simple and can be fully automatic. The aliases docstrings are like:
**Aliases:**
- J=projection
- B=frame
- R=region
Then we realized that sometimes an option flag is too complicated and should be aliased to multiple parameters, and they're documented like below since #3965:
With the new alias system introduced in #4000, we have to manually maintain the aliases in docstrings.
We need to discuss what the docstrings look like, especially for option flags that are aliased to multiple parameters. Let me take -U as an example. The GMT CLI syntax is -U[label][+jjustify][+odx[/dy]][+ttext], then the docstrings can be:
U=label, justify (+j), offset (+o), text (+t)
or
U=label, +j: justify, +o: offset, +t: text
We also need to add a documentation explaining how the new alias system works and how to read and understand the aliases in docstrings.
I prefer the second version for the syntax, as the GMT flag or modifier is consistently followed by the alias.
Hm, maybe this was only an example with focus on modifiers which have or will have their own alias. Or do we now also want to mention the flags which are implemented as standalone methods? -U (as well as -X and -Y) are not anymore supported but we have Figure.timestamp and Figure.shift_origin.
do we now also want to mention the flags which are implemented as standalone methods? -U (as well as -X and -Y) are not anymore supported but we have Figure.timestamp and Figure.shift_origin.
I prefer not to list these flags in the docstrings.
When adding the aliases for the modifiers the lines get longer. Maybe this does not look nice with the multi-column layout we have currently and we have to go back to a one-column layout.
Maybe we can still use a three-column layout for most simple option flags (like -J, -R) and use a one-column layout for a few option flags that are aliased to multiple parameters, although it means the option flags won't be sorted alphabetically.
Activity
seisman commentedon Aug 3, 2025
Ping @GenericMappingTools/pygmt-maintainers Any comments on the docstring styles for aliases?
yvonnefroehlich commentedon Aug 3, 2025
I prefer the second version for the syntax, as the GMT flag or modifier is consistently followed by the alias.
Hm, maybe this was only an example with focus on modifiers which have or will have their own alias. Or do we now also want to mention the flags which are implemented as standalone methods? -U (as well as -X and -Y) are not anymore supported but we have
Figure.timestampandFigure.shift_origin.seisman commentedon Aug 4, 2025
I prefer not to list these flags in the docstrings.
yvonnefroehlich commentedon Aug 4, 2025
When adding the aliases for the modifiers the lines get longer. Maybe this does not look nice with the multi-column layout we have currently and we have to go back to a one-column layout.
seisman commentedon Aug 4, 2025
That's a good point. Will try and see how it looks like.
seisman commentedon Aug 4, 2025
You're right that it looks bad when an option flag is aliased to many parameters.
seisman commentedon Aug 7, 2025
Maybe we can still use a three-column layout for most simple option flags (like
-J,-R) and use a one-column layout for a few option flags that are aliased to multiple parameters, although it means the option flags won't be sorted alphabetically.