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

Wrong number of Parameter for numpy array. #285

Closed
Carreau opened this issue Jul 16, 2020 · 1 comment · Fixed by #286
Closed

Wrong number of Parameter for numpy array. #285

Carreau opened this issue Jul 16, 2020 · 1 comment · Fixed by #286

Comments

@Carreau
Copy link
Contributor

Carreau commented Jul 16, 2020

In [1]: from numpydoc.docscrape import NumpyDocString
   ...: from numpy import array
   ...: len(NumpyDocString(array.__doc__)['Parameters'])
Out[1]: 1

(should be 6)

Again due to a dedent issue:

$ git diff
diff --git a/numpydoc/docscrape.py b/numpydoc/docscrape.py
index d79992c..3db20fe 100644
--- a/numpydoc/docscrape.py
+++ b/numpydoc/docscrape.py
@@ -219,6 +219,7 @@ class NumpyDocString(Mapping):
                 yield name, self._strip(data[2:])

     def _parse_param_list(self, content, single_element_is_type=False):
+        content = dedent_lines(content)
         r = Reader(content)
         params = []
         while not r.eof():

Fixes it.

Not quite sure why it is not found in tests...

@larsoner
Copy link
Collaborator

PR welcome to fix it!

Not quite sure why it is not found in tests...

Is it possible in Sphinx (where it's used in practice most often I suppose) the dedent is already called?

Carreau added a commit to Carreau/numpydoc that referenced this issue Jul 18, 2020
Closes numpy#285

This fixes two tings:

 - When first sentence of the docstring is onteh first line, Parameters
 is not properly parse, which for example mis parsed numpy.array
 docstring.

 - many project have paremeters description list with ` :` afer the
 name, even if no type is present. If there is no space after the `:`
 the parameter name includes the ` :` which is most likely wrong.
Carreau added a commit to Carreau/numpydoc that referenced this issue Jul 18, 2020
Closes numpy#285

This fixes two tings:

 - When first sentence of the docstring is onteh first line, Parameters
 is not properly parse, which for example mis parsed numpy.array
 docstring.

 - many project have paremeters description list with ` :` afer the
 name, even if no type is present. If there is no space after the `:`
 the parameter name includes the ` :` which is most likely wrong.
larsoner added a commit that referenced this issue Aug 10, 2020
* Fix param parsing.

Closes #285

This fixes two tings:

 - When first sentence of the docstring is onteh first line, Parameters
 is not properly parse, which for example mis parsed numpy.array
 docstring.

 - many project have paremeters description list with ` :` afer the
 name, even if no type is present. If there is no space after the `:`
 the parameter name includes the ` :` which is most likely wrong.

* test fixture

* make doc a fixture

* Update numpydoc/tests/test_docscrape.py

Co-authored-by: Eric Larson <larson.eric.d@gmail.com>

* Update numpydoc/tests/test_docscrape.py

Co-authored-by: Eric Larson <larson.eric.d@gmail.com>

Co-authored-by: Eric Larson <larson.eric.d@gmail.com>
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

Successfully merging a pull request may close this issue.

2 participants