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

If already numpydoc format, will remove the Raises section #49

Closed
dadadel opened this issue Oct 1, 2017 · 2 comments
Closed

If already numpydoc format, will remove the Raises section #49

dadadel opened this issue Oct 1, 2017 · 2 comments

Comments

@dadadel
Copy link
Owner

dadadel commented Oct 1, 2017

If a function is already described by a Numpydoc docstring, Pyment will remove the raises section when producing Numpydoc output docstring instead of keeping as is.

The following code (from tests/docs_already_numpydoc.py):

def func1(param1):
    """Function 1
    with 1 param

    Parameters
    ----------
    param1 : type
        1st parameter

    Returns
    -------
    string
        a message

    Raises
    ------
    KeyError
        when a key error
    """
    return "huh"

Will produce the patch:

--- a/docs_already_numpydoc.py
+++ b/docs_already_numpydoc.py
@@ -12,10 +12,7 @@
     string
         a message

-    Raises
-    ------
-    KeyError
-        when a key error
+    
     """
     return "huh"

This example is in the test suite test_pyment_cases.

@wagnerpeer
Copy link
Contributor

wagnerpeer commented Jul 13, 2018

Docstrings containing a section following the "Raises" section will result in pyment correctly parsing and generating an empty diff!
This can be tested inserting such a section into the example file tests/docs_already_numpydoc.py like the following:

def func1(param1):
    """Function 1
    with 1 param

    Parameters
    ----------
    param1 : type
        1st parameter

    Returns
    -------
    string
        a message

    Raises
    ------
    KeyError
        when a key error
    
    Notes
    -----
    Some notes
    """
    return "huh"

To debug the code I reactivated the already existing but commented test tests/pyment_test_cases.FilesConversionTests.testCaseNoGenDocsAlreadyNumpydoc.

To fix the issue one had to calculate the correct, positive relative end index in NumpydocTools.get_list_key instead of using -1 as end index.

But because there are more issues with already existing numpydoc which gets "converted" to numpydoc I left the tests untouched and I also did not modify the tests/docs_already_numpydoc.py file in the way I describe above as this would also obfuscate the current issue with using "Raises" as last section.

See PR #60

@dadadel
Copy link
Owner Author

dadadel commented Nov 19, 2019

The issue is fixed by the wagnerpeer refactorization.

@dadadel dadadel closed this as completed Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants