Skip to content

Commit a4396c7

Browse files
thegoomanjtpio
authored andcommitted
Updated embedded code snippets in readme
1 parent 9036fb6 commit a4396c7

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

advanced/kernel-output/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ object ([see the documentation](https://jupyterlab.github.io/jupyterlab/apputils
4141
Here it is stored in the private `_sessionContext` variable:
4242

4343
```ts
44-
// src/panel.ts#L86-L86
44+
// src/panel.ts#L94-L94
4545

4646
private _sessionContext: SessionContext;
4747
```
@@ -50,20 +50,20 @@ A `SessionContext` handles a single kernel session. The session itself (not yet
5050
the kernel) is started with these lines:
5151

5252
```ts
53-
// src/panel.ts#L36-L40
53+
// src/panel.ts#L44-L48
5454

5555
this._sessionContext = new SessionContext({
5656
sessionManager: manager.sessions,
5757
specsManager: manager.kernelspecs,
58-
name: 'Kernel Output'
58+
name: 'Kernel Output',
5959
});
6060
```
6161

6262
The private session variable is exposed as read-only for other users
6363
through a getter method:
6464

6565
```ts
66-
// src/panel.ts#L64-L66
66+
// src/panel.ts#L72-L74
6767

6868
get session(): ISessionContext {
6969
return this._sessionContext;
@@ -75,7 +75,7 @@ with this line:
7575

7676
<!-- prettier-ignore-start -->
7777
```ts
78-
// src/panel.ts#L50-L61
78+
// src/panel.ts#L58-L69
7979

8080
void this._sessionContext
8181
.initialize()
@@ -99,7 +99,7 @@ The following two methods ensure the clean disposal of the session
9999
when you close the panel.
100100

101101
```ts
102-
// src/panel.ts#L68-L71
102+
// src/panel.ts#L76-L79
103103

104104
dispose(): void {
105105
this._sessionContext.dispose();
@@ -108,7 +108,7 @@ dispose(): void {
108108
```
109109

110110
```ts
111-
// src/panel.ts#L81-L84
111+
// src/panel.ts#L89-L92
112112

113113
protected onCloseRequest(msg: Message): void {
114114
super.onCloseRequest(msg);
@@ -124,12 +124,12 @@ You can instantiate it with a new `OutputAreaModel`; this is class containing
124124
the data to show:
125125

126126
```ts
127-
// src/panel.ts#L42-L46
127+
// src/panel.ts#L50-L54
128128

129129
this._outputareamodel = new OutputAreaModel();
130130
this._outputarea = new SimplifiedOutputArea({
131131
model: this._outputareamodel,
132-
rendermime: rendermime
132+
rendermime: rendermime,
133133
});
134134
```
135135

@@ -138,7 +138,7 @@ some code to a kernel through a `ISessionContext` ([see documentation](https://j
138138
in the specific `SimplifiedOutputArea` object you created:
139139

140140
```ts
141-
// src/panel.ts#L73-L79
141+
// src/panel.ts#L81-L87
142142

143143
execute(code: string): void {
144144
SimplifiedOutputArea.execute(code, this._outputarea, this._sessionContext)
@@ -158,7 +158,7 @@ To display the `SimplifiedOutputArea` Widget you need to add it to your
158158
panel with:
159159

160160
```ts
161-
// src/panel.ts#L48-L48
161+
// src/panel.ts#L56-L56
162162

163163
this.addWidget(this._outputarea);
164164
```
@@ -172,7 +172,7 @@ The last step is to add the panel to the JupyterLab main area.
172172
First, it is a good practice to unify the extension commands into one namespace at the top of the file:
173173

174174
```ts
175-
// src/index.ts#L21-L25
175+
// src/index.ts#L23-L27
176176

177177
namespace CommandIDs {
178178
export const create = 'kernel-output:create';
@@ -185,10 +185,10 @@ You can then add the commands to the palette and the menu by iterating
185185
on a list:
186186

187187
```ts
188-
// src/index.ts#L105-L109
188+
// src/index.ts#L110-L114
189189

190190
// add items in command palette and menu
191-
[CommandIDs.create, CommandIDs.execute].forEach(command => {
191+
[CommandIDs.create, CommandIDs.execute].forEach((command) => {
192192
palette.addItem({ command, category });
193193
exampleMenu.addItem({ command });
194194
});
@@ -198,7 +198,7 @@ To create a new client session, the service manager must be obtained from
198198
the JupyterLab application:
199199

200200
```ts
201-
// src/index.ts#L54-L54
201+
// src/index.ts#L58-L58
202202

203203
const manager = app.serviceManager;
204204
```
@@ -208,7 +208,7 @@ ready. Then once the panel is created and its session is ready, it
208208
can be added to the JupyterLab main area:
209209

210210
```ts
211-
// src/index.ts#L58-L69
211+
// src/index.ts#L63-L74
212212

213213
let panel: ExamplePanel;
214214

@@ -218,7 +218,7 @@ let panel: ExamplePanel;
218218
* @returns The panel
219219
*/
220220
async function createPanel(): Promise<ExamplePanel> {
221-
panel = new ExamplePanel(manager, rendermime);
221+
panel = new ExamplePanel(manager, rendermime, translator);
222222
shell.add(panel, 'main');
223223
return panel;
224224
}
@@ -231,28 +231,28 @@ to be executed by the kernel. Then you will send it to your panel for execution
231231
and display:
232232

233233
```ts
234-
// src/index.ts#L83-L103
234+
// src/index.ts#L88-L108
235235

236236
commands.addCommand(CommandIDs.execute, {
237-
label: 'Contact Kernel and Execute Code',
238-
caption: 'Contact Kernel and Execute Code',
237+
label: trans.__('Contact Kernel and Execute Code'),
238+
caption: trans.__('Contact Kernel and Execute Code'),
239239
execute: async () => {
240240
// Create the panel if it does not exist
241241
if (!panel) {
242242
await createPanel();
243243
}
244244
// Prompt the user about the statement to be executed
245245
const input = await InputDialog.getText({
246-
title: 'Code to execute',
247-
okLabel: 'Execute',
248-
placeholder: 'Statement to execute'
246+
title: trans.__('Code to execute'),
247+
okLabel: trans.__('Execute'),
248+
placeholder: trans.__('Statement to execute'),
249249
});
250250
// Execute the statement
251251
if (input.button.accept) {
252252
const code = input.value;
253253
panel.execute(code);
254254
}
255-
}
255+
},
256256
});
257257
```
258258

advanced/kernel-output/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@
4242
"watch:src": "tsc -w"
4343
},
4444
"dependencies": {
45-
"@jupyterlab/application": "~3.0.0-beta.4",
46-
"@jupyterlab/launcher": "~3.0.0-beta.4",
47-
"@jupyterlab/mainmenu": "~3.0.0-beta.4",
48-
"@jupyterlab/outputarea": "~3.0.0-beta.4",
49-
"@jupyterlab/translation": "^3.0.0-beta.4",
45+
"@jupyterlab/application": "~3.0.0-beta.8",
46+
"@jupyterlab/launcher": "~3.0.0-beta.8",
47+
"@jupyterlab/mainmenu": "~3.0.0-beta.8",
48+
"@jupyterlab/outputarea": "~3.0.0-beta.8",
49+
"@jupyterlab/translation": "^3.0.0-beta.8",
5050
"@lumino/algorithm": "^1.3.3",
5151
"@lumino/coreutils": "^1.5.3",
5252
"@lumino/datagrid": "^0.3.1",

0 commit comments

Comments
 (0)