Repository navigation
Conversation
It is parsed into a DocstringMeta.
|
In my actual usage I'm monkey patching to support a style similar to google: import docstring_parser.parser.google, re
docstring_parser.parser.google._sections = {
"ARGUMENTS": "param",
"EXAMPLES": "examples",
}
docstring_parser.parser.google._titles_re = re.compile(
"^(" + "|".join("(%s)" % t for t in docstring_parser.parser.google._sections) + ")", flags=re.M
)
docstring_parser.parser.google._valid = {t for t, a in docstring_parser.parser.google._sections.items() if a} |
|
@pslacerda can you add tests for this? |
|
Sure I can. I do need Notes, Note and Example also, beside Examples. Should I add these too? |
|
Yes. If you're feeling adventurous, you could refactor it so that extending the library for whatever sections you need is possible and doesn't require such hacks. |
|
I was feeling adventurous, just finished the code. Even with it a bit ugly, it is working for my case. I expect it to be an usual case. |
|
-- I'd rather preferred GoogleParser. |
rr-
left a comment
There was a problem hiding this comment.
Thank you. Excellent work, though I don't understand the last comment. I requested only some cosmetic changes.
|
I was trying to say that maybe it could be like: class GoogleParser:
"""New API for custom sections"""
_sections: ...
_title_colon: ...
_titles_re: ...
_valid: ...
def __init__(sections=None, title_colon=True): pass
def parse(): pass
def add_section(): pass
def _build_meta(): pass
def parse(s):
"""Old & easy API keep as it was."""
return GoogleParser().parse(s)But now I like the way it turned. |
|
Just tried with classes, see if you like. Also things that looks like titles but aren't titles are now description. |
|
@pslacerda thanks, beautiful work. Merged. LMK if you need a new version on PyPI. |
|
@rr- seems you merged local but didn't pushed to Github. |
|
@pslacerda haha you're right :D I just pushed the changes. OK, LMK once you document the changes and we'll release a new version. Also, I apologize for the late reply. |
It is parsed into a DocstringMeta.