Reformatting docstrings and comments
By running the current 0.10.0 version of yapf on
def func(a):
"""Do something awesome.
This is a long long long description of the awesome work that is done by this function. Despite being very detailed, it runs over the column limit.
"""
we basically cannot get any formatting of the docstring. Could you please help me if it is a feature that is currently absent from yapf? If it could be reformatted into something like,
def func(a):
"""Do something awesome.
This is a long long long description of the awesome work that is done by
this function. Despite being very detailed, it runs over the column limit.
"""
quite a lot of something like gq in vim could be saved. If it could reformat the docstring in the default Sphinx, numpy, or Google format, probably it could be even more helpful.
I would also appreciate the option to have a different maximum line length for comments.
@tschijnmo: I just ran into https://github.com/myint/docformatter. That might help?
Yes please. YAPF doesn't seem to reformat docstrings at all. Intended behavior?
I've done this internally, and it's a mess. There are so many conditions that are needed. The best way would be to create a lib2to3 fixer. If someone wanted to offer a patch, I would consider it.
I assume this goes for reflowing comments as well? Would be handy for sure.
How about just piggybacking off of https://github.com/myint/docformatter? It just doesn't seem inline with YAPF's philosophy of being like go fmt in that a canonical formatting should be produced, when it totally ignores docstrings at the moment.
How about doctest?
def f():
"""
>>> 1+2 # -> 1 + 2
3
"""