pygmt
pygmt copied to clipboard
Use longname placeholders in the docstrings for common options
Description of proposed changes
For "common" options, we have the option description defined in the file pygmt/helpers/decorators.py. Then in the module wrappers, we can use placeholders like {R} in the docstrings, which are automatically replaced by the long docstrings.
Currently, we use single-letter flags as the placeholders (e.g., {R}, {I}) for most common options, although there are a few exceptions (e.g., {CPT}, {XY}). It works well but sometimes may cause confusion, especially for non-common options like -G and -I.
For example, sometimes the "common" option -G is aliased to fill, but the docstring for placeholder {G} indicates it's aliased to color (e.g., https://github.com/GenericMappingTools/pygmt/issues/1617). I also remember that someone once incorrectly used the placeholder {I} in the docstring, but the -I option for the module has very different meanings (for example, -I means inquiry in some modules).
I find that using long names for these placeholders can avoid these problems and long names are also more readable than short names.
In this PR, I rename the placeholder {I} to {spacing} to show what the changes look like, but I plan to replace all short-name placeholders with long names (e.g., {R} => {region}).
What do you think about the changes?
I agree this is an improvement. In addition to your comments, this also offers a slight benefit to users of IDEs like vscode which do not process the f-strings when displaying the documentation.
Ping @maxrjones @willschlitzer @michaelgrund @yvonnefroehlich
Ping @maxrjones @willschlitzer @michaelgrund @yvonnefroehlich
I can take a look later today or tomorrow.