-
I found several "issues" with the docstring parser which I want to ask about and discuss here first, since I don't know if these "issues" are intentional by design or not. 1. Numpydoc: Grouped attributesGrouped attributes in numpy can't be parsed for attributes, only for parameters. Take for example this code: def function_with_parameters(grouped_parameter_1, grouped_parameter_2)-> None:
"""
Function with parameters.
Dolor sit amet.
Parameters
----------
grouped_parameter_1, grouped_parameter_2 : int, default=4
foo: grouped_parameter_1 and grouped_parameter_2
"""
class ClassWithAttributesAndParameters:
"""
Class with attributes and parameters.
Dolor sit amet.
Parameters
----------
grouped_attribute_3, grouped_attribute_4 : int, default=4
foo: grouped_attribute_3 and grouped_attribute_4
Attributes
----------
grouped_attribute_1, grouped_attribute_2 : int, default=4
foo: grouped_attribute_1 and grouped_attribute_2
"""
grouped_attribute_1, grouped_attribute_2 = 4, 4
def __init__(self, grouped_attribute_3, grouped_attribute_4) -> None:
pass For parameter docstrings (in classes and functions) grouped parameters can be parsed correctly, but not for attributes. Is this intended? 2. Google & Sphinx: Can't parse default values in docstringsGoogle and Sphinx describe default values with "defaults to", e.g.: class ClassWithGoogleDocstring:
"""Lorem ipsum.
Dolor sit amet.
Args:
p (int): foo. Defaults to 1.
"""
def __init__(self, p) -> None:
pass
class ClassWithSphinxDocstring:
"""
Lorem ipsum.
Dolor sit amet.
:param p: foo defaults to 1
:type p: int
"""
def __init__(self, p) -> None:
pass These values can't be parsed with Griffe though. 3. Sphinx attribute types can't be parsedParameters defined with class SphinxClassWithAttributesAndParameters:
"""
Lorem ipsum.
Dolor sit amet.
:param p: foo
:type p: int
:var q: bar
:type q: int
"""
q = 1
def __init__(self, p) -> None:
pass 4.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey, thanks a lot for this detailed report!
|
Beta Was this translation helpful? Give feedback.
Hey, thanks a lot for this detailed report!
The Numpydoc style guide is unclear and doesn't explicitly tell attributes can be grouped.
This is arbitrary text and cannot be parsed indeed. It could be written in something else than english, or use different punctuation, spacing, or describe complex values such as
some value if something else another value
which cannot be translated to Python code.Simply not implemented. Someone else contributed the Sphinx parser. PRs wel…