Skip to content

Commit 8fd4d15

Browse files
committed
Hello world
1 parent eeadbcf commit 8fd4d15

File tree

20 files changed

+2415
-126
lines changed

20 files changed

+2415
-126
lines changed

.github/style/index.css

Whitespace-only changes.

.github/workflows/build.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: master
6+
pull_request:
7+
branches: '*'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v1
15+
- name: Install node
16+
uses: actions/setup-node@v1
17+
with:
18+
node-version: '10.x'
19+
- name: Install Python
20+
uses: actions/setup-python@v1
21+
with:
22+
python-version: '3.7'
23+
architecture: 'x64'
24+
- name: Install dependencies
25+
run: python -m pip install jupyterlab
26+
- name: Build the extension
27+
run: |
28+
jlpm && jlpm run build
29+
jupyter labextension install .
30+
python -m jupyterlab.browser_check

.gitignore

Lines changed: 5 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,129 +1,8 @@
1-
# Byte-compiled / optimized / DLL files
2-
__pycache__/
3-
*.py[cod]
4-
*$py.class
5-
6-
# C extensions
7-
*.so
8-
9-
# Distribution / packaging
10-
.Python
11-
build/
12-
develop-eggs/
13-
dist/
14-
downloads/
15-
eggs/
16-
.eggs/
1+
*.bundle.*
172
lib/
18-
lib64/
19-
parts/
20-
sdist/
21-
var/
22-
wheels/
23-
pip-wheel-metadata/
24-
share/python-wheels/
3+
node_modules/
254
*.egg-info/
26-
.installed.cfg
27-
*.egg
28-
MANIFEST
29-
30-
# PyInstaller
31-
# Usually these files are written by a python script from a template
32-
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33-
*.manifest
34-
*.spec
35-
36-
# Installer logs
37-
pip-log.txt
38-
pip-delete-this-directory.txt
39-
40-
# Unit test / coverage reports
41-
htmlcov/
42-
.tox/
43-
.nox/
44-
.coverage
45-
.coverage.*
46-
.cache
47-
nosetests.xml
48-
coverage.xml
49-
*.cover
50-
*.py,cover
51-
.hypothesis/
52-
.pytest_cache/
53-
54-
# Translations
55-
*.mo
56-
*.pot
57-
58-
# Django stuff:
59-
*.log
60-
local_settings.py
61-
db.sqlite3
62-
db.sqlite3-journal
63-
64-
# Flask stuff:
65-
instance/
66-
.webassets-cache
67-
68-
# Scrapy stuff:
69-
.scrapy
70-
71-
# Sphinx documentation
72-
docs/_build/
73-
74-
# PyBuilder
75-
target/
76-
77-
# Jupyter Notebook
785
.ipynb_checkpoints
79-
80-
# IPython
81-
profile_default/
82-
ipython_config.py
83-
84-
# pyenv
85-
.python-version
86-
87-
# pipenv
88-
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89-
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90-
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91-
# install all needed dependencies.
92-
#Pipfile.lock
93-
94-
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95-
__pypackages__/
96-
97-
# Celery stuff
98-
celerybeat-schedule
99-
celerybeat.pid
100-
101-
# SageMath parsed files
102-
*.sage.py
103-
104-
# Environments
105-
.env
106-
.venv
107-
env/
108-
venv/
109-
ENV/
110-
env.bak/
111-
venv.bak/
112-
113-
# Spyder project settings
114-
.spyderproject
115-
.spyproject
116-
117-
# Rope project settings
118-
.ropeproject
119-
120-
# mkdocs documentation
121-
/site
122-
123-
# mypy
124-
.mypy_cache/
125-
.dmypy.json
126-
dmypy.json
127-
128-
# Pyre type checker
129-
.pyre/
6+
*.tsbuildinfo
7+
__pycache__
8+
.idea/

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include setupbase.py
2+
include README.md
3+
include package.json

