4

I recently switched to use PyCharm as my main python IDE. I am having a problem on generating docstrings. I usually follow the Google standard, which is supported natively on PyCharm and with an extension on vscode (https://github.com/NilsJPWerner/autoDocstring).

In vscode, I was getting a very good autocomplete, especially for default and optional parameters. In PyCharm, however, I am only able to add a placeholder for the type information. Below the two examples:

Code to generate doctoring:

def fun(first, second = 1, third = ''):
    raise NotImplementedError

vscode with autoDocstring:

"""[summary]

Args:
    first ([type]): [description]
    second (int, optional): [description]. Defaults to 1.
    third (str, optional): [description]. Defaults to ''.

Raises:
    NotImplementedError: [description]
"""

PyCharm:

"""

Args:
    first (): 
    second (): 
    third (): 

Returns:

"""

Is there a way to improve what PyCharm can generate and get it closer to the combination of vscode and autoDocstring?

Guido Muscioni
  • 1,203
  • 3
  • 15
  • 37
  • Not sure if this answers your question or not but after you create your function name with your parameters, just enter the three double quote marks """. Pycharm should add another three and put a slightly better docstring inside of the two. Of course, though, if your function definition changes, you'll have to manually modify the docstring (I'm not sure how that works w/ vscode). – Ben Sep 24 '20 at 19:53
  • PyCharm output I posted before is done with the """ enter sequence.Thanks! @Ben – Guido Muscioni Oct 01 '20 at 15:34
  • Ahhh. You probably know more about docstrings than I do but you know that you can put the parameter type in the function definition, right? Here's an example... def process_column_modifier(modifier: str, gs_or_tbl: str, col_name: str, tbl_name: str, cols: [{}]) -> str: ...The data type doesn't show up in the """ docstring but it does show up when you refer to this function from other functions (after you type the parens Pycharm tells you the params and their data types). – Ben Oct 01 '20 at 17:48

0 Answers0