Skip to content

Commit

Permalink
Flatten the examples folder structure
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Feb 18, 2021
1 parent 9d0a3c1 commit 3d221fe
Show file tree
Hide file tree
Showing 195 changed files with 93 additions and 82 deletions.
47 changes: 24 additions & 23 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,22 @@ jobs:
fail-fast: false
matrix:
example:
- advanced/kernel-messaging
- advanced/kernel-output
- basics/datagrid
- basics/hello-world
- basics/signals
- kernel-messaging
- kernel-output
- datagrid
- hello-world
- signals
- command-palette
- commands
- context-menu
- launcher
- log-console/custom-log-console
- log-console/log-messages
- custom-log-console
- log-messages
- main-menu
- react/react-widget
- react-widget
- settings
- state
- widget-tracker/widgets
- widgets
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout
Expand All @@ -53,10 +53,10 @@ jobs:
- name: Check config files
if: steps.filter.outputs.extension == 'true'
run: |
diff basics/hello-world/tsconfig.json ${EXAMPLE_FOLDER}/tsconfig.json
diff basics/hello-world/.eslintignore ${EXAMPLE_FOLDER}/.eslintignore
diff basics/hello-world/.eslintrc.js ${EXAMPLE_FOLDER}/.eslintrc.js
diff basics/hello-world/.gitignore ${EXAMPLE_FOLDER}/.gitignore
diff hello-world/tsconfig.json ${EXAMPLE_FOLDER}/tsconfig.json
diff hello-world/.eslintignore ${EXAMPLE_FOLDER}/.eslintignore
diff hello-world/.eslintrc.js ${EXAMPLE_FOLDER}/.eslintrc.js
diff hello-world/.gitignore ${EXAMPLE_FOLDER}/.gitignore
env:
EXAMPLE_FOLDER: ${{ matrix.example }}
shell: bash
Expand Down Expand Up @@ -132,15 +132,15 @@ jobs:
with:
filters: |
extension:
- 'advanced/server-extension/**'
- 'server-extension/**'
- name: Cache lerna
if: steps.filter.outputs.extension == 'true'
uses: actions/cache@v2
with:
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-lerna-${{ hashFiles('advanced/server-extension/package.json') }}
key: ${{ runner.os }}-lerna-${{ hashFiles('server-extension/package.json') }}
restore-keys: |
${{ runner.os }}-lerna-
- name: Install node
Expand All @@ -151,9 +151,9 @@ jobs:
- name: Check config files
if: steps.filter.outputs.extension == 'true'
run: |
diff basics/hello-world/tsconfig.json advanced/server-extension/tsconfig.json
diff basics/hello-world/.eslintignore advanced/server-extension/.eslintignore
diff basics/hello-world/.eslintrc.js advanced/server-extension/.eslintrc.js
diff hello-world/tsconfig.json server-extension/tsconfig.json
diff hello-world/.eslintignore server-extension/.eslintignore
diff hello-world/.eslintrc.js server-extension/.eslintrc.js
shell: bash
- name: Install Python
if: steps.filter.outputs.extension == 'true'
Expand Down Expand Up @@ -182,18 +182,18 @@ jobs:
- name: Install the NPM dependencies
if: steps.filter.outputs.extension == 'true'
run: |
cd advanced/server-extension
cd server-extension
jlpm
- name: Lint the files
if: steps.filter.outputs.extension == 'true'
run: |
cd advanced/server-extension
cd server-extension
jlpm run eslint:check
- name: Build extension as user
if: steps.filter.outputs.extension == 'true'
# Force the usage of the source distribution (good practice)
run: |
cd advanced/server-extension
cd server-extension
python setup.py sdist
pip install ./dist/jlab_ext_example* --pre --find-links=dist --no-cache-dir
python -m jupyterlab.browser_check
Expand All @@ -212,7 +212,7 @@ jobs:
- name: Build extension as dev
if: steps.filter.outputs.extension == 'true'
run: |
cd advanced/server-extension
cd server-extension
pip install -e .
- name: Check extension as dev
if: steps.filter.outputs.extension == 'true' && ( startsWith(runner.os, 'Linux') || startsWith(runner.os, 'macOS') )
Expand Down Expand Up @@ -266,7 +266,8 @@ jobs:
run: jlpm
- name: Build all the extensions
run: |
pytest --check-links
jlpm build-ext
jlpm lint:check
jlpm install-ext
# Check links as last step as new tutorial may set links not yet valid (like file not yet in master)
pytest --check-links
66 changes: 33 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ conda env create
conda activate jupyterlab-extension-examples

