1+ 'use strict' ;
2+
3+ import * as vscode from 'vscode' ;
4+ import { Disposable } from 'vscode' ;
5+ import * as fs from 'fs' ;
6+ import * as path from 'path' ;
7+ import * as constants from './common/constants' ;
8+
9+ export class TextDocumentContentProvider extends Disposable implements vscode . TextDocumentContentProvider {
10+ private _onDidChange = new vscode . EventEmitter < vscode . Uri > ( ) ;
11+ private lastUri : vscode . Uri ;
12+ constructor ( ) {
13+ super ( ( ) => { } ) ;
14+ }
15+ public provideTextDocumentContent ( uri : vscode . Uri , token : vscode . CancellationToken ) : Thenable < string > {
16+ this . lastUri = uri ;
17+ return this . generateResultsView ( ) ;
18+ }
19+
20+ get onDidChange ( ) : vscode . Event < vscode . Uri > {
21+ return this . _onDidChange . event ;
22+ }
23+
24+ public update ( ) {
25+ this . _onDidChange . fire ( this . lastUri ) ;
26+ }
27+
28+ private generateResultsView ( ) : Promise < string > {
29+ const htmlContent = `
30+ <!DOCTYPE html>
31+ <head><style type="text/css"> html, body{ height:100%; width:100%; } </style>
32+ <script type="text/javascript">
33+ </script>
34+ </head>
35+ <body>
36+ <iframe id="myframe" frameborder="0" style="border: 0px solid transparent;height:100%;width:100%;"
37+ src="http://0.0.0.0:8000/docs/jupyter_prerequisites/" seamless></iframe></body></html>` ;
38+ return Promise . resolve ( htmlContent ) ;
39+ }
40+ }
41+
42+ export class DocProvider {
43+ constructor ( ) {
44+ const helpSchema = 'help-viewer' ;
45+ const previewUri = vscode . Uri . parse ( helpSchema + '://authority/jupyter' ) ;
46+
47+ const textProvider = new TextDocumentContentProvider ( ) ;
48+ vscode . workspace . registerTextDocumentContentProvider ( helpSchema , textProvider ) ;
49+
50+ vscode . commands . registerCommand ( 'python.displayHelp' , ( page : string ) => {
51+ return vscode . commands . executeCommand ( 'vscode.previewHtml' , previewUri , vscode . ViewColumn . One , 'Help' )
52+ . then ( ( ) => {
53+ // Do nothing
54+ } , reason => {
55+ // vscode.window.showErrorMessage(reason);
56+ } ) ;
57+ } ) ;
58+ }
59+ }
0 commit comments