Skip to content

Commit 61fe1da

Browse files
committed
Seed code_snippets project from cookiecutter'
0 parents  commit 61fe1da

24 files changed

+2721
-0
lines changed

.eslintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
dist
3+
coverage
4+
**/*.d.ts
5+
tests

.eslintrc.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
module.exports = {
2+
extends: [
3+
'eslint:recommended',
4+
'plugin:@typescript-eslint/eslint-recommended',
5+
'plugin:@typescript-eslint/recommended',
6+
'plugin:prettier/recommended'
7+
],
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
project: 'tsconfig.json',
11+
sourceType: 'module'
12+
},
13+
plugins: ['@typescript-eslint'],
14+
rules: {
15+
'@typescript-eslint/interface-name-prefix': [
16+
'error',
17+
{ prefixWithI: 'always' }
18+
],
19+
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
20+
'@typescript-eslint/no-explicit-any': 'off',
21+
'@typescript-eslint/no-namespace': 'off',
22+
'@typescript-eslint/no-use-before-define': 'off',
23+
'@typescript-eslint/quotes': [
24+
'error',
25+
'single',
26+
{ avoidEscape: true, allowTemplateLiterals: false }
27+
],
28+
curly: ['error', 'all'],
29+
eqeqeq: 'error',
30+
'prefer-arrow-callback': 'error'
31+
}
32+
};

.github/workflows/build.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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
29+
jlpm run eslint:check
30+
31+
pip install .
32+
jupyter lab build
33+
jupyter serverextension list 1>serverextensions 2>&1
34+
cat serverextensions | grep "code_snippets.*OK"
35+
jupyter labextension list 1>labextensions 2>&1
36+
cat labextensions | grep "code-snippets.*OK"
37+
38+
python -m jupyterlab.browser_check

.gitignore

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
*.bundle.*
2+
lib/
3+
node_modules/
4+
*.egg-info/
5+
.ipynb_checkpoints
6+
*.tsbuildinfo
7+
8+
*/labextension/*.tgz
9+
# Created by https://www.gitignore.io/api/python
10+
# Edit at https://www.gitignore.io/?templates=python
11+
12+
### Python ###
13+
# Byte-compiled / optimized / DLL files
14+
__pycache__/
15+
*.py[cod]
16+
*$py.class
17+
18+
# C extensions
19+
*.so
20+
21+
# Distribution / packaging
22+
.Python
23+
build/
24+
develop-eggs/
25+
dist/
26+
downloads/
27+
eggs/
28+
.eggs/
29+
lib/
30+
lib64/
31+
parts/
32+
sdist/
33+
var/
34+
wheels/
35+
pip-wheel-metadata/
36+
share/python-wheels/
37+
.installed.cfg
38+
*.egg
39+
MANIFEST
40+
41+
# PyInstaller
42+
# Usually these files are written by a python script from a template
43+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
44+
*.manifest
45+
*.spec
46+
47+
# Installer logs
48+
pip-log.txt
49+
pip-delete-this-directory.txt
50+
51+
# Unit test / coverage reports
52+
htmlcov/
53+
.tox/
54+
.nox/
55+
.coverage
56+
.coverage.*
57+
.cache
58+
nosetests.xml
59+
coverage.xml
60+
*.cover
61+
.hypothesis/
62+
.pytest_cache/
63+
64+
# Translations
65+
*.mo
66+
*.pot
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# pyenv
78+
.python-version
79+
80+
# celery beat schedule file
81+
celerybeat-schedule
82+
83+
# SageMath parsed files
84+
*.sage.py
85+
86+
# Spyder project settings
87+
.spyderproject
88+
.spyproject
89+
90+
# Rope project settings
91+
.ropeproject
92+
93+
# Mr Developer
94+
.mr.developer.cfg
95+
.project
96+
.pydevproject
97+
98+
# mkdocs documentation
99+
/site
100+
101+
# mypy
102+
.mypy_cache/
103+
.dmypy.json
104+
dmypy.json
105+
106+
# Pyre type checker
107+
.pyre/
108+
109+
# End of https://www.gitignore.io/api/python

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
**/node_modules
3+
**/lib
4+
**/package.json

.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": true
3+
}

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2020, Jay Ahn, Kiran Pinnipati All rights reserved.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
* Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
* Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
* Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
include LICENSE
2+
include README.md
3+
include pyproject.toml
4+
5+
include jupyter-config/code_snippets.json
6+
7+
include package.json
8+
include ts*.json
9+
include code_snippets/labextension/*.tgz
10+
11+
# Javascript files
12+
graft src
13+
graft style
14+
prune **/node_modules
15+
prune lib
16+
17+
# Patterns to exclude from any directory
18+
global-exclude *~
19+
global-exclude *.pyc
20+
global-exclude *.pyo
21+
global-exclude .git
22+
global-exclude .ipynb_checkpoints

README.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# code_snippets
2+
3+
![Github Actions Status](https://github.com/jupytercalpoly/project2.git/workflows/Build/badge.svg)[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/jupytercalpoly/project2.git/master?urlpath=lab)
4+
5+
Save, reuse, and share code snippets using JupyterLab Code Snippets
6+
7+
8+
This extension is composed of a Python package named `code_snippets`
9+
for the server extension and a NPM package named `code-snippets`
10+
for the frontend extension.
11+
12+
13+
## Requirements
14+
15+
* JupyterLab >= 2.0
16+
17+
## Install
18+
19+
Note: You will need NodeJS to install the extension.
20+
21+
```bash
22+
pip install code_snippets
23+
jupyter lab build
24+
```
25+
26+
## Troubleshoot
27+
28+
If you are seeing the frontend extension but it is not working, check
29+
that the server extension is enabled:
30+
31+
```bash
32+
jupyter serverextension list
33+
```
34+
35+
If the server extension is installed and enabled but you are not seeing
36+
the frontend, check the frontend is installed:
37+
38+
```bash
39+
jupyter labextension list
40+
```
41+
42+
If it is installed, try:
43+
44+
```bash
45+
jupyter lab clean
46+
jupyter lab build
47+
```
48+
49+
## Contributing
50+
51+
### Install
52+
53+
The `jlpm` command is JupyterLab's pinned version of
54+
[yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
55+
`yarn` or `npm` in lieu of `jlpm` below.
56+
57+
```bash
58+
# Clone the repo to your local environment
59+
# Move to code_snippets directory
60+
61+
# Install server extension
62+
pip install -e .
63+
# Register server extension
64+
jupyter serverextension enable --py code_snippets --sys-prefix
65+
66+
# Install dependencies
67+
jlpm
68+
# Build Typescript source
69+
jlpm build
70+
# Link your development version of the extension with JupyterLab
71+
jupyter labextension install .
72+
# Rebuild Typescript source after making changes
73+
jlpm build
74+
# Rebuild JupyterLab after making any changes
75+
jupyter lab build
76+
```
77+
78+
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.
79+
80+
```bash
81+
# Watch the source directory in another terminal tab
82+
jlpm watch
83+
# Run jupyterlab in watch mode in one terminal tab
84+
jupyter lab --watch
85+
```
86+
87+
Now every change will be built locally and bundled into JupyterLab. Be sure to refresh your browser page after saving file changes to reload the extension (note: you'll need to wait for webpack to finish, which can take 10s+ at times).
88+
89+
### Uninstall
90+
91+
```bash
92+
pip uninstall code_snippets
93+
jupyter labextension uninstall code-snippets
94+
```

binder/environment.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# a mybinder.org-ready environment for demoing code_snippets
2+
# this environment may also be used locally on Linux/MacOS/Windows, e.g.
3+
#
4+
# conda env update --file binder/environment.yml
5+
# conda activate code_snippets-demo
6+
#
7+
name: code_snippets-demo
8+
9+
channels:
10+
- conda-forge
11+
12+
dependencies:
13+
# runtime dependencies
14+
- python >=3.8,<3.9.0a0
15+
- jupyterlab >=2,<3.0.0a0
16+
# labextension build dependencies
17+
- nodejs >=12,<13.0.0a0
18+
# serverextension build dependencies
19+
- jupyter-packaging >=0.4.0,<0.5.0a0
20+
- pip
21+
- wheel
22+
23+
# additional packages for demos, may require modifying `labextensions.txt`
24+
# - ipywidgets

0 commit comments

Comments
 (0)