# go to the hello world example
cd basics/hello-world
cd hello-world

# install the extension in editable mode
python -m pip install -e .
Expand All @@ -50,25 +50,25 @@ Note that the `1.x` and `2.x` branches are not updated anymore.

You may find it easier to learn how to create extensions _by examples_, instead of going through the documentation.

Start with the [Hello World](basics/hello-world) and then jump to the topic you are interested in.
Start with the [Hello World](hello-world) and then jump to the topic you are interested in.

- [Hello World](basics/hello-world)
- [Signals](basics/signals)
- [Datagrid](basics/datagrid)
- [Hello World](hello-world)
- [Signals](signals)
- [Datagrid](datagrid)
- [Command Palette](command-palette)
- [Commands](commands)
- [Launcher](launcher)
- [Main Menu](main-menu)
- [Settings](settings)
- [State](state)
- [React Widget](react/react-widget)
- [Widgets](widget-tracker/widgets)
- [Log Messages](log-console/log-messages)
- [Custom Log Console](log-console/custom-log-console)
- [React Widget](react-widget)
- [Widgets](widgets)
- [Log Messages](log-messages)
- [Custom Log Console](custom-log-console)
- [Context Menu](context-menu)
- [Kernel Output](advanced/kernel-output)
- [Kernel Messaging](advanced/kernel-messaging)
- [Server Hello World](advanced/server-extension)
- [Kernel Output](kernel-output)
- [Kernel Messaging](kernel-messaging)
- [Server Hello World](server-extension)

You can expect from each example:

