Skip to content

DOC: Deprecation directive in docstrings should be placed before the extended summary #24143

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

Closed
datapythonista opened this issue Dec 7, 2018 · 3 comments · Fixed by #24188
Closed

Comments

@datapythonista
Copy link
Member

Based on https://numpydoc.readthedocs.io/en/latest/format.html#sections

This is correct:

def some_old_method():
    """
    This is what old methods does.

    .. deprecated:: 1.0
        Use `some_new_method` instead.

    This is an extended summary with more details about
    what `some_old_method` does.

    The extended summary can contain multiple paragraphs.
    """

This is NOT correct:

def some_old_method():
    """
    This is what old methods does.

    This is an extended summary with more details about
    what `some_old_method` does.

    The extended summary can contain multiple paragraphs.

    .. deprecated:: 1.0
        Use `some_new_method` instead.
    """

But seems like we've been doing it wrong in many cases (see #24105#discussion_r239646516)

What we need to do is:

  • Add a validation in scripts/validate_docstrings.py to check that the order is correct (there is a validation for the order of the sections, it may or may not make sense to validate it there or in a new error).
  • Add tests to check that the new validation works (in scripts/tests/test_validate_docstrings.py)
  • Get the list of all wrong cases (there shouldn't be many, we don't have so much deprecated stuff)
  • Fix the wrong cases by moving the .. deprecated:: directive to the correct position.
  • Add to the call to the validation script in ci/code_checks.py the new error code, so the new validation is checked in the CI.
@aqurilla
Copy link
Contributor

aqurilla commented Dec 7, 2018

Hi! @datapythonista, can I work on this issue?

@datapythonista
Copy link
Member Author

sure @aqurilla, let me know if you need help

@aqurilla
Copy link
Contributor

aqurilla commented Dec 7, 2018

Will do, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants