Skip to content

DOC: Validate docstring directives #27630

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

Merged

Conversation

albertvillanova
Copy link
Contributor

@albertvillanova albertvillanova commented Jul 28, 2019

@albertvillanova
Copy link
Contributor Author

For the moment, I have hardcoded the directives:

  • deprecated
  • versionadded
  • versionchanged

Nevertheless, I have noted there exist other directives used in pandas:

  • code-block
  • note
  • plot
  • warning

May I also include these?

@albertvillanova
Copy link
Contributor Author

Any reviewer? ;) @gfyoung @datapythonista Thanks.

@albertvillanova albertvillanova changed the title Validate docstring directives DOC: Validate docstring directives Aug 3, 2019
Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Good job, nice PR.

Just couple of comments. Also, can you please add unit tests for the new feature? And can you add GL10 to the list of docstring codes checked in ci/code_checks.sh. If there are failing cases and the CI is red, is ok, let's first see how is this working and if there are cases left, and then we see what we do.

I'm happy to add the other directives you mention (not sure if we have code-block in docstrings, but I think for warning and other can be useful to check. But we can do that in a follow up too.

Thanks!

@@ -239,6 +240,11 @@ def get_api_items(api_doc_fd):


class Docstring:
DIRECTIVES = ["deprecated", "versionadded", "versionchanged"]
DIRECTIVE_WITHOUT_TWO_COLONS = re.compile(
Copy link
Member

Choose a reason for hiding this comment

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

We define similar constants at the top of the file, I'd keep these two there.

I find the name DIRECTIVE_WITHOUT_TWO_COLONS a bit misleading. If I understand correctly it's the same exact directives than the previous, but as compile expression to detect them. I understand your reasoning for the name, and it may be the best option, but reading the two constants gives me the impression that it's a different set of directives.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed. We should rename this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it OK as DIRECTIVE_PATTERN?

Copy link
Member

Choose a reason for hiding this comment

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

sounds good to me

@datapythonista datapythonista added Docs CI Continuous Integration labels Aug 3, 2019
@albertvillanova
Copy link
Contributor Author

All in GREEN (I had already fixed the docstrings #27621).

Copy link
Member

@datapythonista datapythonista left a comment

Choose a reason for hiding this comment

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

Great job @albertvillanova, lgtm. Thanks for adding this, will be very useful.

@gfyoung gfyoung merged commit 54e5803 into pandas-dev:master Aug 6, 2019
@gfyoung
Copy link
Member

gfyoung commented Aug 6, 2019

Thanks @albertvillanova !

@gfyoung gfyoung added this to the 1.0 milestone Aug 6, 2019
quintusdias pushed a commit to quintusdias/pandas_dev that referenced this pull request Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Continuous Integration Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Validate reST directives in docstrings
3 participants