Expand All @@ -83,23 +83,23 @@ You are welcome to open any [issue](https://github.com/jupyterlab/extension-exam

## Basic

### [Hello World](basics/hello-world)
### [Hello World](hello-world)

Set up the development environment and print to the console.

[![Hello World](basics/hello-world/preview.png)](basics/hello-world)
[![Hello World](hello-world/preview.png)](hello-world)

### [Signals](basics/signals)
### [Signals](signals)

Use Signals to allow Widgets communicate with each others.

[![Button with Signal](basics/signals/preview.png)](basics/signals)
[![Button with Signal](signals/preview.png)](signals)

### [Datagrid](basics/datagrid)
### [Datagrid](datagrid)

Display a Datagrid as a Lumino Widget.

[![Datagrid](basics/datagrid/preview.png)](basics/datagrid)
[![Datagrid](datagrid/preview.png)](datagrid)

## Command Palette

Expand Down Expand Up @@ -151,33 +151,33 @@ Use State persistence in an extension.

## React

### [React Widget](react/react-widget)
### [React Widget](react-widget)

Create a React.js Widget in JupyterLab.

[![react-widget](react/react-widget/preview.gif)](react/react-widget)
[![react-widget](react-widget/preview.gif)](react-widget)

## Widget Tracker

### [Widgets](widget-tracker/widgets)
### [Widgets](widgets)

Add a new Widget element to the main window.

[![Custom Tab](widget-tracker/widgets/preview.png)](widget-tracker/widgets)
[![Custom Tab](widgets/preview.png)](widgets)

## Log Console

### [Log Messages](log-console/log-messages)
### [Log Messages](log-messages)

Send a log message to the log console.

[![Log Messages](log-console/log-messages/preview.gif)](log-console/log-messages)
[![Log Messages](log-messages/preview.gif)](log-messages)

### [Custom Log Console](log-console/custom-log-console)
### [Custom Log Console](custom-log-console)

Create a new log console.

[![Custom Log Console](log-console/custom-log-console/preview.gif)](log-console/custom-log-console)
[![Custom Log Console](custom-log-console/custom-preview.gif)](custom-log-console)

## Context Menu

Expand All @@ -189,23 +189,23 @@ Add a new button to an existent context menu.

## Advanced

### [Kernel Output](advanced/kernel-output)
### [Kernel Output](kernel-output)

Render kernel messages in an OuputArea.

[![OutputArea class](advanced/kernel-output/preview.gif)](advanced/kernel-output)
[![OutputArea class](kernel-output/preview.gif)](kernel-output)

### [Kernel Messaging](advanced/kernel-messaging)
### [Kernel Messaging](kernel-messaging)

Interact with a kernel from an extension.

[![Kernel Messages](advanced/kernel-messaging/preview.gif)](advanced/kernel-messaging)
[![Kernel Messages](kernel-messaging/preview.gif)](kernel-messaging)

### [Server Hello World](advanced/server-extension)
### [Server Hello World](server-extension)

Create a minimal extension with backend (i.e. server) and frontend parts.

[![Server Hello World](advanced/server-extension/preview.png)](advanced/server-extension)
[![Server Hello World](server-extension/preview.png)](server-extension)

## Prerequisites

Expand Down Expand Up @@ -252,7 +252,7 @@ jlpm clean-ext

### Build and Install one Example

Go to the example directory you want to install, e.g. `cd ./basics/hello-world`, and run the following commands:
Go to the example directory you want to install, e.g. `cd ./hello-world`, and run the following commands:

```bash
pip install -e .
Expand Down
Empty file removed advanced/README.md
Empty file.
Empty file removed basics/README.md
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ This example shows how to create a log console to print log messages from a Jupy

The default log console extension in JupyterLab obtains log outputs from the kernel context of the current active notebook. So you can either:

1. Obtain the current active notebook and send message to his `Logger` instance (see the [log message](https://github.com/jupyterlab/extension-examples/tree/master/log-console/log-messages) example).
1. Obtain the current active notebook and send message to his `Logger` instance (see the [log message](https://github.com/jupyterlab/extension-examples/tree/master/log-messages) example).
2. Create your custom log console (covered in this example).

> It is strongly recommended to read [commands](https://github.com/jupyterlab/extension-examples/tree/master/commands), [command-palette](https://github.com/jupyterlab/extension-examples/tree/master/command-palette), [main-menu](https://github.com/jupyterlab/extension-examples/tree/master/main-menu), [widget-tracker](https://github.com/jupyterlab/extension-examples/tree/master/widget-tracker) and [react-widget](https://github.com/jupyterlab/extension-examples/tree/master/react/react-widget) examples before diving into this one.
> It is strongly recommended to read [commands](https://github.com/jupyterlab/extension-examples/tree/master/commands), [command-palette](https://github.com/jupyterlab/extension-examples/tree/master/command-palette), [main-menu](https://github.com/jupyterlab/extension-examples/tree/master/main-menu), [widget-tracker](https://github.com/jupyterlab/extension-examples/tree/master/widget-tracker) and [react-widget](https://github.com/jupyterlab/extension-examples/tree/master/react-widget) examples before diving into this one.
To implement this log console you need to install the following packages:

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions basics/hello-world/README.md → hello-world/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ show something like:

```bash
local extensions:
@jupyterlab-examples/hello-world: [...]/basics/hello-world
@jupyterlab-examples/hello-world: [...]/hello-world
```

Now let's check inside of JupyterLab if it works. Run [can take a while]:
Expand Down Expand Up @@ -263,5 +263,5 @@ JupyterLab is built on top of three major concepts. It is advised to look throug
examples in the following order:

- _command_: Function to be executed from UI elements. See the [commands example](../../commands)
- _widget_: UI based brick. See the [widgets example](../../widget-tracker/widgets)
- _widget_: UI based brick. See the [widgets example](../../widgets)
- _signal_: Observer pattern between JupyterLab elements. See the [signals example](../signals)
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ provided directly by the JupyterLab application:
const manager = app.serviceManager;
```

With these lines, you can extend the panel widget from the [signal example](../../basics/signals) to initialize a
With these lines, you can extend the panel widget from the [signal example](../../signals) to initialize a
kernel. In addition, you will create a `KernelModel` class in it and
overwrite the `dispose` and `onCloseRequest` methods of the `StackedPanel`
([see the documentation](https://jupyterlab.github.io/lumino/widgets/classes/stackedpanel.html))
Expand Down Expand Up @@ -282,7 +282,7 @@ In the [Kernel Output](../kernel-output)
example, you will explore how you can reuse some Jupyter components to have a nicer display for kernel messages.

This example uses React to define UI elements. You can
learn more about React in JupyterLab in [that example](../../react/react-widget/README.md).
learn more about React in JupyterLab in [that example](../../react-widget/README.md).

The UI refresh is triggered by signal emitions. To know more about it,
you can have a look at the [signal example](../../basics/signals/README.md).
you can have a look at the [signal example](../../signals/README.md).
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected onCloseRequest(msg: Message): void {

## OutputArea and Model

The `SimplifiedOutputArea` class is a `Widget`, as described in the [widget example](../../widget-tracker/widgets/README.md).
The `SimplifiedOutputArea` class is a `Widget`, as described in the [widget example](../../widgets/README.md).
It has the ability to display the results of a notebook cell execution.
You can instantiate it with a new `OutputAreaModel`; this class is containing
the data to show:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 10 additions & 5 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{
"packages": [
"advanced/*",
"basics/*",
"command-palette",
"commands",
"context-menu",
"custom-log-console",
"datagrid",
"hello-world",
"kernel-messaging",
"kernel-output",
"launcher",
"log-console/*",
"log-messages",
"main-menu",
"react/*",
"react-widget",
"server-extension",
"settings",
"signals",
"state",
"widget-tracker/*"
"widgets"
],
"npmClient": "jlpm",
"useWorkspaces": true,
Expand Down
Empty file removed log-console/README.md
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions log-console/log-messages/README.md → log-messages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This is a basic example to show how to send different types of log message to th
The default log console extension in JupyterLab obtains log outputs from the kernel context of the current active notebook. That let the log console change the source input once a new notebook is opened. There are different ways to approach the problem:

1. Obtain the current active notebook and send message to his `Logger` instance (covered in this example).
2. Create your custom log console (see the [custom log console](https://github.com/jupyterlab/extension-examples/tree/master/log-console/custom-log-console) example).
2. Create your custom log console (see the [custom log console](https://github.com/jupyterlab/extension-examples/tree/master/custom-log-console) example).

> It is strongly recommended to read [main-menu](https://github.com/jupyterlab/extension-examples/tree/master/main-menu) example before diving into this one.
Expand Down Expand Up @@ -71,4 +71,4 @@ logger?.log(msg);
It is worth noting that with this approximation you will only be able to send messages to the log console if you have a notebook opened. If you have more than one notebook opened, the messages will be sent to the active notebook or the most recently focused notebook. It means that if you are changing from one notebook to another, every message will be sent to a different source and will be shown when the notebook gets the focus.
Examples of other types of messages can be seen in the [custom log console](https://github.com/jupyterlab/extension-examples/tree/master/log-console/custom-log-console) example.
Examples of other types of messages can be seen in the [custom log console](https://github.com/jupyterlab/extension-examples/tree/master/custom-log-console) example.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 3d221fe

Please sign in to comment.