| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0d419f0 commit 60d556d
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | import * as vscode from 'vscode'; | |
| 4 | 4 | import * as proxy from './jediProxy'; | |
| 5 | 5 | import * as telemetryContracts from "../common/telemetryContracts"; | |
| 6 | + import { highlightCode } from './jediHelpers'; | ||
| 6 | 7 | ||
| 7 | 8 | export class PythonHoverProvider implements vscode.HoverProvider { | |
| 8 | 9 | private jediProxyHandler: proxy.JediProxyHandler<proxy.IHoverResult>; | |
@@ -26,9 +27,10 @@ export class PythonHoverProvider implements vscode.HoverProvider { | |||
| 26 | 27 | break; | |
| 27 | 28 | } | |
| 28 | 29 | } | |
| 29 | - results.push({language: 'python', value: signature}); | ||
| 30 | + results.push({ language: 'python', value: signature }); | ||
| 30 | 31 | if (item.description) { | |
| 31 | - results.push(description); | ||
| 32 | + var descriptionWithHighlightedCode = highlightCode(item.description); | ||
| 33 | + results.push(descriptionWithHighlightedCode); | ||
| 32 | 34 | } | |
| 33 | 35 | }); | |
| 34 | 36 | return new vscode.Hover(results); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -47,3 +47,15 @@ export function extractSignatureAndDocumentation(definition: proxy.IAutoComplete | |||
| 47 | 47 | } | |
| 48 | 48 | return [signature, lines.join(EOL).trim().replace(/^\s+|\s+$/g, '').trim()]; | |
| 49 | 49 | } | |
| 50 | + | ||
| 51 | + export function highlightCode(documentation: string): string { | ||
| 52 | + let lines = documentation.split(EOL); | ||
| 53 | + lines = lines.map(line => { | ||
| 54 | + if (line.trim().startsWith('>>> ')) { | ||
| 55 | + return '```python\n' + line.substring(4).trim() + '\n```'; | ||
| 56 | + } | ||
| 57 | + return line; | ||
| 58 | + }); | ||
| 59 | + | ||
| 60 | + return lines.join(EOL).trim().replace(/^\s+|\s+$/g, '').trim(); | ||
| 61 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments