PY-16904 Preserve none indent when updating Numpy docstring
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Wed, 16 Sep 2015 12:38:30 +0000 (15:38 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Thu, 17 Sep 2015 10:01:29 +0000 (13:01 +0300)
python/src/com/jetbrains/python/documentation/docstrings/SectionBasedDocStringUpdater.java
python/testData/intentions/afterNumpyAddMissingParameterPreservesNoneIndent.py [new file with mode: 0644]
python/testData/intentions/beforeNumpyAddMissingParameterPreservesNoneIndent.py [new file with mode: 0644]
python/testSrc/com/jetbrains/python/intentions/PyIntentionTest.java

index 860fe3326c1286bb55a1a756a11d59c7d1d9bba9..83f4d8ead46cba704903e0c615310cc33c17b601 100644 (file)
@@ -299,7 +299,7 @@ public abstract class SectionBasedDocStringUpdater extends DocStringUpdater<Sect
   protected String getFieldIndent(@NotNull Section section, @NotNull SectionField field) {
     final String titleIndent = getSectionIndent(section);
     final String fieldIndent = getLineIndent(getFieldStartLine(field));
-    final int diffSize = Math.max(1, PyIndentUtil.getLineIndentSize(fieldIndent) - PyIndentUtil.getLineIndentSize(titleIndent));
+    final int diffSize = Math.max(0, PyIndentUtil.getLineIndentSize(fieldIndent) - PyIndentUtil.getLineIndentSize(titleIndent));
     return StringUtil.repeatSymbol(' ', diffSize);
   }
 
diff --git a/python/testData/intentions/afterNumpyAddMissingParameterPreservesNoneIndent.py b/python/testData/intentions/afterNumpyAddMissingParameterPreservesNoneIndent.py
new file mode 100644 (file)
index 0000000..8e8b5ef
--- /dev/null
@@ -0,0 +1,8 @@
+def f(param1, param2):
+    """
+    Parameters
+    ----------
+    param1
+    param2 : object
+
+    """
\ No newline at end of file
diff --git a/python/testData/intentions/beforeNumpyAddMissingParameterPreservesNoneIndent.py b/python/testData/intentions/beforeNumpyAddMissingParameterPreservesNoneIndent.py
new file mode 100644 (file)
index 0000000..b417d77
--- /dev/null
@@ -0,0 +1,7 @@
+def <caret>f(param1, param2):
+    """
+    Parameters
+    ----------
+    param2 : object
+
+    """
\ No newline at end of file
index a19c4978aaf20190b8f1e4640a66c61762f5ce34..e7ee154de3873b0bb588f455191df6965c26ebfb 100644 (file)
@@ -550,6 +550,11 @@ public class  PyIntentionTest extends PyTestCase {
     }
   }
 
+  // PY-16904
+  public void testNumpyAddMissingParameterPreservesNoneIndent() {
+    doDocAddMissingParamsTest(DocStringFormat.NUMPY);
+  }
+
   // PY-9795
   public void testAddMissingParamsInGoogleDocString() {
     doDocAddMissingParamsTest(DocStringFormat.GOOGLE);