Skip to content

Commit

Permalink
Merge pull request #128 from krassowski/lab-4.0
Browse files Browse the repository at this point in the history
Port to JupyterLab 4.0/CodeMirror6
  • Loading branch information
krassowski authored Jul 4, 2023
2 parents b41c9d5 + 5b117cd commit 1bac610
Show file tree
Hide file tree
Showing 29 changed files with 6,463 additions and 4,467 deletions.
14 changes: 7 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ module.exports = {
},
plugins: ['@typescript-eslint'],
rules: {
"@typescript-eslint/naming-convention": [
"error",
'@typescript-eslint/naming-convention': [
'error',
{
"selector": "interface",
"format": ["PascalCase"],
"custom": {
"regex": "^I[A-Z]",
"match": true
selector: 'interface',
format: ['PascalCase'],
custom: {
regex: '^I[A-Z]',
match: true
}
}
],
Expand Down
24 changes: 5 additions & 19 deletions .github/workflows/binder-on-pr.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (c) fcollonval
# Distributed under the terms of the Modified BSD License.
# Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html
name: Binder Badge
on:
pull_request_target:
Expand All @@ -9,20 +6,9 @@ on:
jobs:
binder:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: comment on PR with Binder link
uses: actions/github-script@v1
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO;
var PR_HEAD_REF = process.env.PR_HEAD_REF;
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab) :point_left: Launch a binder notebook on branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_`
})
env:
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}
- uses: jupyterlab/maintainer-tools/.github/actions/binder-link@v1
with:
github_token: ${{ secrets.github_token }}
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: '16.x'
- name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.8'
architecture: 'x64'
- name: Install dependencies
run: python -m pip install jupyterlab
- name: Build the extension
run: |
jlpm
jlpm run eslint:check
jlpm run lint:check
python -m pip install .
jupyter labextension list 2>&1 | grep -ie "@ijmbarr/jupyterlab_spellchecker.*OK"
jupyter labextension list 2>&1 | grep -ie "@jupyterlab-contrib/spellchecker.*OK"
python -m jupyterlab.browser_check
- name: Install test dependencies
run: python -m pip install pytest
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/enforce-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Enforce PR label

on:
pull_request:
types: [labeled, unlabeled, opened, edited, synchronize]
jobs:
enforce-label:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: enforce-triage-label
uses: jupyterlab/maintainer-tools/.github/actions/enforce-label@v1
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: '14.x'
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
- name: Install Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.x'
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip build twine jupyterlab
Expand Down
14 changes: 9 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
*.bundle.*
lib/
node_modules/
*.log
.eslintcache
.stylelintcache
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
Expand All @@ -10,6 +13,9 @@ package-lock.json
dictionaries/*.py
download_new_dic.py
_temp_extension/
jupyterlab_spellchecker/labextension
# Version file is handled by hatchling
jupyterlab_spellchecker/_version.py

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python
Expand Down Expand Up @@ -61,6 +67,7 @@ htmlcov/
.coverage.*
.cache
nosetests.xml
coverage/
coverage.xml
*.cover
.hypothesis/
Expand Down Expand Up @@ -116,8 +123,5 @@ dmypy.json
# OSX files
.DS_Store

# hide development labextension
/*/labextension

# hide vscode configuration
.vscode
# Yarn cache
.yarn/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules
**/node_modules
**/lib
**/package.json
!/package.json
jupyterlab_spellchecker
12 changes: 12 additions & 0 deletions .stylelintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": [
"stylelint-config-recommended",
"stylelint-config-standard",
"stylelint-prettier/recommended"
],
"rules": {
"property-no-vendor-prefix": null,
"selector-no-vendor-prefix": null,
"value-no-vendor-prefix": null
}
}
3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
enableImmutableInstalls: false

nodeLinker: node-modules
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
### 0.8.0 (2023-06-04)

- support JupyterLab 4.0 (#128)

### 0.7.3 (2023-02-08)

- enable spellchecker by default in RST and LaTeX files (#122)
- add IPython to ignore list (#123)
- bump version and builder dev dependency (#124)

### 0.7.2 (2021-10-08)

- fallback to `base_name` if babel crashes (#95)
- bump ansi-regex from 5.0.0 to 5.0.1 (#97)

### 0.7.1 (2021-09-01)

- bump tar from 6.1.5 to 6.1.11 (#92)
- bump url-parse from 1.5.1 to 1.5.3 (#91)
- bump path-parse from 1.0.6 to 1.0.7 (#90)
- add new trove classifiers (#89)
- bump tar from 6.1.0 to 6.1.5 (#88)

### 0.7.0 (2021-07-31)

- added possibility of using remote "online" dictionaries by specifying URLs for `.aff` and `.dic` files (#85)
- added support for translations of the text shown in the interface (#84)
- fixed the behaviour of the dictionary selector when an invalid dictionary is initially set in the settings (#83)
- bumped normalize-uri to 4.5.1 (#82)
- enable strict null checks, switch to modern compilation targets; add more Jupyter projects to spellcheck ignore (#86)

### 0.6.0 (2021-06-01)

- change the dictionary loading mechanism from internal static into a server extension (#69)
- dictionaries will now be discovered in operating system specific paths if available
- choice is now possible from one of multiple dictionaries using the same locale
- add the possibility to add custom dictionary (#66)

### 0.5.2 (2021-03-19)

- added a status message while loading a dictionary (#62)

### 0.5.0 (2021-02-28)
Expand Down
25 changes: 0 additions & 25 deletions MANIFEST.in

This file was deleted.

21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# jupyterlab-spellchecker

[![Extension status](https://img.shields.io/badge/status-ready-success "ready to be used")](https://jupyterlab-contrib.github.io/)
[![Extension status](https://img.shields.io/badge/status-ready-success 'ready to be used')](https://jupyterlab-contrib.github.io/)
[![Github Actions Status](https://github.com/jupyterlab-contrib/spellchecker/workflows/Build/badge.svg)](https://github.com/jupyterlab-contrib/spellchecker/actions)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupyterlab-contrib/spellchecker/master?urlpath=lab)
[![PyPI version](https://img.shields.io/pypi/v/jupyterlab-spellchecker.svg)](https://pypi.org/project/jupyterlab-spellchecker/)
Expand All @@ -11,9 +11,10 @@ A JupyterLab extension highlighting misspelled words in markdown cells within no
![](https://raw.githubusercontent.com/jupyterlab-contrib/spellchecker/master/demo.gif)

The JupyterLab extension is based on [the spellchecker Jupyter Notebook extension](https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tree/master/src/jupyter_contrib_nbextensions/nbextensions/spellchecker) and relies on [Typo.js](https://github.com/cfinke/Typo.js) for the actual spell checking.
Spellchecker suggestions are available from the context menu. The style of the highlights can be customized in the *Advanced Settings Editor*.
Spellchecker suggestions are available from the context menu. The style of the highlights can be customized in the _Advanced Settings Editor_.

The extension provides (Hunspell) [SCOWL](http://wordlist.aspell.net/) dictionaries for:

- American, British, Canadian, and Australian English
- French,
- German (Germany, Austria, Switzerland)
Expand All @@ -33,6 +34,7 @@ You should place two files with extensions `.aff` and `.dic`, and name following
For more details, please see the [example](#adding-dictionaries---example) below.

## JupyterLab Version

The extension has been tested up to JupyterLab version 3.0.

## Installation
Expand Down Expand Up @@ -96,6 +98,7 @@ and you want to add Polish language, you would put `pl_PL.aff` and `pl_PL.dic` i
#### Where to get the dictionaries from?

Some good sources of dictionaries include:

- [LibreOffice/dictionaries](https://github.com/LibreOffice/dictionaries) GitHub repository
- [Chromium](https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+/master) repository
- (if you know of any other quality resources please send a PR to add them here)
Expand All @@ -107,17 +110,17 @@ is fetching the dictionaries from a remote URL. This requires an Internet connec
(each time when you open JupyterLab or change the dictionary), and might be useful if you are not able
to save dictionaries on disk (e.g. when using JupyterLab on JupyterHub configured by someone else).

To configure the online dictionaries go to *Advanced Settings Editor**Spellchecker*
To configure the online dictionaries go to _Advanced Settings Editor__Spellchecker_
and set `onlineDictionaries` to an array of JSON objects like in the example below:

```json
[
{
"id": "en_US-online",
"aff": "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff",
"dic": "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic",
"name": "My favorite variant of English"
}
{
"id": "en_US-online",
"aff": "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff",
"dic": "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic",
"name": "My favorite variant of English"
}
]
```

Expand Down
10 changes: 10 additions & 0 deletions binder/postBuild
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ _(sys.executable, "-m", "pip", "check")

# install the labextension
_(sys.executable, "-m", "pip", "install", "-e", ".")
_(sys.executable, "-m", "jupyter", "labextension", "develop", "--overwrite", ".")
_(
sys.executable,
"-m",
"jupyter",
"server",
"extension",
"enable",
"jupyterlab-spellchecker",
)

# verify the environment the extension didn't break anything
_(sys.executable, "-m", "pip", "check")
Expand Down
10 changes: 9 additions & 1 deletion jupyterlab_spellchecker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
try:
from ._version import __version__
except ImportError:
# Fallback when using the package in dev mode without installing
# in editable mode with pip. It is highly recommended to install
# the package from a stable release or in editable mode: https://pip.pypa.io/en/stable/topics/local-project-installs/#editable-installs
import warnings
warnings.warn("Importing 'jupyterlab-spellchecker' outside a proper installation.")
__version__ = "dev"

import json
from pathlib import Path

from .handlers import setup_handlers
from ._version import __version__

HERE = Path(__file__).parent.resolve()

Expand Down
20 changes: 0 additions & 20 deletions jupyterlab_spellchecker/_version.py

This file was deleted.

2 changes: 1 addition & 1 deletion jupyterlab_spellchecker/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def setup_handlers(web_app, url_path, server_app):
# Prepend the base_url so that it works in a JupyterHub setting
route_pattern = url_path_join(base_url, url_path, "language_manager")
handlers = [(route_pattern, LanguageManagerHandler)]
web_app.add_handlers(host_pattern, handlers)
web_app.add_handlers(host_pattern, handlers)
Loading

0 comments on commit 1bac610

Please sign in to comment.