Skip to content

Update COMMON_OPTIONS arguments to GMT standard - #783

Closed
willschlitzer wants to merge 28 commits into
GenericMappingTools:masterfrom
willschlitzer:common-options-doc-update
Closed

willschlitzer wants to merge 28 commits into
GenericMappingTools:masterfrom
willschlitzer:common-options-doc-update

Conversation

@willschlitzer

Copy link
Copy Markdown
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
Copy Markdown
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

seisman commented Jan 21, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
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

seisman commented Jan 21, 2021

Copy link
Copy Markdown
Member

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.

Comment thread pygmt/helpers/decorators.py Resolved

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

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.

Comment thread pygmt/helpers/decorators.py Outdated
@@ -15,13 +15,14 @@
COMMON_OPTIONS = {
"R": """\

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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?)?

Comment thread pygmt/helpers/decorators.py Resolved
Comment thread pygmt/helpers/decorators.py Resolved
Comment thread pygmt/helpers/decorators.py Resolved
Comment thread pygmt/helpers/decorators.py 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
Copy Markdown
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

Comment thread pygmt/helpers/decorators.py Resolved
Comment thread pygmt/helpers/decorators.py 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
Copy Markdown
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

@willschlitzer willschlitzer Feb 10, 2021 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

This branch was previously deployed

1 inactive deployment
Preview — 5609b6e3 Deployed Feb 10, 2021 by vercel[bot]
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.

3 participants