Yapf: Reformatting docstrings and comments

Created on 20 Jun 2016  路  6Comments  路  Source: google/yapf

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.

Most helpful comment

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.

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

qv-pat picture qv-pat  路  3Comments

hayd picture hayd  路  8Comments

thisfred picture thisfred  路  7Comments

haphut picture haphut  路  3Comments

stevenleeS0ht picture stevenleeS0ht  路  4Comments