diff --git a/python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/GoogleDocStringSectionFixer.java b/python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/GoogleDocStringSectionFixer.java index 6974ae8a13cd..e72de9f39eff 100644 --- a/python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/GoogleDocStringSectionFixer.java +++ b/python/src/com/jetbrains/python/codeInsight/editorActions/smartEnter/fixers/GoogleDocStringSectionFixer.java @@ -56,7 +56,7 @@ public class GoogleDocStringSectionFixer extends PyFixer myAddedParams = Lists.newArrayList(); private final List myRemovedParams = Lists.newArrayList(); private final String myDocStringText; - // Updated after buildAndInsert() @Nullable private PyDocStringOwner myDocStringOwner; - private String myDocStringIndent; - private DocStringFormat myDocStringFormat; + private final String myDocStringIndent; + private final DocStringFormat myDocStringFormat; + private final PsiElement mySettingsAnchor; private boolean myUseTypesFromDebuggerSignature = true; private boolean myNewMode = false; // true - generate new string, false - update existing @@ -75,12 +75,14 @@ public class PyDocstringGenerator { private PyDocstringGenerator(@Nullable PyDocStringOwner docStringOwner, @Nullable String docStringText, @NotNull DocStringFormat format, - @NotNull String indentation) { + @NotNull String indentation, + @NotNull PsiElement settingsAnchor) { myDocStringOwner = docStringOwner; myDocStringIndent = indentation; myDocStringFormat = format; myDocStringText = docStringText; myNewMode = myDocStringText == null; + mySettingsAnchor = settingsAnchor; } @NotNull @@ -90,26 +92,28 @@ public class PyDocstringGenerator { indentation = PyIndentUtil.getElementIndent(((PyStatementListContainer)owner).getStatementList()); } final String docStringText = owner.getDocStringExpression() == null ? null : owner.getDocStringExpression().getText(); - return new PyDocstringGenerator(owner, docStringText, DocStringUtil.getConfiguredDocStringFormat(owner), indentation); + return new PyDocstringGenerator(owner, docStringText, DocStringUtil.getConfiguredDocStringFormat(owner), indentation, owner); } @NotNull - public static PyDocstringGenerator create(@NotNull DocStringFormat format, @NotNull String indentation) { - return new PyDocstringGenerator(null, null, format, indentation); + public static PyDocstringGenerator create(@NotNull DocStringFormat format, @NotNull String indentation, @NotNull PsiElement settingsAnchor) { + return new PyDocstringGenerator(null, null, format, indentation, settingsAnchor); } @NotNull public static PyDocstringGenerator update(@NotNull PyStringLiteralExpression docString) { return new PyDocstringGenerator(PsiTreeUtil.getParentOfType(docString, PyDocStringOwner.class), - docString.getText(), DocStringUtil.getConfiguredDocStringFormat(docString), - PyIndentUtil.getElementIndent(docString)); + docString.getText(), + DocStringUtil.getConfiguredDocStringFormat(docString), + PyIndentUtil.getElementIndent(docString), + docString); } @NotNull public static PyDocstringGenerator update(@NotNull DocStringFormat format, @NotNull String indentation, - @NotNull String text) { - return new PyDocstringGenerator(null, text, format, indentation); + @NotNull String text, PsiElement settingsAnchor) { + return new PyDocstringGenerator(null, text, format, indentation, settingsAnchor); } @NotNull @@ -208,19 +212,11 @@ public class PyDocstringGenerator { return myDocStringIndent; } - public void setDocStringFormat(@NotNull DocStringFormat format) { - myDocStringFormat = format; - } - @NotNull public DocStringFormat getDocStringFormat() { return myDocStringFormat; } - public void setDocStringIndent(@NotNull String docStringIndent) { - myDocStringIndent = docStringIndent; - } - public boolean isNewMode() { return myNewMode; } @@ -412,7 +408,7 @@ public class PyDocstringGenerator { } } else if (myDocStringFormat == DocStringFormat.GOOGLE || myDocStringFormat == DocStringFormat.NUMPY) { - builder = myDocStringFormat == DocStringFormat.GOOGLE ? new GoogleCodeStyleDocStringBuilder() : new NumpyDocStringBuilder(); + builder = myDocStringFormat == DocStringFormat.GOOGLE ? GoogleCodeStyleDocStringBuilder.forProject(mySettingsAnchor.getProject()) : new NumpyDocStringBuilder(); final SectionBasedDocStringBuilder sectionBuilder = (SectionBasedDocStringBuilder)builder; if (myAddFirstEmptyLine) { sectionBuilder.addEmptyLine(); @@ -467,7 +463,9 @@ public class PyDocstringGenerator { } else if (myDocStringFormat == DocStringFormat.GOOGLE) { //noinspection ConstantConditions - updater = new GoogleCodeStyleDocStringUpdater((SectionBasedDocString)getStructuredDocString(), myDocStringIndent); + updater = GoogleCodeStyleDocStringUpdater.forProject((GoogleCodeStyleDocString)getStructuredDocString(), + myDocStringIndent, + mySettingsAnchor.getProject()); } else if (myDocStringFormat == DocStringFormat.NUMPY) { //noinspection ConstantConditions diff --git a/python/src/com/jetbrains/python/documentation/docstrings/SectionBasedDocStringUpdater.java b/python/src/com/jetbrains/python/documentation/docstrings/SectionBasedDocStringUpdater.java index 7216492f08cb..69bbf2b9296c 100644 --- a/python/src/com/jetbrains/python/documentation/docstrings/SectionBasedDocStringUpdater.java +++ b/python/src/com/jetbrains/python/documentation/docstrings/SectionBasedDocStringUpdater.java @@ -274,6 +274,7 @@ public abstract class SectionBasedDocStringUpdater extends DocStringUpdater myDecoratorValues = new HashMap(); private boolean myAsync = false; - private PyDocstringGenerator myDocStringGenerator = PyDocstringGenerator.create(DocStringFormat.REST, " "); + private PyDocstringGenerator myDocStringGenerator; /** * Creates builder copying signature and doc from another one. @@ -51,7 +51,7 @@ public class PyFunctionBuilder { @NotNull public static PyFunctionBuilder copySignature(@NotNull final PyFunction source, @NotNull final String... decoratorsToCopyIfExist) { final String name = source.getName(); - final PyFunctionBuilder functionBuilder = new PyFunctionBuilder((name != null) ? name : ""); + final PyFunctionBuilder functionBuilder = new PyFunctionBuilder((name != null) ? name : "", source); for (final PyParameter parameter : source.getParameterList().getParameters()) { final String parameterName = parameter.getName(); if (parameterName != null) { @@ -73,22 +73,22 @@ public class PyFunctionBuilder { return functionBuilder; } - public PyFunctionBuilder(@NotNull String name) { + public PyFunctionBuilder(@NotNull String name, @NotNull PsiElement settingsAnchor) { myName = name; + myDocStringGenerator = PyDocstringGenerator.create(DocStringUtil.getConfiguredDocStringFormat(settingsAnchor), + PyIndentUtil.getIndentFromSettings(settingsAnchor.getProject()), + settingsAnchor); } /** * Adds param and its type to doc + * @param format what docstyle to use to doc param type * @param name param name * @param type param type - * @param format what docstyle to use to doc param type */ @NotNull - public PyFunctionBuilder parameterWithType(@NotNull final String name, - @NotNull final String type, - @NotNull final DocStringFormat format) { + public PyFunctionBuilder parameterWithType(@NotNull String name, @NotNull String type) { parameter(name); - myDocStringGenerator.setDocStringFormat(format); myDocStringGenerator.withParamTypedByName(name, type); return this; } @@ -158,7 +158,6 @@ public class PyFunctionBuilder { List statements = myStatements.isEmpty() ? Collections.singletonList(PyNames.PASS) : myStatements; final String indent = PyIndentUtil.getIndentFromSettings(project); - myDocStringGenerator.setDocStringIndent(indent); // There was original docstring or some parameters were added via parameterWithType() if (!myDocStringGenerator.isNewMode() || myDocStringGenerator.hasParametersToAdd()) { final String docstring = PyIndentUtil.changeIndent(myDocStringGenerator.buildDocString(), true, indent); diff --git a/python/src/com/jetbrains/python/refactoring/classes/membersManager/InstanceFieldsManager.java b/python/src/com/jetbrains/python/refactoring/classes/membersManager/InstanceFieldsManager.java index 0ca143d6eb91..26cefef51cc0 100644 --- a/python/src/com/jetbrains/python/refactoring/classes/membersManager/InstanceFieldsManager.java +++ b/python/src/com/jetbrains/python/refactoring/classes/membersManager/InstanceFieldsManager.java @@ -93,7 +93,7 @@ class InstanceFieldsManager extends FieldsManager { //TODO: Move to utils? @NotNull private static PyFunction createInitMethod(@NotNull final PyClass to) { - final PyFunctionBuilder functionBuilder = new PyFunctionBuilder(PyNames.INIT); + final PyFunctionBuilder functionBuilder = new PyFunctionBuilder(PyNames.INIT, to); functionBuilder.parameter(PyNames.CANONICAL_SELF); //TODO: Take param from codestyle? final PyFunction function = functionBuilder.buildFunction(to.getProject(), LanguageLevel.forElement(to)); return PyClassRefactoringUtil.addMethods(to, true, function).get(0); diff --git a/python/src/com/jetbrains/python/refactoring/extractmethod/PyExtractMethodUtil.java b/python/src/com/jetbrains/python/refactoring/extractmethod/PyExtractMethodUtil.java index 23b4243aee7d..b0ffe97eec0b 100644 --- a/python/src/com/jetbrains/python/refactoring/extractmethod/PyExtractMethodUtil.java +++ b/python/src/com/jetbrains/python/refactoring/extractmethod/PyExtractMethodUtil.java @@ -455,7 +455,7 @@ public class PyExtractMethodUtil { } } // Change signature according to pass settings and - final PyFunctionBuilder builder = new PyFunctionBuilder("foo"); + final PyFunctionBuilder builder = new PyFunctionBuilder("foo", generatedMethod); if (isClassMethod) { builder.parameter("cls"); } @@ -517,7 +517,7 @@ public class PyExtractMethodUtil { @NotNull final AbstractVariableData[] variableData, @NotNull final PsiElement expression, @Nullable final PyUtil.MethodFlags flags, boolean isAsync) { - final PyFunctionBuilder builder = new PyFunctionBuilder(methodName); + final PyFunctionBuilder builder = new PyFunctionBuilder(methodName, expression); addDecorators(builder, flags); addFakeParameters(builder, variableData); if (isAsync) { @@ -543,7 +543,7 @@ public class PyExtractMethodUtil { boolean isAsync) { assert !elementsRange.isEmpty() : "Empty statements list was selected!"; - final PyFunctionBuilder builder = new PyFunctionBuilder(methodName); + final PyFunctionBuilder builder = new PyFunctionBuilder(methodName, elementsRange.get(0)); if (isAsync) { builder.makeAsync(); } diff --git a/python/src/com/jetbrains/python/refactoring/introduce/field/PyIntroduceFieldHandler.java b/python/src/com/jetbrains/python/refactoring/introduce/field/PyIntroduceFieldHandler.java index 26e009d7c5df..a3e579d9e268 100644 --- a/python/src/com/jetbrains/python/refactoring/introduce/field/PyIntroduceFieldHandler.java +++ b/python/src/com/jetbrains/python/refactoring/introduce/field/PyIntroduceFieldHandler.java @@ -187,7 +187,7 @@ public class PyIntroduceFieldHandler extends IntroduceHandler { if (init != null) { return AddFieldQuickFix.appendToMethod(init, callback); } - final PyFunctionBuilder builder = new PyFunctionBuilder(PythonUnitTestUtil.TESTCASE_SETUP_NAME); + final PyFunctionBuilder builder = new PyFunctionBuilder(PythonUnitTestUtil.TESTCASE_SETUP_NAME, clazz); builder.parameter(PyNames.CANONICAL_SELF); PyFunction setUp = builder.buildFunction(clazz.getProject(), LanguageLevel.getDefault()); final PyStatementList statements = clazz.getStatementList(); diff --git a/python/testData/codeInsight/smartEnter/googleDocStringColonAndIndentAfterSection_after.py b/python/testData/codeInsight/smartEnter/googleDocStringColonAndIndentAfterSection_after.py index c03317d64030..76d66ad6c23d 100644 --- a/python/testData/codeInsight/smartEnter/googleDocStringColonAndIndentAfterSection_after.py +++ b/python/testData/codeInsight/smartEnter/googleDocStringColonAndIndentAfterSection_after.py @@ -1,5 +1,5 @@ def func(): """ Args: - + """ \ No newline at end of file diff --git a/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSectionCustomIndent.py b/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSectionCustomIndent.py new file mode 100644 index 000000000000..49e6c1606938 --- /dev/null +++ b/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSectionCustomIndent.py @@ -0,0 +1,4 @@ +def f(): + """ + Raises: + """ \ No newline at end of file diff --git a/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSectionCustomIndent_after.py b/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSectionCustomIndent_after.py new file mode 100644 index 000000000000..cb370585781c --- /dev/null +++ b/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSectionCustomIndent_after.py @@ -0,0 +1,5 @@ +def f(): + """ + Raises: + + """ \ No newline at end of file diff --git a/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSection_after.py b/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSection_after.py index cb370585781c..a7a684b4d953 100644 --- a/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSection_after.py +++ b/python/testData/codeInsight/smartEnter/googleDocStringIndentAfterSection_after.py @@ -1,5 +1,5 @@ def f(): """ Raises: - + """ \ No newline at end of file diff --git a/python/testData/editing/sectionIndentInsideGoogleDocString.after.py b/python/testData/editing/sectionIndentInsideGoogleDocString.after.py index 2d6842087f9e..234f7967875a 100644 --- a/python/testData/editing/sectionIndentInsideGoogleDocString.after.py +++ b/python/testData/editing/sectionIndentInsideGoogleDocString.after.py @@ -1,5 +1,5 @@ def f(param): """ Args: - param + param """ \ No newline at end of file diff --git a/python/testData/editing/sectionIndentInsideGoogleDocStringCustomIndent.after.py b/python/testData/editing/sectionIndentInsideGoogleDocStringCustomIndent.after.py new file mode 100644 index 000000000000..0eacef0f1636 --- /dev/null +++ b/python/testData/editing/sectionIndentInsideGoogleDocStringCustomIndent.after.py @@ -0,0 +1,5 @@ +def f(param): + """ + Args: + param + """ \ No newline at end of file diff --git a/python/testData/editing/sectionIndentInsideGoogleDocStringCustomIndent.py b/python/testData/editing/sectionIndentInsideGoogleDocStringCustomIndent.py new file mode 100644 index 000000000000..f7b48b4ec5ae --- /dev/null +++ b/python/testData/editing/sectionIndentInsideGoogleDocStringCustomIndent.py @@ -0,0 +1,4 @@ +def f(param): + """ + Args: + """ \ No newline at end of file diff --git a/python/testData/inspections/GoogleDocStringAddKeywordVararg_after.py b/python/testData/inspections/GoogleDocStringAddKeywordVararg_after.py index d9e705879c76..e150cacae22b 100644 --- a/python/testData/inspections/GoogleDocStringAddKeywordVararg_after.py +++ b/python/testData/inspections/GoogleDocStringAddKeywordVararg_after.py @@ -1,5 +1,5 @@ def f(**kwargs): """ Args: - **kwargs: + **kwargs: """ \ No newline at end of file diff --git a/python/testData/inspections/GoogleDocStringAddParam_after.py b/python/testData/inspections/GoogleDocStringAddParam_after.py index aa1e26fdaa62..921473a44d2d 100644 --- a/python/testData/inspections/GoogleDocStringAddParam_after.py +++ b/python/testData/inspections/GoogleDocStringAddParam_after.py @@ -1,5 +1,5 @@ def f(b): """ Args: - b: + b: """ \ No newline at end of file diff --git a/python/testData/inspections/GoogleDocStringAddPositionalVararg_after.py b/python/testData/inspections/GoogleDocStringAddPositionalVararg_after.py index 6a8042fd12d5..dfe21ec7ad03 100644 --- a/python/testData/inspections/GoogleDocStringAddPositionalVararg_after.py +++ b/python/testData/inspections/GoogleDocStringAddPositionalVararg_after.py @@ -1,5 +1,5 @@ def f(*args): """ Args: - *args: + *args: """ \ No newline at end of file diff --git a/python/testData/intentions/afterAddMissingParamsInGoogleDocStringEmptyParamSection.py b/python/testData/intentions/afterAddMissingParamsInGoogleDocStringEmptyParamSection.py index e146af3c186f..ed4172f67622 100644 --- a/python/testData/intentions/afterAddMissingParamsInGoogleDocStringEmptyParamSection.py +++ b/python/testData/intentions/afterAddMissingParamsInGoogleDocStringEmptyParamSection.py @@ -1,7 +1,7 @@ def f(x, y, z): """ Parameters: - x: - y: - z: + x: + y: + z: """ \ No newline at end of file diff --git a/python/testData/intentions/afterAddMissingParamsInGoogleDocStringEmptyParamSectionCustomCodeIndent.py b/python/testData/intentions/afterAddMissingParamsInGoogleDocStringEmptyParamSectionCustomCodeIndent.py new file mode 100644 index 000000000000..8daba24562a7 --- /dev/null +++ b/python/testData/intentions/afterAddMissingParamsInGoogleDocStringEmptyParamSectionCustomCodeIndent.py @@ -0,0 +1,7 @@ +def f(x, y, z): + """ + Parameters: + x: + y: + z: + """ \ No newline at end of file diff --git a/python/testData/intentions/afterAddMissingParamsInGoogleDocStringNoParamSection.py b/python/testData/intentions/afterAddMissingParamsInGoogleDocStringNoParamSection.py index d39babd82abc..2e873cc24990 100644 --- a/python/testData/intentions/afterAddMissingParamsInGoogleDocStringNoParamSection.py +++ b/python/testData/intentions/afterAddMissingParamsInGoogleDocStringNoParamSection.py @@ -1,7 +1,7 @@ def f(x, y, z): """ Args: - x: - y: - z: + x: + y: + z: """ \ No newline at end of file diff --git a/python/testData/intentions/afterAddMissingParamsInGoogleDocStringNoParamSectionCustomCodeIndent.py b/python/testData/intentions/afterAddMissingParamsInGoogleDocStringNoParamSectionCustomCodeIndent.py new file mode 100644 index 000000000000..7bbbfb350c6e --- /dev/null +++ b/python/testData/intentions/afterAddMissingParamsInGoogleDocStringNoParamSectionCustomCodeIndent.py @@ -0,0 +1,7 @@ +def f(x, y, z): + """ + Args: + x: + y: + z: + """ \ No newline at end of file diff --git a/python/testData/intentions/afterGoogleDocStubCustomIndent.py b/python/testData/intentions/afterGoogleDocStubCustomIndent.py new file mode 100644 index 000000000000..1321e8b867df --- /dev/null +++ b/python/testData/intentions/afterGoogleDocStubCustomIndent.py @@ -0,0 +1,11 @@ +def f(x, y): + """ + + Args: + x: + y: + + Returns: + + """ + return 42 \ No newline at end of file diff --git a/python/testData/intentions/afterGoogleDocStubEmptyFunctionBody.py b/python/testData/intentions/afterGoogleDocStubEmptyFunctionBody.py index ed96a75bbbb2..85127682e403 100644 --- a/python/testData/intentions/afterGoogleDocStubEmptyFunctionBody.py +++ b/python/testData/intentions/afterGoogleDocStubEmptyFunctionBody.py @@ -2,8 +2,8 @@ def f(x, y): """ Args: - x: - y: + x: + y: """ diff --git a/python/testData/intentions/afterGoogleDocStubInlineFunctionBody.py b/python/testData/intentions/afterGoogleDocStubInlineFunctionBody.py index b4a3cdf9aea1..b30fbfa064e3 100644 --- a/python/testData/intentions/afterGoogleDocStubInlineFunctionBody.py +++ b/python/testData/intentions/afterGoogleDocStubInlineFunctionBody.py @@ -2,8 +2,8 @@ def f(x, y): """ Args: - x: - y: + x: + y: Returns: diff --git a/python/testData/intentions/afterGoogleDocStubInlineFunctionBodyMultilineParametersList.py b/python/testData/intentions/afterGoogleDocStubInlineFunctionBodyMultilineParametersList.py index 62c1fc58fae6..2f29800d4b03 100644 --- a/python/testData/intentions/afterGoogleDocStubInlineFunctionBodyMultilineParametersList.py +++ b/python/testData/intentions/afterGoogleDocStubInlineFunctionBodyMultilineParametersList.py @@ -3,8 +3,8 @@ def f(x, """ Args: - x: - y: + x: + y: Returns: diff --git a/python/testData/intentions/afterGoogleDocStubInlineFunctionBodyNoSpaceBefore.py b/python/testData/intentions/afterGoogleDocStubInlineFunctionBodyNoSpaceBefore.py index b4a3cdf9aea1..b30fbfa064e3 100644 --- a/python/testData/intentions/afterGoogleDocStubInlineFunctionBodyNoSpaceBefore.py +++ b/python/testData/intentions/afterGoogleDocStubInlineFunctionBodyNoSpaceBefore.py @@ -2,8 +2,8 @@ def f(x, y): """ Args: - x: - y: + x: + y: Returns: diff --git a/python/testData/intentions/afterGoogleDocStubWithTypes.py b/python/testData/intentions/afterGoogleDocStubWithTypes.py index d98dffbfa73b..c58f8bd27d16 100644 --- a/python/testData/intentions/afterGoogleDocStubWithTypes.py +++ b/python/testData/intentions/afterGoogleDocStubWithTypes.py @@ -2,8 +2,8 @@ def f(x, y): """ Args: - x (): - y (): + x (): + y (): Returns: diff --git a/python/testData/intentions/afterParamTypeInEmptyGoogleDocString.py b/python/testData/intentions/afterParamTypeInEmptyGoogleDocString.py index 0446fcb10aac..1831028cfe75 100644 --- a/python/testData/intentions/afterParamTypeInEmptyGoogleDocString.py +++ b/python/testData/intentions/afterParamTypeInEmptyGoogleDocString.py @@ -1,5 +1,5 @@ def f(x, y): """ Args: - x (object): + x (object): """ \ No newline at end of file diff --git a/python/testData/intentions/afterParamTypeInGoogleDocStringEmptyParamSection.py b/python/testData/intentions/afterParamTypeInGoogleDocStringEmptyParamSection.py index c16661b5e76b..ae8aafb7abbd 100644 --- a/python/testData/intentions/afterParamTypeInGoogleDocStringEmptyParamSection.py +++ b/python/testData/intentions/afterParamTypeInGoogleDocStringEmptyParamSection.py @@ -3,5 +3,5 @@ def f(x, y): Summary. Parameters: - x (object): + x (object): """ \ No newline at end of file diff --git a/python/testData/intentions/afterParamTypeInGoogleDocStringOnlySummary.py b/python/testData/intentions/afterParamTypeInGoogleDocStringOnlySummary.py index dfd0e9914bf3..62e44c46b073 100644 --- a/python/testData/intentions/afterParamTypeInGoogleDocStringOnlySummary.py +++ b/python/testData/intentions/afterParamTypeInGoogleDocStringOnlySummary.py @@ -3,5 +3,5 @@ def f(x, y): Summary. Args: - x (object): + x (object): """ \ No newline at end of file diff --git a/python/testData/intentions/afterParamTypeInGoogleDocStringOnlySummaryOneLine.py b/python/testData/intentions/afterParamTypeInGoogleDocStringOnlySummaryOneLine.py index 9418ac11257f..105675dc72e0 100644 --- a/python/testData/intentions/afterParamTypeInGoogleDocStringOnlySummaryOneLine.py +++ b/python/testData/intentions/afterParamTypeInGoogleDocStringOnlySummaryOneLine.py @@ -2,5 +2,5 @@ def f(x, y): """Summary. Args: - x (object): + x (object): """ \ No newline at end of file diff --git a/python/testData/intentions/afterParamTypeInNewGoogleDocString.py b/python/testData/intentions/afterParamTypeInNewGoogleDocString.py index b31f12026c63..3427a1256e77 100644 --- a/python/testData/intentions/afterParamTypeInNewGoogleDocString.py +++ b/python/testData/intentions/afterParamTypeInNewGoogleDocString.py @@ -2,6 +2,6 @@ def f(x): """ Args: - x (object): + x (object): """ return 42 \ No newline at end of file diff --git a/python/testData/intentions/afterReturnTypeInEmptyGoogleDocString.py b/python/testData/intentions/afterReturnTypeInEmptyGoogleDocString.py index 17c07c723182..96bc72c1c6b6 100644 --- a/python/testData/intentions/afterReturnTypeInEmptyGoogleDocString.py +++ b/python/testData/intentions/afterReturnTypeInEmptyGoogleDocString.py @@ -1,5 +1,5 @@ def f(x, y): """ Returns: - object: + object: """ \ No newline at end of file diff --git a/python/testData/intentions/afterReturnTypeInGoogleDocStringEmptyReturnSection.py b/python/testData/intentions/afterReturnTypeInGoogleDocStringEmptyReturnSection.py index 630e5a2168c8..e5a8056258f9 100644 --- a/python/testData/intentions/afterReturnTypeInGoogleDocStringEmptyReturnSection.py +++ b/python/testData/intentions/afterReturnTypeInGoogleDocStringEmptyReturnSection.py @@ -3,5 +3,5 @@ def f(x, y): Summary. Returns: - object: + object: """ \ No newline at end of file diff --git a/python/testData/intentions/afterReturnTypeInNewGoogleDocString.py b/python/testData/intentions/afterReturnTypeInNewGoogleDocString.py index 9417a926bd41..cccff17f2f14 100644 --- a/python/testData/intentions/afterReturnTypeInNewGoogleDocString.py +++ b/python/testData/intentions/afterReturnTypeInNewGoogleDocString.py @@ -2,6 +2,6 @@ def f(x): """ Returns: - object: + object: """ return 42 \ No newline at end of file diff --git a/python/testData/intentions/beforeAddMissingParamsInGoogleDocStringEmptyParamSectionCustomCodeIndent.py b/python/testData/intentions/beforeAddMissingParamsInGoogleDocStringEmptyParamSectionCustomCodeIndent.py new file mode 100644 index 000000000000..1fd53417fddc --- /dev/null +++ b/python/testData/intentions/beforeAddMissingParamsInGoogleDocStringEmptyParamSectionCustomCodeIndent.py @@ -0,0 +1,4 @@ +def f(x, y, z): + """ + Parameters: + """ \ No newline at end of file diff --git a/python/testData/intentions/beforeAddMissingParamsInGoogleDocStringNoParamSectionCustomCodeIndent.py b/python/testData/intentions/beforeAddMissingParamsInGoogleDocStringNoParamSectionCustomCodeIndent.py new file mode 100644 index 000000000000..dd2501bbae71 --- /dev/null +++ b/python/testData/intentions/beforeAddMissingParamsInGoogleDocStringNoParamSectionCustomCodeIndent.py @@ -0,0 +1,3 @@ +def f(x, y, z): + """ + """ \ No newline at end of file diff --git a/python/testData/intentions/beforeGoogleDocStubCustomIndent.py b/python/testData/intentions/beforeGoogleDocStubCustomIndent.py new file mode 100644 index 000000000000..c57c31a3f729 --- /dev/null +++ b/python/testData/intentions/beforeGoogleDocStubCustomIndent.py @@ -0,0 +1,2 @@ +def f(x, y): + return 42 \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/PyEditingTest.java b/python/testSrc/com/jetbrains/python/PyEditingTest.java index f397dcec4e01..3428a30fe8b3 100644 --- a/python/testSrc/com/jetbrains/python/PyEditingTest.java +++ b/python/testSrc/com/jetbrains/python/PyEditingTest.java @@ -251,6 +251,12 @@ public class PyEditingTest extends PyTestCase { doDocStringTypingTest("\nparam", DocStringFormat.GOOGLE); } + // PY-16765 + public void testSectionIndentInsideGoogleDocStringCustomIndent() { + getCommonCodeStyleSettings().getIndentOptions().INDENT_SIZE = 2; + doDocStringTypingTest("\nparam", DocStringFormat.GOOGLE); + } + public void testEnterInString() { // PY-1738 doTestEnter("a = \"some string\"", "a = \"some \" \\\n" + " \"string\""); diff --git a/python/testSrc/com/jetbrains/python/PySmartEnterTest.java b/python/testSrc/com/jetbrains/python/PySmartEnterTest.java index 893bd425d89d..ac609850a7b6 100644 --- a/python/testSrc/com/jetbrains/python/PySmartEnterTest.java +++ b/python/testSrc/com/jetbrains/python/PySmartEnterTest.java @@ -234,4 +234,14 @@ public class PySmartEnterTest extends PyTestCase { } }); } + + // PY-16765 + public void testGoogleDocStringIndentAfterSectionCustomIndent() { + getCommonCodeStyleSettings().getIndentOptions().INDENT_SIZE = 2; + runWithDocStringFormat(DocStringFormat.GOOGLE, new Runnable() { + public void run() { + doTest(); + } + }); + } } diff --git a/python/testSrc/com/jetbrains/python/intentions/PyIntentionTest.java b/python/testSrc/com/jetbrains/python/intentions/PyIntentionTest.java index 976b98f8e2ed..a551418fcb16 100644 --- a/python/testSrc/com/jetbrains/python/intentions/PyIntentionTest.java +++ b/python/testSrc/com/jetbrains/python/intentions/PyIntentionTest.java @@ -419,6 +419,12 @@ public class PyIntentionTest extends PyTestCase { }); } + // PY-16765 + public void testGoogleDocStubCustomIndent() { + getCommonCodeStyleSettings().getIndentOptions().INDENT_SIZE = 2; + doDocStubTest(DocStringFormat.GOOGLE); + } + // PY-9795 public void testGoogleDocStubInlineFunctionBody() { doDocStubTest(DocStringFormat.GOOGLE); @@ -565,10 +571,22 @@ public class PyIntentionTest extends PyTestCase { doDocAddMissingParamsTest(DocStringFormat.GOOGLE); } + // PY-16765 + public void testAddMissingParamsInGoogleDocStringNoParamSectionCustomCodeIndent() { + getCommonCodeStyleSettings().getIndentOptions().INDENT_SIZE = 2; + doDocAddMissingParamsTest(DocStringFormat.GOOGLE); + } + // PY-9795 public void testAddMissingParamsInGoogleDocStringEmptyParamSection() { doDocAddMissingParamsTest(DocStringFormat.GOOGLE); } + + // PY-16765 + public void testAddMissingParamsInGoogleDocStringEmptyParamSectionCustomCodeIndent() { + getCommonCodeStyleSettings().getIndentOptions().INDENT_SIZE = 2; + doDocAddMissingParamsTest(DocStringFormat.GOOGLE); + } // PY-4717 public void testReturnTypeInNewNumpyDocString() {