Better extraction of summary from plain text docstrings
authorMikhail Golubev <mikhail.golubev@jetbrains.com>
Tue, 22 Sep 2015 12:49:04 +0000 (15:49 +0300)
committerMikhail Golubev <mikhail.golubev@jetbrains.com>
Tue, 22 Sep 2015 15:44:09 +0000 (18:44 +0300)
python/src/com/jetbrains/python/documentation/docstrings/PlainDocString.java

index a94d4924eb05eb656905da25dc29ac12389a7494..e023000dbaf248e6e81656e9906d16936f25e3cd 100644 (file)
@@ -34,10 +34,11 @@ public class PlainDocString extends DocStringLineParser implements StructuredDoc
 
   public PlainDocString(@NotNull Substring content) {
     super(content);
-    if (!isEmpty(0) && isEmptyOrDoesNotExist(1)) {
-      mySummary = getLine(0).trim().toString();
-      final int next = consumeEmptyLines(1);
-      if (next != 1 && next < getLineCount()) {
+    final int firstNonEmpty = consumeEmptyLines(0);
+    if (firstNonEmpty < getLineCount() && isEmptyOrDoesNotExist(firstNonEmpty + 1)) {
+      mySummary = getLine(firstNonEmpty).trim().toString();
+      final int next = consumeEmptyLines(firstNonEmpty + 1);
+      if (next < getLineCount()) {
         final String remaining = getLine(next).union(getLine(getLineCount() - 1)).toString();
         myDescription = PyIndentUtil.removeCommonIndent(remaining, false);
       }