Mauricio Villegas

Results 276 comments of Mauricio Villegas

You may want to try [jsonargparse](https://github.com/omni-us/jsonargparse). It has a very extensive support for complex type hints including `Optional`. See in the docs [type hints](https://jsonargparse.readthedocs.io/en/stable/#type-hints) and [basic-usage](https://jsonargparse.readthedocs.io/en/stable/#basic-usage).

@rr- is this something that would be accepted in `docstring_parser`? Should the implementation be different in some way?

> Why not pass `t.__doc__` to `parse` directly? Attribute docstrings don't have a `__doc__`. To parse the MyDataClass example would require to get the short description from the class' `__doc__`...

> My preliminary intuition is that I wouldn't want to extend `parse`'s contract by having it support non-strings, and instead offer a new method that uses `parse()` underneath. But this...

My initial idea would be to use [inspect.getsource](https://docs.python.org/3/library/inspect.html#inspect.getsource), then [ast.parse](https://docs.python.org/3/library/ast.html#ast.parse) and implement an [ast.NodeVisitor](https://docs.python.org/3/library/ast.html#ast.NodeVisitor) to collect all attributes that have docstrings.

The following is a possible implementation to extract docstrings for class attributes: ```python import ast import inspect def ast_is_literal_str(node): return isinstance(node, ast.Expr) and isinstance(node.value, ast.Constant) and isinstance(node.value.value, str) def ast_get_attribute_name(node):...

@rr- how does it look? What would be a good way to introduce this in the package? I would propose to add a `parse_from_component` function to [parser.py](https://github.com/rr-/docstring_parser/blob/master/docstring_parser/parser.py) and create a...

@rr- you can read about this syntax in https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html. @Andry-Bal a question regarding the example. Shouldn't the `.. testcode::` block be indented one more level so that it is clear...

Looking at https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings, which I guess is the definition of the google style, the only defined sections are `Args:`, `Returns:`, `Yields:` and `Raises:`. According to this the example in the...

Looking at the sphinx napoleon extension (which is what is used to handle google style docstrings), I think `Example:` is considered an independent section, see [napoleon.html#docstring-sections](https://www.sphinx-doc.org/en/master/usage/extensions/napoleon.html#docstring-sections). There is also an...