Skip to content

Commit

Permalink
Make jupyterlab_pygments a labextension
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou committed Apr 4, 2022
1 parent 5cca14a commit 85699f2
Show file tree
Hide file tree
Showing 29 changed files with 794 additions and 56 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
coverage
**/*.d.ts
tests
39 changes: 39 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended'
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
sourceType: 'module'
},
plugins: ['@typescript-eslint'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
'selector': 'interface',
'format': ['PascalCase'],
'custom': {
'regex': '^I[A-Z]',
'match': true
}
}
],
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/quotes': [
'error',
'single',
{ avoidEscape: true, allowTemplateLiterals: false }
],
curly: ['error', 'all'],
eqeqeq: 'error',
'prefer-arrow-callback': 'error'
}
};
31 changes: 31 additions & 0 deletions .github/workflows/binder-on-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html
name: Binder Badge
on:
pull_request_target:
types: [opened]

permissions:
pull-requests: write


jobs:
binder:
runs-on: ubuntu-latest
steps:
- name: comment on PR with Binder link
uses: actions/github-script@v3
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 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 }}

69 changes: 69 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Build

on:
push:
branches: main
pull_request:
branches: '*'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Base Setup
uses: jupyterlab/maintainer-tools/.github/actions/base-setup@v1

- name: Install dependencies
run: python -m pip install -U jupyterlab~=3.1 check-manifest

- name: Build the extension
run: |
set -eux
jlpm
jlpm lint:check
python -m pip install .
jupyter labextension list 2>&1 | grep -ie "jupyterlab_pygments.*OK"
python -m jupyterlab.browser_check
check-manifest -v
pip install build
python -m build --sdist
cp dist/*.tar.gz myextension.tar.gz
pip uninstall -y "jupyterlab_pygments" jupyterlab
rm -rf myextension
- uses: actions/upload-artifact@v2
with:
name: myextension-sdist
path: myextension.tar.gz

test_isolated:
needs: build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- uses: actions/download-artifact@v2
with:
name: myextension-sdist
- name: Install and Test
run: |
set -eux
# Remove NodeJS, twice to take care of system and locally installed node versions.
sudo rm -rf $(which node)
sudo rm -rf $(which node)
pip install myextension.tar.gz
pip install jupyterlab
jupyter labextension list 2>&1 | grep -ie "jupyterlab_pygments.*OK"
python -m jupyterlab.browser_check --no-chrome-test
62 changes: 62 additions & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Check Release
on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: write

jobs:
check_release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.9
architecture: 'x64'
- name: Install node
uses: actions/setup-node@v2
with:
node-version: '14.x'

- name: Get pip cache dir
id: pip-cache
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v1
with:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('package.json') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Cache checked links
uses: actions/cache@v2
with:
path: ~/.cache/pytest-link-check
key: ${{ runner.os }}-linkcheck-${{ hashFiles('**/.md') }}-md-links
restore-keys: |
${{ runner.os }}-linkcheck-
- name: Upgrade packaging dependencies
run: |
pip install --upgrade pip setuptools wheel jupyter-packaging~=0.10 --user
- name: Install Dependencies
run: |
pip install .
- name: Check Release
uses: jupyter-server/jupyter_releaser/.github/actions/check-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Upload Distributions
uses: actions/upload-artifact@v2
with:
name: jupyterlab_pygments-releaser-dist-${{ github.run_number }}
path: .jupyter_releaser_checkout/dist
119 changes: 115 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,117 @@
*.bundle.*
lib/
node_modules/
.eslintcache
.stylelintcache
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
jupyterlab_pygments/labextension

# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
dist/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
*.egg-info/
.ipynb_checkpoints/
.*.swp
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# End of https://www.gitignore.io/api/python

# OSX files
.DS_Store

# Generated pygments CSS
style/base.css
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
**/node_modules
**/lib
**/package.json
jupyterlab_pygments
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "none",
"arrowParens": "avoid"
}
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,
}
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

<!-- <START NEW CHANGELOG ENTRY> -->

<!-- <END NEW CHANGELOG ENTRY> -->
24 changes: 24 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include LICENSE
include *.md
include pyproject.toml

include package.json
include install.json
include ts*.json
include yarn.lock

graft jupyterlab_pygments/labextension

# Javascript files
graft src
graft style
prune **/node_modules
prune lib
prune binder

# Patterns to exclude from any directory
global-exclude *~
global-exclude *.pyc
global-exclude *.pyo
global-exclude .git
global-exclude .ipynb_checkpoints
Loading

0 comments on commit 85699f2

Please sign in to comment.