@@ -4,20 +4,35 @@ This example shows how to clear all cell outputs at once by clicking on the butt
4
4
5
5
![ Github Actions Status] ( https://github.com/yash112-lang/extension-examples/blob/master/clear_cell_outputs/Preview.gif )
6
6
7
- <!-- A JupyterLab extension for clearing all cells output at once. -->
8
-
9
7
To use it first we need to import the packages
10
- ```
11
- import { ToolbarButton } from '@jupyterlab/apputils';
12
- import { DocumentRegistry } from '@jupyterlab/docregistry';
13
- import { NotebookActions, NotebookPanel, INotebookModel } from '@jupyterlab/notebook';
14
- import { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
15
- import { IDisposable, DisposableDelegate } from '@lumino/disposable';
8
+ ``` ts
9
+ // src/index.ts#L1-L19
10
+
11
+ import {
12
+ IDisposable , DisposableDelegate
13
+ } from ' @lumino/disposable' ;
14
+
15
+ import {
16
+ JupyterFrontEnd , JupyterFrontEndPlugin
17
+ } from ' @jupyterlab/application' ;
18
+
19
+ import {
20
+ ToolbarButton
21
+ } from ' @jupyterlab/apputils' ;
22
+
23
+ import {
24
+ DocumentRegistry
25
+ } from ' @jupyterlab/docregistry' ;
26
+
27
+ import {
28
+ NotebookActions , NotebookPanel , INotebookModel
29
+ } from ' @jupyterlab/notebook' ;
16
30
```
17
31
18
32
Firstly we have to register the plugin information. In this we have to pass a activate ** function** & the plugin ** id** .
19
33
20
- ```
34
+ ``` ts
35
+ // src/index.ts#L25-L29
21
36
const plugin: JupyterFrontEndPlugin <void > = {
22
37
activate ,
23
38
id: ' clear-cell-outputs:buttonPlugin' ,
@@ -26,7 +41,8 @@ const plugin: JupyterFrontEndPlugin<void> = {
26
41
```
27
42
Now creating a notebook widget extension that adds a button to the toolbar. For more info [ IWidgetExtension] ( https://jupyterlab.readthedocs.io/en/latest/api/interfaces/docregistry.documentregistry.iwidgetextension.html )
28
43
29
- ```
44
+ ``` ts
45
+ // src/index.ts#L35-L56
30
46
export
31
47
class ButtonExtension implements DocumentRegistry .IWidgetExtension <NotebookPanel , INotebookModel > {
32
48
@@ -51,29 +67,9 @@ export
51
67
}
52
68
```
53
69
Now activating the extension
54
- ```
70
+ ``` ts
71
+ // src/index.ts#L61-L63
55
72
function activate(app : JupyterFrontEnd ) {
56
73
app .docRegistry .addWidgetExtension (' Notebook' , new ButtonExtension ());
57
74
};
58
75
```
59
-
60
- ## Requirements
61
-
62
- * JupyterLab >= 3.0
63
-
64
- ## Install
65
-
66
- To install the extension, execute:
67
-
68
- ``` bash
69
- pip install clear_cell_outputs
70
- ```
71
-
72
- ## Uninstall
73
-
74
- To remove the extension, execute:
75
-
76
- ``` bash
77
- pip uninstall clear_cell_outputs
78
- ```
79
-
0 commit comments