Skip to content

Commit ab9a330

Browse files
committed
remove signature from the docstring
1 parent adaeb15 commit ab9a330

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/client/providers/hoverProvider.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export class PythonHoverProvider implements vscode.HoverProvider {
1717
let capturedInfo: string[] = [];
1818
data.items.forEach(item => {
1919
let { description, signature } = item;
20+
const rawSignature = signature;
2021
switch (item.kind) {
2122
case vscode.SymbolKind.Constructor:
2223
case vscode.SymbolKind.Function:
@@ -34,8 +35,13 @@ export class PythonHoverProvider implements vscode.HoverProvider {
3435
}
3536
if (item.docstring) {
3637
let lines = item.docstring.split(EOL);
37-
if (lines.length > 0 && lines[0] === item.signature) {
38+
// If the docstring starts with the signature, then remove those lines from the docstring
39+
if (lines.length > 0 && item.signature.indexOf(lines[0]) === 0) {
3840
lines.shift();
41+
let endIndex = lines.findIndex(line => item.signature.endsWith(line));
42+
if (endIndex >= 0) {
43+
lines = lines.filter((line, index) => index > endIndex);
44+
}
3945
}
4046
if (lines.length > 0 && item.signature.startsWith(currentWord) && lines[0].startsWith(currentWord) && lines[0].endsWith(')')) {
4147
lines.shift();

0 commit comments

Comments
 (0)