diff --git a/src/features/documentation.ts b/src/features/documentation.ts index b20489d7ca..fd85261c1e 100644 --- a/src/features/documentation.ts +++ b/src/features/documentation.ts @@ -36,42 +36,45 @@ export function GetDocumentationString(structDoc: protocol.DocumentationComment) let indentSpaces = "\t\t"; let documentation = ""; - if (structDoc.SummaryText) { - documentation += structDoc.SummaryText + newLine; + if (structDoc) { + if (structDoc.SummaryText) { + documentation += structDoc.SummaryText + newLine; + } + + if (structDoc.TypeParamElements && structDoc.TypeParamElements.length > 0) { + documentation += "Type Parameters:" + newLine; + documentation += indentSpaces + structDoc.TypeParamElements.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine; + } + + if (structDoc.ParamElements && structDoc.ParamElements.length > 0) { + documentation += "Parameters:" + newLine; + documentation += indentSpaces + structDoc.ParamElements.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine; + } + + if (structDoc.ReturnsText) { + documentation += structDoc.ReturnsText + newLine; + } + + if (structDoc.RemarksText) { + documentation += structDoc.RemarksText + newLine; + } + + if (structDoc.ExampleText) { + documentation += structDoc.ExampleText + newLine; + } + + if (structDoc.ValueText) { + documentation += structDoc.ValueText + newLine; + } + + if (structDoc.Exception && structDoc.Exception.length > 0) { + documentation += "Exceptions:" + newLine; + documentation += indentSpaces + structDoc.Exception.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine; + } + + documentation = documentation.trim(); } - - if (structDoc.TypeParamElements && structDoc.TypeParamElements.length > 0) { - documentation += "Type Parameters:" + newLine; - documentation += indentSpaces + structDoc.TypeParamElements.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine; - } - - if (structDoc.ParamElements && structDoc.ParamElements.length > 0) { - documentation += "Parameters:" + newLine; - documentation += indentSpaces + structDoc.ParamElements.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine; - } - - if (structDoc.ReturnsText) { - documentation += structDoc.ReturnsText + newLine; - } - - if (structDoc.RemarksText) { - documentation += structDoc.RemarksText + newLine; - } - - if (structDoc.ExampleText) { - documentation += structDoc.ExampleText + newLine; - } - - if (structDoc.ValueText) { - documentation += structDoc.ValueText + newLine; - } - - if (structDoc.Exception && structDoc.Exception.length > 0) { - documentation += "Exceptions:" + newLine; - documentation += indentSpaces + structDoc.Exception.map(displayDocumentationObject).join("\n" + indentSpaces) + newLine; - } - - documentation = documentation.trim(); + return documentation; }