@@ -42,32 +42,44 @@ export class Signature extends CodeMirrorLSPFeature {
42
42
let markdown = '```' + language + '\n' + item . label + '\n```' ;
43
43
if ( item . documentation ) {
44
44
markdown += '\n' ;
45
-
46
- let in_text_block = false ;
47
- // TODO: make use of the MarkupContent object instead
48
- for ( let line of item . documentation . toString ( ) . split ( '\n' ) ) {
49
- if ( line . trim ( ) === item . label . trim ( ) ) {
50
- continue ;
51
- }
52
-
53
- if ( line . startsWith ( '>>>' ) ) {
54
- if ( in_text_block ) {
55
- markdown += '```\n\n' ;
56
- in_text_block = false ;
45
+ if (
46
+ typeof item . documentation === 'string' ||
47
+ item . documentation . kind === 'plaintext'
48
+ ) {
49
+ let in_text_block = false ;
50
+ // TODO: make use of the MarkupContent object instead
51
+ for ( let line of item . documentation . toString ( ) . split ( '\n' ) ) {
52
+ if ( line . trim ( ) === item . label . trim ( ) ) {
53
+ continue ;
57
54
}
58
- line = '```' + language + '\n' + line . substr ( 3 ) + '\n```' ;
59
- } else {
60
- // start new text block
61
- if ( ! in_text_block ) {
62
- markdown += '```\n' ;
63
- in_text_block = true ;
55
+
56
+ if ( line . startsWith ( '>>>' ) ) {
57
+ if ( in_text_block ) {
58
+ markdown += '```\n\n' ;
59
+ in_text_block = false ;
60
+ }
61
+ line = '```' + language + '\n' + line . substr ( 3 ) + '\n```' ;
62
+ } else {
63
+ // start new text block
64
+ if ( ! in_text_block ) {
65
+ markdown += '```\n' ;
66
+ in_text_block = true ;
67
+ }
64
68
}
69
+ markdown += line + '\n' ;
65
70
}
66
- markdown += line + '\n' ;
67
- }
68
- // close off the text block - if any
69
- if ( in_text_block ) {
70
- markdown += '```' ;
71
+ // close off the text block - if any
72
+ if ( in_text_block ) {
73
+ markdown += '```' ;
74
+ }
75
+ } else {
76
+ if ( item . documentation . kind !== 'markdown' ) {
77
+ this . virtual_editor . console . warn (
78
+ 'Unknown MarkupContent kind:' ,
79
+ item . documentation . kind
80
+ ) ;
81
+ }
82
+ markdown += item . documentation . value ;
71
83
}
72
84
}
73
85
return markdown ;
0 commit comments