Skip to content

Commit

Permalink
Merge branch 'main' into save-cells-to-run-before-restart
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski authored Nov 1, 2023
2 parents 259938d + aa117ca commit 9961c13
Show file tree
Hide file tree
Showing 135 changed files with 5,118 additions and 405 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ __pycache__
pip-wheel-metadata
Pipfile
Pipfile.lock
venv/

# xeus-python debug logs
xpython_debug_logs
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ repos:
exclude: (.bumpversion.cfg|yarn.js)

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.26.3
rev: 0.27.0
hooks:
- id: check-github-workflows

- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.9.1
hooks:
- id: black

# Check ruff version is aligned with the one in pyproject.toml
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.291
rev: v0.0.292
hooks:
- id: ruff
args: ["--fix"]
Expand Down
2 changes: 1 addition & 1 deletion builder/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export namespace Build {
rules: [
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
use: [MiniCssExtractPlugin.loader, require.resolve('css-loader')]
},
{
test: /\.svg/,
Expand Down
2 changes: 1 addition & 1 deletion builder/src/extensionConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ function generateConfig({
rules.push({
test: /\.js$/,
enforce: 'pre',
use: ['source-map-loader']
use: [require.resolve('source-map-loader')]
});
}

Expand Down
5 changes: 4 additions & 1 deletion builder/src/webpack.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import miniSVGDataURI from 'mini-svg-data-uri';

const rules = [
{ test: /\.raw\.css$/, type: 'asset/source' },
{ test: /(?<!\.raw)\.css$/, use: ['style-loader', 'css-loader'] },
{
test: /(?<!\.raw)\.css$/,
use: [require.resolve('style-loader'), require.resolve('css-loader')]
},
{ test: /\.txt$/, type: 'asset/source' },
{ test: /\.md$/, type: 'asset/source' },
{ test: /\.(jpg|png|gif)$/, type: 'asset/resource' },
Expand Down
8 changes: 5 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ RUN if grep -q '^ID=alpine$' /etc/os-release; then \
ENV MAMBA_USER=$NEW_MAMBA_USER
USER $MAMBA_USER


WORKDIR /home/$MAMBA_USER/jupyterlab_cache
COPY --chown=$MAMBA_USER:$MAMBA_USER .. .

RUN micromamba install -n base -c conda-forge git rsync -y && micromamba install -y -n base -f /home/$MAMBA_USER/jupyterlab_cache/binder/environment.yml && micromamba clean --all --yes
COPY --chown=$MAMBA_USER:$MAMBA_USER ../binder/environment.yml ./binder/environment.yml

RUN micromamba install -n base -c conda-forge git rsync -y && micromamba install -y -n base -f ./binder/environment.yml && micromamba clean --all --yes

COPY --chown=$MAMBA_USER:$MAMBA_USER .. .

RUN micromamba run jlpm install

Expand Down
9 changes: 7 additions & 2 deletions docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ GID=$(id -g)
RSYNC_CMD="rsync -ar /home/$DEV_USER/jupyterlab_cache/node_modules/. /home/$DEV_USER/jupyterlab/node_modules"
CMD=$1 # possible command: build, clean, dev, shell

PORT=8888 # Optional, only used for the `dev` command
re='^[0-9]+$'
if [[ $2 =~ $re ]] ; then
PORT=$2
fi

stringmd5() {
echo "md5sum,md5" | tr ',' '\n' | while read -r cmd; do
Expand Down Expand Up @@ -55,13 +60,13 @@ if [[ $CMD == 'build' ]]; then
fi
stop_contaniner
if [[ $CMD == 'dev' || $CMD == '' || $CMD == 'dev-detach' ]]; then
DOCKER_CMD="$RSYNC_CMD && jupyter lab --dev-mode --watch --ip 0.0.0.0"
DOCKER_CMD="$RSYNC_CMD && jupyter lab --dev-mode --extensions-in-dev-mode --watch --ip 0.0.0.0 --port $PORT"
else
DOCKER_CMD="$RSYNC_CMD && bash"
fi
RUN_MODE="-it"
if [[ $CMD == 'dev-detach' ]]; then
RUN_MODE="-d"
fi
docker run $RUN_MODE --name $DEV_CONTAINER --rm -p 8888:8888 -v $ROOT_DIR:/home/$DEV_USER/jupyterlab --entrypoint "/bin/bash" $IMAGE_TAG -i -c "$DOCKER_CMD"
docker run $RUN_MODE --name $DEV_CONTAINER --rm -p $PORT:$PORT -v $ROOT_DIR:/home/$DEV_USER/jupyterlab --entrypoint "/bin/bash" $IMAGE_TAG -i -c "$DOCKER_CMD"
fi
1 change: 1 addition & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ def document_plugins_tokens_list(list_path: Path, output_path: Path) -> None:
"use_edit_page_button": True,
"navbar_align": "left",
"navbar_start": ["navbar-logo", "version-switcher"],
"navigation_with_keys": False,
"footer_start": ["copyright.html"],
"switcher": {
# Trick to get the documentation version switcher to always points to the latest version without being corrected by the integrity check;
Expand Down
2 changes: 1 addition & 1 deletion docs/source/developer/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ Other available commands:

.. code:: bash
bash docker/start.sh dev # Same as calling bash docker/start.sh
bash docker/start.sh dev 4567 # Start JupyterLab dev container at port 4567
bash docker/start.sh stop # Stop the running container
bash docker/start.sh clean # Remove the docker image
bash docker/start.sh build # Rebuild the docker image
Expand Down
2 changes: 1 addition & 1 deletion docs/source/developer/repo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The ``lab-dev`` endpoint is the equivalent of checking out the repo locally and
The ``lab-spliced`` endpoint is the equivalent of building JupyterLab in spliced mode and running ``jupyter lab``.
See the `Development workflow for source extensions <../extension/extension_dev.html#development-workflow-for-source-extensions>`__ for more information on spliced mode.

Build utilities: ``builtutils/``
Build utilities: ``buildutils/``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

An ``npm`` package that contains several utility scripts for managing
Expand Down
97 changes: 97 additions & 0 deletions docs/source/extension/extension_points.rst
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,103 @@ If you are adding your own activities to JupyterLab, you might consider providin
a ``WidgetTracker`` token of your own, so that other extensions can make use of it.
Completion Providers
--------------------
Both code completer and inline completer can be extended by registering
an (inline) completion provider on the completion manager provided by
the ``ICompletionProviderManager`` token.
Code Completer
^^^^^^^^^^^^^^
A minimal code completion provider needs to implement the `fetch` and `isApplicable`
methods, and define a unique `identifier` property, but the ``ICompletionProvider``
interface allows for much more extensive customization of the completer.
.. code:: typescript
import { ICompletionProviderManager, ICompletionProvider } from '@jupyterlab/completer';
class MyProvider implements ICompletionProvider {
readonly identifier = 'my-provider';
async isApplicable(context) {
return true;
}
async fetch(request, context) {
return {
start: request.offset,
end: request.offset,
items: [
{ label: 'option 1' },
{ label: 'option 2' }
]
};
}
}
const plugin: JupyterFrontEndPlugin<void> = {
id: 'my-completer-extension:provider',
autoStart: true,
requires: [ICompletionProviderManager],
activate: (app: JupyterFrontEnd, manager: ICompletionProviderManager): void => {
const provider = new MyProvider();
manager.registerProvider(provider);
}
};
A more detailed example is provided in the `extension-examples <https://github.com/jupyterlab/extension-examples/tree/main/completer>`__ repository.
For an example of an extensively customised completion provider, see the
`jupyterlab-lsp <https://github.com/jupyter-lsp/jupyterlab-lsp>`__ extension.
Inline Completer
^^^^^^^^^^^^^^^^
.. versionadded::4.1
Experimental Inline Completion API was added in JupyterLab 4.1.
We welcome feedback on making it better for extension authors.
A minimal inline completion provider extension would only implement the
required method `fetch` and define `identifier` and `name` properties,
but a number of additional fields can be used for enhanced functionality,
such as streaming, see the ``IInlineCompletionProvider`` documentation.
.. code:: typescript
import { ICompletionProviderManager, IInlineCompletionProvider } from '@jupyterlab/completer';
class MyInlineProvider implements IInlineCompletionProvider {
readonly identifier = 'my-provider';
readonly name = 'My provider';
async fetch(request, context) {
return {
items: [
{ insertText: 'suggestion 1' },
{ insertText: 'suggestion 2' }
]
};
}
}
const plugin: JupyterFrontEndPlugin<void> = {
id: 'my-completer-extension:inline-provider',
autoStart: true,
requires: [ICompletionProviderManager],
activate: (app: JupyterFrontEnd, manager: ICompletionProviderManager): void => {
const provider = new MyInlineProvider();
manager.registerInlineProvider(provider);
}
};
For an example of an inline completion provider with streaming support, see
`jupyterlab-transformers-completer <https://github.com/krassowski/jupyterlab-transformers-completer>`__.
State Database
--------------
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ideas with others.

JupyterLab is a sibling to other notebook authoring applications under
the `Project Jupyter <https://docs.jupyter.org/en/latest/>`_ umbrella, like
`Jupyter Notebook <https://jupyterlab.readthedocs.io/en/latest/>`_ and
`Jupyter Notebook <https://jupyter-notebook.readthedocs.io/en/latest/>`_ and
`Jupyter Desktop <https://github.com/jupyterlab/jupyterlab-desktop>`_. JupyterLab
offers a more advanced, feature rich, customizable experience compared to
Jupyter Notebook.
Expand Down
51 changes: 51 additions & 0 deletions docs/source/user/completer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.. Copyright (c) Jupyter Development Team.
.. Distributed under the terms of the Modified BSD License.
.. _completer:

Completer
=========

Two completer implementations are available in JupyterLab: code completer for tab-completion,
and inline completer for inline (as-you-type) suggestions.

Both the code completer and inline completer can present completions from third-party
providers when extensions with relevant (inline) completion providers are installed.

Code completer widget
---------------------

The code completer widget can be activated by pressing :kbd:`Tab` in a non-empty line of a code cell.

To cycle completion candidates use:
- :kbd:`Up`/:kbd:`Down` arrow keys or :kbd:`Tab`/:kbd:`Shift`+:kbd:`Shift` for cycling one item at a time
- :kbd:`Page Up`/:kbd:`Page Down` keys for jumping over multiple items at once

To accept the active completion candidate pressing :kbd:`Enter`, or click on it with your mouse/pointer.

By default the completions will include the symbols ("tokens") from the current editor ("context"),
and any suggestions returned by the active kernel in response to ``complete_request`` message.
You may be able to improve the relevance of completion suggestions by adjusting the configuration
of the kernel of your choice.

Documentation panel
^^^^^^^^^^^^^^^^^^^

The documentation panel presents additional information about the completion candidate.
It can be enabled in Code Completer settings. By default this panel sends ``inspect_request``
to the active kernel and is therefore only available in notebooks and other documents
with active session connected to a kernel that supports inspections.

Inline completer
----------------

JupyterLab 4.1+ includes an experimental inline completer, showing the suggestions
as greyed out "ghost" text. Compared to the completer widget, the inline completer:

- can present multi-line completions
- is automatically invoked as you type
- does not offer additional information such as type of documentation for the suggestions
- can provide completions in both code and markdown cells (the default history provider only suggests in code cells)

The inline completer is disabled by default and can be enabled in the Settings Editor
by enabling the History Provider.
1 change: 1 addition & 0 deletions docs/source/user/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ files
file_editor
notebook
code_console
completer
terminal
running
commands
Expand Down
4 changes: 4 additions & 0 deletions docs/source/user/notebook.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ and select “New Console for Notebook”:
<iframe src="https://www.youtube-nocookie.com/embed/eq1l7DBngQQ?rel=0&amp;showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>

.. _kernel_history:

You can iterate through the kernel history in a document cell using ``Alt Up-Arrow`` and ``Alt Down-Arrow``. To use this feature, enable kernel history access in the notebook settings.

.. _cell-toolbar:

Cell Toolbar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,22 @@
"caption": "",
"shortcuts": []
},
{
"id": "notebook:access-next-history-entry",
"label": "Access Next Kernel History Entry",
"caption": "",
"shortcuts": [
"Alt ArrowDown"
]
},
{
"id": "notebook:access-previous-history-entry",
"label": "Access Previous Kernel History Entry",
"caption": "",
"shortcuts": [
"Alt ArrowUp"
]
},
{
"id": "notebook:change-cell-to-code",
"label": "Change to Code Cell Type",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9961c13

Please sign in to comment.