pydocstring

Top level API - all you need to integrate with an editor, just call pydocstring.generate_docstring() with the source code and the position of your cursor.

pydocstring.generate_docstring(source, position=(1, 0), formatter='google', autocomplete=False)

Generate a docstring

Parameters:
  • source (str) – the text of the source
  • position (tuple) – the position of the cursor in the source, row, column. Rows start at 1 Columns start at 0
  • formatter (str) – the format of the docstring choose from google, numpy, reST.
  • autocomplete (bool) – Whether or not to remove three characters from before the position prior to parsing the code. THis is to remove the “”” before a docstring default: False
Raises:

exc.InvalidFormatter – If the value provided to formatter is not a supported formatter name

Returns:

docstring, excluding quotation marks, or None, if one could not be generated

Return type:

str or None