mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 01:29:04 +01:00
Test extension for notebook
This commit is contained in:
20
extensions/notebook-test/.vscode/launch.json
vendored
Normal file
20
extensions/notebook-test/.vscode/launch.json
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Run Extension",
|
||||
"type": "extensionHost",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "${execPath}",
|
||||
"args": [
|
||||
"--extensionDevelopmentPath=${workspaceFolder}"
|
||||
],
|
||||
"outFiles": [
|
||||
"${workspaceFolder}/out/**/*.js"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
1
extensions/notebook-test/README.md
Normal file
1
extensions/notebook-test/README.md
Normal file
@@ -0,0 +1 @@
|
||||
# Notebook test
|
||||
20
extensions/notebook-test/extension.webpack.config.js
Normal file
20
extensions/notebook-test/extension.webpack.config.js
Normal file
@@ -0,0 +1,20 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
//@ts-check
|
||||
|
||||
'use strict';
|
||||
|
||||
const withDefaults = require('../shared.webpack.config');
|
||||
|
||||
module.exports = withDefaults({
|
||||
context: __dirname,
|
||||
resolve: {
|
||||
mainFields: ['module', 'main']
|
||||
},
|
||||
entry: {
|
||||
extension: './src/extension.ts',
|
||||
}
|
||||
});
|
||||
BIN
extensions/notebook-test/icon.png
Normal file
BIN
extensions/notebook-test/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
18
extensions/notebook-test/icon.svg
Normal file
18
extensions/notebook-test/icon.svg
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 23.0.6, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill-rule:evenodd;clip-rule:evenodd;fill:#C5C5C5;}
|
||||
</style>
|
||||
<g>
|
||||
<path class="st0" d="M2,14.1l-1.1-1L0.9,3l1-1.1l12.1,0l1.1,1l0,10.1L14,14.1H2z M13.9,12.9V3.1H2.1v9.8H13.9z M8.9,12.1V7.9h4.2
|
||||
v4.2H8.9z M11.9,10.9V9.1h-1.8v1.8H11.9z M2.9,12.1v-1.2h4.2v1.2H2.9z M2.9,9.1V7.9h4.2v1.2H2.9z M2.9,7.1V3.9h10.2v3.2H2.9z
|
||||
M11.9,5.9V5.1H4.1v0.8H11.9z"/>
|
||||
<path d="M14,2l1,1v10l-1,1H2l-1-1V3l1-1H14 M2,13h12V3H2V13 M13,4v3H3V4H13 M4,6h8V5H4V6 M13,8v4H9V8H13 M10,11h2V9h-2V11 M7,8v1H3
|
||||
V8H7 M7,11v1H3v-1H7 M14.1,1.8L14.1,1.8H2H1.9L1.9,1.9l-1,1L0.8,2.9V3v10v0.1l0.1,0.1l1,1l0.1,0.1H2h12h0.1l0.1-0.1l1-1l0.1-0.1V13
|
||||
V3V2.9l-0.1-0.1L14.1,1.8L14.1,1.8L14.1,1.8z M2.2,3.2h11.6v9.6H2.2V3.2L2.2,3.2z M13.2,3.8H13H3H2.8V4v3v0.2H3h10h0.2V7V4V3.8
|
||||
L13.2,3.8z M4.2,5.2h7.6v0.6H4.2V5.2L4.2,5.2z M13.2,7.8H13H9H8.8V8v4v0.2H9h4h0.2V12V8V7.8L13.2,7.8z M10.2,9.2h1.6v1.6h-1.6V9.2
|
||||
L10.2,9.2z M7.2,7.8H7H3H2.8V8v1v0.2H3h4h0.2V9V8V7.8L7.2,7.8z M7.2,10.8H7H3H2.8V11v1v0.2H3h4h0.2V12v-1V10.8L7.2,10.8z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
46
extensions/notebook-test/package.json
Normal file
46
extensions/notebook-test/package.json
Normal file
@@ -0,0 +1,46 @@
|
||||
{
|
||||
"name": "notebook-test",
|
||||
"displayName": "Notebook Test",
|
||||
"description": "Notebook test for execution and outputs",
|
||||
"extensionKind": [
|
||||
"ui",
|
||||
"workspace"
|
||||
],
|
||||
"version": "1.0.0",
|
||||
"publisher": "vscode",
|
||||
"icon": "icon.png",
|
||||
"enableProposedApi": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"vscode": "^1.40.0"
|
||||
},
|
||||
"main": "./out/extension",
|
||||
"categories": [
|
||||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"*"
|
||||
],
|
||||
"contributes": {
|
||||
"notebookProvider": [
|
||||
{
|
||||
"viewType": "jupyter",
|
||||
"displayName": "Jupyter",
|
||||
"selector": [
|
||||
{
|
||||
"filenamePattern": "*.test.ipynb"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"compile": "tsc -p ./",
|
||||
"watch": "tsc -watch -p ./"
|
||||
},
|
||||
"dependencies": {
|
||||
"vscode-extension-telemetry": "0.1.1",
|
||||
"vscode-nls": "^4.0.0",
|
||||
"typescript": "^3.6.4"
|
||||
}
|
||||
}
|
||||
14
extensions/notebook-test/src/extension.ts
Normal file
14
extensions/notebook-test/src/extension.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { NotebookProvider } from './notebookProvider';
|
||||
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
console.log(context.extensionPath);
|
||||
|
||||
context.subscriptions.push(vscode.window.registerNotebookProvider('jupyter', new NotebookProvider()));
|
||||
}
|
||||
|
||||
156
extensions/notebook-test/src/notebookProvider.ts
Normal file
156
extensions/notebook-test/src/notebookProvider.ts
Normal file
@@ -0,0 +1,156 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export class Cell implements vscode.ICell {
|
||||
public outputs: any[] = [];
|
||||
|
||||
constructor(
|
||||
public source: string[],
|
||||
public cell_type: 'markdown' | 'code',
|
||||
private _outputs: any[]
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
fillInOutputs() {
|
||||
this.outputs = this._outputs;
|
||||
}
|
||||
}
|
||||
|
||||
export class JupyterNotebook implements vscode.INotebook {
|
||||
constructor(
|
||||
public metadata: vscode.IMetadata,
|
||||
public cells: Cell[]
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export class NotebookProvider implements vscode.NotebookProvider {
|
||||
private _onDidChangeNotebook = new vscode.EventEmitter<{ resource: vscode.Uri; notebook: vscode.INotebook; }>();
|
||||
onDidChangeNotebook: vscode.Event<{ resource: vscode.Uri; notebook: vscode.INotebook; }> = this._onDidChangeNotebook.event;
|
||||
private _notebook: JupyterNotebook;
|
||||
private _notebooks: Map<vscode.Uri, JupyterNotebook> = new Map();
|
||||
|
||||
constructor() {
|
||||
this._notebook = new JupyterNotebook(
|
||||
{
|
||||
language_info: {
|
||||
file_extension: 'ipynb'
|
||||
}
|
||||
},
|
||||
[
|
||||
new Cell([
|
||||
'# header\n',
|
||||
'body\n'
|
||||
],
|
||||
'markdown',
|
||||
[]
|
||||
),
|
||||
new Cell([
|
||||
'print(a)',
|
||||
],
|
||||
'code',
|
||||
[
|
||||
{
|
||||
'output_type': 'stream',
|
||||
'name': 'stdout',
|
||||
'text': 'hi, stdout\n'
|
||||
}
|
||||
]
|
||||
),
|
||||
new Cell(
|
||||
[
|
||||
'import time, sys\n',
|
||||
'for i in range(8):\n',
|
||||
' print(i)\n',
|
||||
' time.sleep(0.5)'
|
||||
],
|
||||
'code',
|
||||
[
|
||||
{
|
||||
'name': 'stdout',
|
||||
'text': '0\n',
|
||||
'output_type': 'stream'
|
||||
},
|
||||
{
|
||||
'name': 'stdout',
|
||||
'text': '1\n',
|
||||
'output_type': 'stream'
|
||||
},
|
||||
{
|
||||
'name': 'stdout',
|
||||
'text': '2\n',
|
||||
'output_type': 'stream'
|
||||
},
|
||||
{
|
||||
'name': 'stdout',
|
||||
'text': '3\n',
|
||||
'output_type': 'stream'
|
||||
},
|
||||
{
|
||||
'name': 'stdout',
|
||||
'text': '4\n',
|
||||
'output_type': 'stream'
|
||||
},
|
||||
{
|
||||
'name': 'stdout',
|
||||
'text': '5\n',
|
||||
'output_type': 'stream'
|
||||
},
|
||||
{
|
||||
'name': 'stdout',
|
||||
'text': '6\n',
|
||||
'output_type': 'stream'
|
||||
},
|
||||
{
|
||||
'name': 'stdout',
|
||||
'text': '7\n',
|
||||
'output_type': 'stream'
|
||||
}
|
||||
]
|
||||
),
|
||||
new Cell(
|
||||
[
|
||||
'print(a + 4)'
|
||||
],
|
||||
'code',
|
||||
[
|
||||
{
|
||||
'output_type': 'error',
|
||||
'ename': 'NameError',
|
||||
'evalue': 'name \'a\' is not defined',
|
||||
'traceback': [
|
||||
'\u001b[0;31m---------------------------------------------------------------------------\u001b[0m',
|
||||
'\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)',
|
||||
'\u001b[0;32m<ipython-input-1-f270cadddfe4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ma\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m',
|
||||
'\u001b[0;31mNameError\u001b[0m: name \'a\' is not defined'
|
||||
]
|
||||
}
|
||||
]
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
async resolveNotebook(resource: vscode.Uri): Promise<vscode.INotebook | undefined> {
|
||||
if (this._notebooks.has(resource)) {
|
||||
return this._notebooks.get(resource);
|
||||
}
|
||||
|
||||
this._notebooks.set(resource, this._notebook);
|
||||
|
||||
return Promise.resolve(this._notebook);
|
||||
}
|
||||
|
||||
async executeNotebook(resource: vscode.Uri): Promise<void> {
|
||||
this._notebook.cells.forEach(cell => cell.fillInOutputs());
|
||||
|
||||
this._onDidChangeNotebook.fire({ resource, notebook: this._notebook });
|
||||
return;
|
||||
}
|
||||
}
|
||||
8
extensions/notebook-test/src/typings/ref.d.ts
vendored
Normal file
8
extensions/notebook-test/src/typings/ref.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
/// <reference path='../../../../src/vs/vscode.d.ts'/>
|
||||
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>
|
||||
/// <reference types='@types/node'/>
|
||||
10
extensions/notebook-test/tsconfig.json
Normal file
10
extensions/notebook-test/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "../shared.tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out",
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
||||
46
extensions/notebook-test/yarn.lock
Normal file
46
extensions/notebook-test/yarn.lock
Normal file
@@ -0,0 +1,46 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
applicationinsights@1.0.8:
|
||||
version "1.0.8"
|
||||
resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-1.0.8.tgz#db6e3d983cf9f9405fe1ee5ba30ac6e1914537b5"
|
||||
integrity sha512-KzOOGdphOS/lXWMFZe5440LUdFbrLpMvh2SaRxn7BmiI550KAoSb2gIhiq6kJZ9Ir3AxRRztjhzif+e5P5IXIg==
|
||||
dependencies:
|
||||
diagnostic-channel "0.2.0"
|
||||
diagnostic-channel-publishers "0.2.1"
|
||||
zone.js "0.7.6"
|
||||
|
||||
diagnostic-channel-publishers@0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.2.1.tgz#8e2d607a8b6d79fe880b548bc58cc6beb288c4f3"
|
||||
integrity sha1-ji1geottef6IC1SLxYzGvrKIxPM=
|
||||
|
||||
diagnostic-channel@0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/diagnostic-channel/-/diagnostic-channel-0.2.0.tgz#cc99af9612c23fb1fff13612c72f2cbfaa8d5a17"
|
||||
integrity sha1-zJmvlhLCP7H/8TYSxy8sv6qNWhc=
|
||||
dependencies:
|
||||
semver "^5.3.0"
|
||||
|
||||
semver@^5.3.0:
|
||||
version "5.5.0"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
|
||||
integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==
|
||||
|
||||
vscode-extension-telemetry@0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/vscode-extension-telemetry/-/vscode-extension-telemetry-0.1.1.tgz#91387e06b33400c57abd48979b0e790415ae110b"
|
||||
integrity sha512-TkKKG/B/J94DP5qf6xWB4YaqlhWDg6zbbqVx7Bz//stLQNnfE9XS1xm3f6fl24c5+bnEK0/wHgMgZYKIKxPeUA==
|
||||
dependencies:
|
||||
applicationinsights "1.0.8"
|
||||
|
||||
vscode-nls@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
|
||||
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
|
||||
|
||||
zone.js@0.7.6:
|
||||
version "0.7.6"
|
||||
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.7.6.tgz#fbbc39d3e0261d0986f1ba06306eb3aeb0d22009"
|
||||
integrity sha1-+7w50+AmHQmG8boGMG6zrrDSIAk=
|
||||
Reference in New Issue
Block a user