Search code examples
pycharm

Generating Sphinx autodoc compatible docstrings with Pycharm


Pycharm 5.0 autocompletes docstring when you start writing a function:

enter image description here

However this format does not to seem to follow any good best practice. How it is possible to change this, so that parameters would be in Sphinx autodoc format:

def communicate(self, bytes):
     """Communicate with devices

     :param bytes: Outgoing request as array of bytes
     """

Solution

  • You can change the default docstring format by going to File -> Settings -> Tools -> Python Integrated Tools, and indicating your style of choice in the "Docstring format" dropdown box. Sphinx uses reStructuredText