question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reformatting docstrings and comments

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:39
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
JorisEcommented, Jul 11, 2016

I would also appreciate the option to have a different maximum line length for comments.

4reactions
carlthomecommented, Oct 21, 2016

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reformatting Python Multiline Comments and Docstrings in ...
I believe you are looking for the "textwrap" module, which controls denting, dedenting, paragraph width, etc.
Read more >
The No 1 Ultimate Guide to Comments and Docstrings in Python
Firstly in Comment and Docstring Tutorial we are going to talk about Comments as they are more common and easier to understand.
Read more >
Advanced Code Documentation Beyond Comments and ...
Personally, I prefer Google docstring format as it results in wider docstrings with fewer lines of code. Numpy docstring format tends to result...
Read more >
Python Docstrings Tutorial : Examples & Format for Pydoc ...
Docstrings are represented with closing & opening quotes, while comments start with a # at the beginning. Note that comments can not be...
Read more >
Docstrings Format — Python Notes for Linguistics
Docstrings Format ¶ · Docstrings are important in the coding process. · Good documentation of the codes would make the codes earsier to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found