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
  """
Lenar Hoyt
  • 1,163
  • 7
  • 25

1 Answers1

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.

JCC
  • 989
  • 5
  • 15