Index: pkg/analysis_server/lib/src/utilities/documentation.dart |
diff --git a/pkg/analysis_server/lib/src/utilities/documentation.dart b/pkg/analysis_server/lib/src/utilities/documentation.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..8e8e6964aa1fbad1858d7a4b3e8882bb2554b2f6 |
--- /dev/null |
+++ b/pkg/analysis_server/lib/src/utilities/documentation.dart |
@@ -0,0 +1,69 @@ |
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
+// for details. All rights reserved. Use of this source code is governed by a |
+// BSD-style license that can be found in the LICENSE file. |
+ |
+library analysis_server.src.utilities.documentation; |
+ |
+String getDartDocSummary(String str) { |
+ if (str == null) { |
+ return null; |
+ } |
+ List<String> lines = str.split('\n'); |
+ StringBuffer sb = new StringBuffer(); |
+ bool firstLine = true; |
+ for (String line in lines) { |
+ if (sb.length != 0 && line.isEmpty) { |
+ return sb.toString(); |
+ } |
+ if (!firstLine) { |
+ sb.write('\n'); |
+ } |
+ firstLine = false; |
+ sb.write(line); |
+ } |
+ return sb.toString(); |
+} |
+ |
+/** |
+ * Converts [str] from a Dart Doc string with slashes and stars to a plain text |
+ * representation of the comment. |
+ */ |
+String removeDartDocDelimiters(String str) { |
+ if (str == null) { |
+ return null; |
+ } |
+ // remove /** */ |
+ if (str.startsWith('/**')) { |
+ str = str.substring(3); |
+ } |
+ if (str.endsWith("*/")) { |
+ str = str.substring(0, str.length - 2); |
+ } |
+ str = str.trim(); |
+ // remove leading '* ' and '/// ' |
+ List<String> lines = str.split('\n'); |
+ StringBuffer sb = new StringBuffer(); |
+ bool firstLine = true; |
+ for (String line in lines) { |
+ line = line.trim(); |
+ if (line.startsWith("*")) { |
+ line = line.substring(1); |
+ if (line.startsWith(" ")) { |
+ line = line.substring(1); |
+ } |
+ } else if (line.startsWith("///")) { |
+ line = line.substring(3); |
+ if (line.startsWith(" ")) { |
+ line = line.substring(1); |
+ } |
+ } |
+ if (!firstLine) { |
+ sb.write('\n'); |
+ } |
+ firstLine = false; |
+ sb.write(line); |
+ } |
+ str = sb.toString(); |
+ // done |
+ return str; |
+} |