From 55a5ccc559b34b8d2eb9c7b7a2d9efbae40619c2 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Tue, 23 Feb 2021 12:36:46 -0500 Subject: Documentation markup extraction (#1724) * #include an absolute path didn't work - because paths were taken to always be relative. * WIP extracting source documentation. * WIP doc extraction. * More stuff around doc markup extraction. * More WIP around doc extraction. * Fix some indexing issues. * Initial doc extraction working. * Renaming of types in markup extraction process. * Extracting markup content. Removing indenting. Other fixes and improvements around document tools. * WIP support for documentation system. * Remove some commented out sections. * Remove some comments that no longer apply. * Improvements around SourceFile - such that more granularity around line ops. Made some functionality explicitly work without source. Improved Doc types nameing. --- source/core/slang-string-util.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/core/slang-string-util.cpp') diff --git a/source/core/slang-string-util.cpp b/source/core/slang-string-util.cpp index cac7c7cfa..6ce75f3f0 100644 --- a/source/core/slang-string-util.cpp +++ b/source/core/slang-string-util.cpp @@ -360,6 +360,28 @@ ComPtr StringUtil::createStringBlob(const String& string) } } +/* static */UnownedStringSlice StringUtil::trimEndOfLine(const UnownedStringSlice& line) +{ + // Strip CR/LF from end of line if present + + const char* begin = line.begin(); + const char* end = line.end(); + + if (end > begin) + { + const char c = end[-1]; + // If last char is CR/LF move back a char + if (c == '\n' || c == '\r') + { + --end; + // If next char is a match for the CR/LF pair move back an extra char. + end -= Index((end > begin) && (c ^ end[-1]) == ('\r' ^ '\n')); + } + } + + return line.head(Index(end - begin)); +} + /* static */bool StringUtil::areLinesEqual(const UnownedStringSlice& inA, const UnownedStringSlice& inB) { UnownedStringSlice a(inA), b(inB), lineA, lineB; -- cgit v1.2.3