pygmt icon indicating copy to clipboard operation
pygmt copied to clipboard

Use longname placeholders in the docstrings for common options

Open seisman opened this issue 3 years ago • 1 comments

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?

seisman avatar May 25 '22 08:05 seisman

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.

maxrjones avatar Jun 01 '22 13:06 maxrjones

Ping @maxrjones @willschlitzer @michaelgrund @yvonnefroehlich

seisman avatar Sep 17 '22 06:09 seisman

Ping @maxrjones @willschlitzer @michaelgrund @yvonnefroehlich

I can take a look later today or tomorrow.

maxrjones avatar Sep 17 '22 16:09 maxrjones