Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Commit 87c46f9

Browse files
authored
Docstring converter (#596)
Closes #548. Still missing Google/Numpy style param/return/etc list parsing. I'm also not too happy with the code duplication in the markdown documentation source.
1 parent d25e0dd commit 87c46f9

File tree

8 files changed

+1183
-6
lines changed

8 files changed

+1183
-6
lines changed

src/Core/Impl/Extensions/StringExtensions.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public static bool CharsAreLatin1LetterOrDigitOrUnderscore(this string s, int st
181181
return true;
182182
}
183183

184-
public static int IndexOfOrdinal(this string s, string value, int startIndex = 0, bool ignoreCase = false)
184+
public static int IndexOfOrdinal(this string s, string value, int startIndex = 0, bool ignoreCase = false)
185185
=> s?.IndexOf(value, startIndex, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) ?? -1;
186186

187187
public static bool EqualsIgnoreCase(this string s, string other)
@@ -266,5 +266,18 @@ public static bool TryGetNextNonEmptySpan(this string s, char separator, int sub
266266
span = (start, nextSeparatorIndex == -1 || nextSeparatorIndex >= substringLength ? substringLength - start : nextSeparatorIndex - start);
267267
return true;
268268
}
269+
270+
public static string[] SplitLines(this string s, params string[] lineEndings) {
271+
if (lineEndings == null || lineEndings.Length == 0) {
272+
lineEndings = new[] { "\r\n", "\r", "\n" };
273+
}
274+
275+
return s.Split(lineEndings, StringSplitOptions.None);
276+
}
277+
278+
public static string NormalizeLineEndings(this string s, string lineEnding = null) {
279+
lineEnding = lineEnding ?? Environment.NewLine;
280+
return string.Join(lineEnding, s.SplitLines());
281+
}
269282
}
270283
}

0 commit comments

Comments
 (0)