README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,55 @@
11
# jupyterlab-snippets
2+
3+
![Github Actions Status](https://github.com/mkzilla/jupyterlab-snippets/workflows/Build/badge.svg)
4+
25
code snippets integration for JupyterLab
6+
7+
8+
## Requirements
9+
10+
* JupyterLab >= 2.0
11+
12+
## Install
13+
14+
```bash
15+
jupyter labextension install jupyterlab-snippets
16+
```
17+
18+
## Contributing
19+
20+
### Install
21+
22+
The `jlpm` command is JupyterLab's pinned version of
23+
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
24+
`yarn` or `npm` in lieu of `jlpm` below.
25+
26+
```bash
27+
# Clone the repo to your local environment
28+
# Move to jupyterlab-snippets directory
29+
# Install dependencies
30+
jlpm
31+
# Build Typescript source
32+
jlpm build
33+
# Link your development version of the extension with JupyterLab
34+
jupyter labextension link .
35+
# Rebuild Typescript source after making changes
36+
jlpm build
37+
# Rebuild JupyterLab after making any changes
38+
jupyter lab build
39+
```
40+
41+
You can watch the source directory and run JupyterLab in watch mode to watch for changes in the extension's source and automatically rebuild the extension and application.
42+
43+
```bash
44+
# Watch the source directory in another terminal tab
45+
jlpm watch
46+
# Run jupyterlab in watch mode in one terminal tab
47+
jupyter lab --watch
48+
```
49+
50+
### Uninstall
51+
52+
```bash
53+
jupyter labextension uninstall jupyterlab-snippets
54+
```
55+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"NotebookApp": {
3+
"nbserver_extensions": {
4+
"jupyterlab_snippets": true
5+
}
6+
}
7+
}

jupyterlab_snippets/__init__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from notebook.utils import url_path_join
2+
3+
from ._version import __version__
4+
from .ping import ping
5+
from .snippets import snippets
6+
7+
8+
def _jupyter_server_extension_paths():
9+
return [{
10+
'module': 'jupyterlab_snippets'
11+
}]
12+
13+
14+
def load_jupyter_server_extension(nb_server_app):
15+
web_app = nb_server_app.web_app
16+
base = web_app.settings['base_url']
17+
host_pattern = '.*$'
18+
19+
web_app.add_handlers(host_pattern, [
20+
(url_path_join(base, r"/ping"), ping),
21+
(url_path_join(base, r"/snippets"), snippets),
22+
])

jupyterlab_snippets/_version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = '1.0.1'

jupyterlab_snippets/api/api.yaml

Whitespace-only changes.

jupyterlab_snippets/ping.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import platform
2+
import os
3+
import socket
4+
from notebook.base.handlers import IPythonHandler
5+
from ._version import __version__
6+
7+
8+
class ping(IPythonHandler):
9+
def get(self):
10+
data = dict(
11+
os = platform.system(),
12+
arch = platform.architecture(),
13+
platform = platform.platform(),
14+
platform_version = platform.version(),
15+
processor = platform.processor(),
16+
node = socket.getfqdn(),
17+
python = platform.python_version(),
18+
labserver_version = __version__,
19+
user = os.environ.get('USER'),
20+
query= self.request.query,
21+
)
22+
self.finish(data)

jupyterlab_snippets/snippets.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from notebook.base.handlers import IPythonHandler
2+
import json
3+
4+
code = [
5+
{
6+
'name':'Setup',
7+
'snippets': [
8+
'from __future__ import print_function, division',
9+
'import sys',
10+
'if sys.version_info[0] >= 3:',
11+
' xrange = range # Must always iterate with xrange in njit functions',
12+
'import numba',
13+
]
14+
}
15+
16+
]
17+
18+
19+
class snippets(IPythonHandler):
20+
def get(self):
21+
self.finish(json.dumps(code))

package.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "jupyterlab-snippets",
3+
"version": "0.1.0",
4+
"description": "code snippets integration for JupyterLab",
5+
"keywords": [
6+
"jupyter",
7+
"jupyterlab",
8+
"jupyterlab-extension"
9+
],
10+
"homepage": "https://github.com/mkzilla/jupyterlab-snippets",
11+
"bugs": {
12+
"url": "https://github.com/mkzilla/jupyterlab-snippets/issues"
13+
},
14+
"license": "BSD-3-Clause",
15+
"author": "chengyumeng",
16+
"files": [
17+
"lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}",
18+
"style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}"
19+
],
20+
"main": "lib/index.js",
21+
"types": "lib/index.d.ts",
22+
"style": "style/index.css",
23+
"repository": {
24+
"type": "git",
25+
"url": "https://github.com/mkzilla/jupyterlab-snippets.git"
26+
},
27+
"scripts": {
28+
"build": "tsc",
29+
"clean": "rimraf lib tsconfig.tsbuildinfo",
30+
"prepare": "jlpm run clean && jlpm run build",
31+
"watch": "tsc -w"
32+
},
33+
"dependencies": {
34+
"@jupyterlab/application": "^2.0.2",
35+
"@jupyterlab/cells": "^2.0.2",
36+
"@jupyterlab/services": "^5.0.2",
37+
"@lumino/widgets": "^1.11.1"
38+
},
39+
"devDependencies": {
40+
"rimraf": "^2.6.1",
41+
"typescript": "~3.7.0"
42+
},
43+
"sideEffects": [
44+
"style/*.css"
45+
],
46+
"jupyterlab": {
47+
"extension": true
48+
}
49+
}

setup.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[metadata]
2+
license_file = LICENSE

0 commit comments

Comments
 (0)