PyDocstringGenerator (boolean addReturn) { if (myDocStringOwner instanceof PyFunction) { for (PyParameter param : ((PyFunction)myDocStringOwner).getParameterList().getParameters()) { if (param.getAsNamed() == null) { continue; } final String paramName = param.getName(); final StructuredDocString docString = getStructuredDocString(); if (StringUtil.isEmpty(paramName) || param.isSelf() || docString != null && docString.getParameters().contains(paramName)) { continue; } withParam((PyNamedParameter)param); } final RaiseVisitor visitor = new RaiseVisitor(); final PyStatementList statementList = ((PyFunction)myDocStringOwner).getStatementList(); statementList.accept(visitor); if (!PyUtil.isInitOrNewMethod(myDocStringOwner) && (visitor.myHasReturn || addReturn)) { // will add :return: placeholder in Sphinx/Epydoc docstrings withReturnValue(null); } } return this; }