From bbacb4c5ec39b504cbaa665322664ac36aa519d2 Mon Sep 17 00:00:00 2001 From: Matt Hillsdon Date: Fri, 15 Oct 2021 12:23:48 +0100 Subject: [PATCH] Markdown parameter docs for signature help. --- .../pyright-internal/src/languageServerBase.ts | 14 ++++++-------- .../src/languageService/signatureHelpProvider.ts | 11 +++++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/pyright-internal/src/languageServerBase.ts b/packages/pyright-internal/src/languageServerBase.ts index c50aaf5dc4df..17f1cf756916 100644 --- a/packages/pyright-internal/src/languageServerBase.ts +++ b/packages/pyright-internal/src/languageServerBase.ts @@ -576,14 +576,12 @@ export abstract class LanguageServerBase implements LanguageServerInterface { const signatures = signatureHelpResults.signatures.map((sig) => { let paramInfo: ParameterInformation[] = []; if (sig.parameters) { - paramInfo = sig.parameters.map((param) => - ParameterInformation.create( - this.client.hasSignatureLabelOffsetCapability - ? [param.startOffset, param.endOffset] - : param.text, - param.documentation - ) - ); + paramInfo = sig.parameters.map((param) => ({ + label: this.client.hasSignatureLabelOffsetCapability + ? [param.startOffset, param.endOffset] + : param.text, + documentation: param.documentation, + })); } const sigInfo = SignatureInformation.create(sig.label, undefined, ...paramInfo); diff --git a/packages/pyright-internal/src/languageService/signatureHelpProvider.ts b/packages/pyright-internal/src/languageService/signatureHelpProvider.ts index d7abaf8107ae..31e2589d0c49 100644 --- a/packages/pyright-internal/src/languageService/signatureHelpProvider.ts +++ b/packages/pyright-internal/src/languageService/signatureHelpProvider.ts @@ -30,7 +30,7 @@ export interface ParamInfo { startOffset: number; endOffset: number; text: string; - documentation?: string | undefined; + documentation?: string | undefined | MarkupContent; } export interface SignatureInfo { @@ -149,11 +149,18 @@ export class SignatureHelpProvider { ); } + // micro:bit change, convert the parameter docs too + const rawDocumentation = extractParameterDocumentation(functionDocString || '', paramName); + const documentation = rawDocumentation + ? format === MarkupKind.Markdown + ? { kind: MarkupKind.Markdown, value: convertDocStringToMarkdown(rawDocumentation) } + : { kind: MarkupKind.PlainText, value: convertDocStringToPlainText(rawDocumentation) } + : undefined; parameters.push({ startOffset: label.length, endOffset: label.length + paramString.length, text: paramString, - documentation: extractParameterDocumentation(functionDocString || '', paramName), + documentation, }); label += paramString;