Pycharm Plugin add DocString to Python Function

Hello,

i want to add a DocString to a python function via plugin. If the function has a DocString I ca do it by

"\"\"\"" + "test123"+ "\"\"\"");
pyFunction.getDocStringExpression();
docStringExpression.replace(docstring);


but I don't know how to add the DocString if

docStringExpression == null


what would be the best way to do it?

2 comments
Comment actions Permalink

PyStatementList statementList = element.getStatementList();
statementList.addBefore(docstring, statementList.getStatements()[0]);

0
Comment actions Permalink

Works Great! Thank You!


0

Please sign in to leave a comment.