From 08dc4e0b3dee59f3ca2639bc120bc9fa505ef559 Mon Sep 17 00:00:00 2001 From: Eric Fritz Date: Wed, 3 Feb 2021 14:36:29 -0600 Subject: [PATCH 1/2] Ignore empty lines between docstring and definition. --- shared/search/docstrings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/search/docstrings.ts b/shared/search/docstrings.ts index 7d3f1a827..efd6e4e3a 100644 --- a/shared/search/docstrings.ts +++ b/shared/search/docstrings.ts @@ -179,7 +179,7 @@ function findDocstringInBlockComment({ docstringIgnore?: RegExp }): string[] | undefined { // Drop any leading ignored content between the definition and the docstring - const cleanLines = dropWhile(lines, line => docstringIgnore?.test(line)) + const cleanLines = dropWhile(lines, line => docstringIgnore?.test(line) || line.trim() === '') // Check for starting delimiter if (!cleanLines[0] || !startRegex.test(cleanLines[0])) { From dad0d8a391cadadc24803e55125b7ebc947ab60b Mon Sep 17 00:00:00 2001 From: Eric Fritz Date: Wed, 3 Feb 2021 14:36:45 -0600 Subject: [PATCH 2/2] Add docstring ignore to c-family comment styles. --- shared/language-specs/cpp.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/shared/language-specs/cpp.ts b/shared/language-specs/cpp.ts index d17ebc532..4b617dc59 100644 --- a/shared/language-specs/cpp.ts +++ b/shared/language-specs/cpp.ts @@ -48,7 +48,17 @@ export const cppSpec: LanguageSpec = { 'pc', // Pro-C by Oracle RDBMS 'pcc', // Pro-C by Oracle RDBMS ], - commentStyles: [cStyleComment], + commentStyles: [ + { + ...cStyleComment, + // Ignore identifiers between definition line and doc block. This enables + // correctly finding doc strings for function definitions that span multiple + // lines (return type and function name separated by a newline). We'll only + // enable this for C-family languages as it seems to be the most pervasive + // language with this style. + ...{ docstringIgnore: /^[\s\w]+/ }, + }, + ], filterDefinitions, lsifSupport: LSIFSupport.Experimental, }