10

If I press M-q in a docstring like this, then the line breaks in the docstring get messed up:

def foo(word):
  """
  This is a function that does something.
  @param word: str, input.
  @returns: True
  """

becomes this

def foo(word):
  """This is a function that does something. @param word:
  str, input. @returns: True
  """

1 Answer 1

3

python-docstring is a package that overrides fill-paragraph so it is compatible with Python docstrings. It works for both sphinx-doc and reStructuredtext formats. It also provides syntax highlighting, and I believe will highlight markup in your docstrings.

This may be a good place to start. I haven't tried myself, but if you have a docstring format that isn't included, it should be possible to extend the package. For your use case, I imagine it would be a case of editing the regular expressions that detect variables. It might be harder to get it working for Google-style docstrings, however.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.