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

Update COMMON_OPTIONS arguments to GMT standard #783

Conversation

willschlitzer
Copy link
Contributor

Update the argument doc strings in the COMMON_OPTIONS dictionary in decorators.py to the standard set in #631.

@willschlitzer willschlitzer added the documentation Improvements or additions to documentation label Jan 3, 2021
@willschlitzer
Copy link
Contributor Author

I can't figure out why this is failing so many tests, as it is changing the content of strings and no functions. It appears to be rendering correctly when it is built in Sphinx.

@seisman
Copy link
Member

seisman commented Jan 21, 2021

One doctest in pygmt.helpers.decorators.fmt_docstring fails.

=================================== FAILURES ===================================
_______________ [doctest] pygmt.helpers.decorators.fmt_docstring _______________
160     ...
161     ...     Parameters
162     ...     ----------
163     ...     {R}
164     ...     {J}
165     ...
166     ...     {aliases}
167     ...     '''
168     ...     pass
169     >>> print(gmtinfo.__doc__)
Differences (unified diff with -expected +actual):
    @@ -5,10 +5,11 @@
     ----------
     region : str or list
    -    *Required if this is the first plot command*.
    -    ``'xmin/xmax/ymin/ymax[+r][+uunit]'``.
    -    Specify the region of interest.
    +    *xmin/xmax/ymin/ymax*\ [**+r**\ ][**+u**\ *unit*]
    +    Specify the region of interest. This is a required argument if this 
    +    is the first plot command.
     projection : str
    -    *Required if this is the first plot command*.
    -    Select map projection.
    +    *projection*\ [*projection-specific arguments*\ ]*figure size*
    +    Select map projection. This is a required argument if this 
    +    is the first plot command.
     <BLANKLINE>
     **Aliases:**

@willschlitzer
Copy link
Contributor Author

I misinterpreted the 12 xfailed as test failures then. Regardless, I can't see how this is causing a doctest failure, so I'm not sure how to fix the strings to make it pass.

@seisman
Copy link
Member

seisman commented Jan 21, 2021

I misinterpreted the 12 xfailed as test failures then.

They are "known" failures.

I can't see how this is causing a doctest failure, so I'm not sure how to fix the strings to make it pass.

You need to update these lines:

Parameters
----------
region : str or list
*Required if this is the first plot command*.
``'xmin/xmax/ymin/ymax[+r][+uunit]'``.
Specify the region of interest.
projection : str
*Required if this is the first plot command*.
Select map projection.

Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reckon this PR is about done, just a few more changes needed.

@@ -15,13 +15,14 @@
COMMON_OPTIONS = {
"R": """\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"R": """\
"R": r"""\

Need to make this a raw r-string to avoid the pylint warning (W605 invalid escape sequence '\ ')

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It rendered incorrectly when I would have raw strings in both COMMON_OPTIONS and the function doc strings (check out the deployment for 62e8aad at the top). My guess is some issue with a raw string with escape characters being passed into another raw string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, might need to rethink this a bit then or just ignore the pylint error if it's harmless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I add a pylint: disable=invalid-escape-sequence (is that the correct wording/syntax?)?

pygmt/helpers/decorators.py Outdated Show resolved Hide resolved
pygmt/helpers/decorators.py Outdated Show resolved Hide resolved
pygmt/helpers/decorators.py Outdated Show resolved Hide resolved
pygmt/helpers/decorators.py Outdated Show resolved Hide resolved
Specify the region of interest. This is a required argument if this
is the first plot command.""",
"J": r"""projection : str
*projection*\ [*projection-specific arguments*\ ]\ *figure size*.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-J option is very difficult to read.
image

pygmt/helpers/decorators.py Outdated Show resolved Hide resolved
pygmt/helpers/decorators.py Outdated Show resolved Hide resolved
Comment on lines 46 to 53
"XY": r"""xshift : str
[**a**\|\ **c**\|\ **f**\|\ **r**\][*xshift*].
Shift plot origin in x-direction.

yshift : str
[**a**\|\ **c**\|\ **f**\|\ **r**\][*yshift*].
Shift plot origin in y-direction. Full documentation is at
:gmt-docs:`gmt.html#xy-full`.""",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Y option is not correctly rendered.
image

Copy link
Contributor Author

@willschlitzer willschlitzer Feb 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seisman I tried adding blank lines to create line breaks in bc6f1e8, but that just caused tests to fail. Any idea how to fix this?

@willschlitzer willschlitzer added this to the 0.3.0 milestone Feb 10, 2021
@willschlitzer
Copy link
Contributor Author

This problem was fixed by @seisman in #862. Closing this PR.

@willschlitzer willschlitzer deleted the common-options-doc-update branch February 12, 2021 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants