Skip to content

Commit 85ade02

Browse files
committed
jlpm lint
1 parent a53ac79 commit 85ade02

File tree

6 files changed

+238
-228
lines changed

6 files changed

+238
-228
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
### Changes
2424

2525
- Don't list hidden folder #25
26-
- Correct hidden folder removal #26
27-
- Port to JupyterLab 3 #33
26+
- Correct hidden folder removal #26
27+
- Port to JupyterLab 3 #33
2828

2929
Many thanks @fcollonval for the contributions!

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,13 @@ pip uninstall jupyterlab-snippets
4949
Add snippets in `[jupyter_data_dir]/snippets` (see: https://jupyter.readthedocs.io/en/latest/projects/jupyter-directories.html#id2)
5050

5151
To find the Jupyter data directory, run:
52+
5253
```bash
5354
$ jupyter --path
5455
```
56+
5557
This will for example show the following list on macOS:
58+
5659
```
5760
config:
5861
/Users/<username>/.jupyter

jupyter-boilerplate-converter/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ extension (not available for JupyterLab) to [jupyterlab-snippets](../README.md).
66
## Usage
77

88
Run the following commands in the `jupyter-boilerplate-converter` directory.
9+
910
```
1011
$ npm install
1112
$ npm run convert <path/to/boilerplate-snippet.js> <path/to/snippets/dir> [extension]
@@ -18,6 +19,7 @@ Convert built-in jupyter-boilerplate snippets.
1819
Run the following commands in the `jupyter-boilerplate-converter` directory.
1920

2021
Download jupyter-boilerplate from github and list snippets:
22+
2123
```
2224
$ git clone git://github.com/moble/jupyter_boilerplate
2325
$ ls -l jupyter_boilerplate/snippets_submenus_python
@@ -29,6 +31,7 @@ sympy_functions.js
2931
```
3032

3133
Find JupyterLab data directories:
34+
3235
```
3336
$ jupyter --paths
3437
@@ -44,6 +47,7 @@ data:
4447
```
4548

4649
Convert one of the snippets to JupyterLab user-data directory (top directory in the list above):
50+
4751
```
4852
$ npm install # only required to run once
4953
$ npm run convert jupyter_boilerplate/snippets_submenus_python/numpy.js ~/Library/Jupyter .py

jupyter-boilerplate-converter/convert.js

+23-20
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,43 @@ var requirejs = require('requirejs');
22
var fs = require('fs');
33
var sanitizeFilename = require('sanitize-filename');
44

5-
65
const source = process.argv[2];
76
const destination = process.argv[3];
87
const extension = process.argv[4] || '';
98

109
requirejs.config({
11-
nodeRequire: require
10+
nodeRequire: require
1211
});
1312
require('node-define');
1413

1514
sourceData = require(source);
1615

17-
if (!fs.existsSync(destination)){
18-
fs.mkdirSync(destination);
16+
if (!fs.existsSync(destination)) {
17+
fs.mkdirSync(destination);
1918
}
2019

2120
function createLevel(path, data) {
22-
if (!data.name) {
23-
return
24-
}
25-
const newPath = `${path}/${sanitizeFilename(data.name)}`;
26-
27-
if (data.snippet) {
28-
fs.writeFile(`${newPath}${extension}`, data.snippet.join('\n'), function (err) {
29-
if (err) throw err;
30-
});
31-
} else if (data['sub-menu']) {
32-
if (!fs.existsSync(newPath)){
33-
fs.mkdirSync(newPath);
34-
}
35-
data['sub-menu'].forEach(submenu => {
36-
createLevel(newPath, submenu);
37-
});
21+
if (!data.name) {
22+
return;
23+
}
24+
const newPath = `${path}/${sanitizeFilename(data.name)}`;
25+
26+
if (data.snippet) {
27+
fs.writeFile(
28+
`${newPath}${extension}`,
29+
data.snippet.join('\n'),
30+
function (err) {
31+
if (err) throw err;
32+
}
33+
);
34+
} else if (data['sub-menu']) {
35+
if (!fs.existsSync(newPath)) {
36+
fs.mkdirSync(newPath);
3837
}
38+
data['sub-menu'].forEach(submenu => {
39+
createLevel(newPath, submenu);
40+
});
41+
}
3942
}
4043

4144
createLevel(destination, sourceData);

jupyter-config/jupyter_notebook_config.d/jupyterlab_snippets.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
"jupyterlab_snippets": true
55
}
66
}
7-
}
7+
}

0 commit comments

Comments
 (0)