Skip to content

Commit 8beb298

Browse files
committed
add back in docs + binder support
1 parent 74321ff commit 8beb298

File tree

10 files changed

+196
-78
lines changed

10 files changed

+196
-78
lines changed

.gitignore

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
*.egg-info/
2-
.ipynb_checkpoints/
32
dist/
43
build/
54
*.py[cod]
@@ -12,5 +11,12 @@ idom_jupyter/labextension/
1211
# OS X
1312
.DS_Store
1413

15-
# PyEnv
14+
# Py Env
1615
.python-version
16+
17+
# VSCode
18+
.vscode
19+
20+
# Jupyter
21+
.ipynb_checkpoints/
22+
Untitled*.ipynb

README.md

Lines changed: 90 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,106 @@
1-
idom-jupyter
2-
===============================
1+
# idom-jupyter
32

4-
A client for IDOM implemented using Jupyter widgets
3+
A client for [IDOM](https://github.com/idom-team/idom) implemented using Jupyter widgets
54

6-
Installation
7-
------------
5+
## Try It Now!
6+
7+
Check out a live example by clicking the badge below:
8+
9+
<a href="https://mybinder.org/v2/gh/idom-team/idom-jupyter/main?filepath=notebooks%2Fintroduction.ipynb">
10+
<img alt="Binder" height="25px" src="https://mybinder.org/badge_logo.svg" />
11+
</a>
12+
13+
## Getting Started
14+
15+
Before anything else, do one of the following:
16+
17+
1. At the top of your notebook run
18+
19+
```python
20+
import idom_jupyter
21+
```
22+
23+
2. Register `idom_jupyter` as a permanant IPython extension in [your config file](https://ipython.readthedocs.io/en/stable/config/intro.html#introduction-to-ipython-configuration):
24+
25+
```python
26+
c.InteractiveShellApp.extensions = [
27+
'idom_jupyter'
28+
]
29+
```
30+
31+
## Usage
32+
33+
Once you're done [getting started](#getting-started), you can author and display IDOM
34+
layouts natively in your Jupyter Notebook:
35+
36+
```python
37+
import idom
38+
39+
@idom.element
40+
def ClickCount():
41+
count, set_count = idom.hooks.use_state(0)
42+
return idom.html.button(
43+
{"onClick": lambda event: set_count(count + 1)},
44+
[f"Click count: {count}"],
45+
)
46+
47+
ClickCount()
48+
```
49+
50+
You can also turn an `idom` element constructor into one that returns an `ipywidget` with
51+
the `idom_juptyer.widgetize` function. This is useful if you wish to use IDOM in combination
52+
with other Jupyter Widgets as in the following example:
53+
54+
```python
55+
ClickCountWidget = idom_jupyter.widgetize(ClickCount)
56+
ipywidgets.Box(
57+
[
58+
ClickCountWidget(),
59+
ClickCountWidget(),
60+
]
61+
)
62+
```
63+
64+
Alternatively just wrap an `idom` element instance in an `idom_jupyter.LayoutWidget`:
65+
66+
```python
67+
ipywidgets.Box(
68+
[
69+
idom_jupyter.LayoutWidget(ClickCount()),
70+
idom_jupyter.LayoutWidget(ClickCount()),
71+
]
72+
)
73+
```
74+
75+
# Installation
876

977
To install use pip:
1078

11-
$ pip install idom_jupyter
79+
```
80+
pip install idom_jupyter
81+
```
1282

1383
For a development installation (requires [Node.js](https://nodejs.org) and [Yarn version 1](https://classic.yarnpkg.com/)),
1484

15-
$ git clone https://github.com/idom-team/idom-jupyter.git
16-
$ cd idom-jupyter
17-
$ pip install -e .
18-
$ jupyter nbextension install --py --symlink --overwrite --sys-prefix idom_jupyter
19-
$ jupyter nbextension enable --py --sys-prefix idom_jupyter
85+
```
86+
git clone https://github.com/idom-team/idom-jupyter.git
87+
cd idom-jupyter
88+
pip install -e . -r requirements.txt
89+
jupyter nbextension install --py --symlink --overwrite --sys-prefix idom_jupyter
90+
jupyter nbextension enable --py --sys-prefix idom_jupyter
91+
```
2092

2193
When actively developing your extension for JupyterLab, run the command:
2294

23-
$ jupyter labextension develop --overwrite idom_jupyter
95+
```
96+
jupyter labextension develop --overwrite idom_jupyter
97+
```
2498

2599
Then you need to rebuild the JS when you make a code change:
26100

27-
$ cd js
28-
$ yarn run build
101+
```
102+
cd js
103+
yarn run build
104+
```
29105

30106
You then need to refresh the JupyterLab page when your javascript changes.

RELEASE.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
- To release a new version of idom_jupyter on PyPI:
1+
To release a new version of idom-client-jupyter on PyPI:
22

3-
Update _version.py (set release version, remove 'dev')
4-
git add the _version.py file and git commit
5-
`python setup.py sdist upload`
6-
`python setup.py bdist_wheel upload`
7-
`git tag -a X.X.X -m 'comment'`
8-
Update _version.py (add 'dev' and increment minor)
9-
git add and git commit
10-
git push
11-
git push --tags
3+
- Update `_version.py` (set release version, remove 'dev')
4+
- git add the `_version.py` file and git commit
5+
- ```
6+
python setup.py sdist bdist_wheel
7+
twine upload dist/*
8+
git tag -a X.X.X -m 'comment'
9+
git add and git commit
10+
git push
11+
git push --tags
12+
```
1213

13-
- To release a new version of idom-client-jupyter on NPM:
14+
To release a new version of idom-client-jupyter on NPM:
1415

15-
Update `js/package.json` with new npm package version
16-
17-
```
18-
# clean out the `dist` and `node_modules` directories
19-
git clean -fdx
20-
npm install
21-
npm publish
22-
```
16+
- Update `js/package.json` with new npm package version
17+
- ```
18+
# clean out the `dist` and `node_modules` directories
19+
git clean -fdx
20+
npm install
21+
npm publish
22+
```

binder/postBuild

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
npm install -g yarn
5+
6+
pip install -e .
7+
8+
jupyter serverextension enable --py idom_jupyter
9+
jupyter nbextension install --py --symlink --sys-prefix idom_jupyter
10+
jupyter nbextension enable --py --sys-prefix idom_jupyter
11+
# jupyter labextension install js

idom_jupyter/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Module version
2-
version_info = (0, 3, 1, "final", 0)
2+
version_info = (0, 4, 0, "final", 0)
33

44
# Module version stage suffix map
55
_specifier_ = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""}

idom_jupyter/widget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ class LayoutWidget(widgets.DOMWidget):
5252
_model_module = Unicode("idom-client-jupyter").tag(sync=True)
5353

5454
# Version of the front-end module containing widget view
55-
_view_module_version = Unicode("^0.1.0").tag(sync=True)
55+
_view_module_version = Unicode("^0.4.0").tag(sync=True)
5656
# Version of the front-end module containing widget model
57-
_model_module_version = Unicode("^0.1.0").tag(sync=True)
57+
_model_module_version = Unicode("^0.4.0").tag(sync=True)
5858

5959
_jupyter_server_base_url = Unicode().tag(sync=True)
6060

js/lib/widget.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ var IdomModel = widgets.DOMWidgetModel.extend({
88
_view_name: "IdomView",
99
_model_module: "idom-client-jupyter",
1010
_view_module: "idom-client-jupyter",
11-
_model_module_version: "0.1.0",
12-
_view_module_version: "0.1.0",
11+
_model_module_version: "0.4.0",
12+
_view_module_version: "0.4.0",
1313
_jupyter_server_base_url: null,
1414
}),
1515
});
@@ -67,8 +67,8 @@ var _HackyClientHandshakeModel = widgets.DOMWidgetModel.extend({
6767
_view_name: "_HackyClientHandshakeView",
6868
_model_module: "idom-client-jupyter",
6969
_view_module: "idom-client-jupyter",
70-
_model_module_version: "0.1.0",
71-
_view_module_version: "0.1.0",
70+
_model_module_version: "0.4.0",
71+
_view_module_version: "0.4.0",
7272
}),
7373
});
7474

notebooks/introduction.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@
122122
"name": "python",
123123
"nbconvert_exporter": "python",
124124
"pygments_lexer": "ipython3",
125-
"version": "3.9.0"
125+
"version": "3.7.7-final"
126126
}
127127
},
128128
"nbformat": 4,
129129
"nbformat_minor": 4
130-
}
130+
}

requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
black
2+
flake8
3+
pre-commit
4+
wheel
5+
twine
6+
jupyter_packaging

setup.py

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,65 +16,84 @@
1616
here = os.path.dirname(os.path.abspath(__file__))
1717

1818
log.set_verbosity(log.DEBUG)
19-
log.info('setup.py entered')
20-
log.info('$PATH=%s' % os.environ['PATH'])
19+
log.info("setup.py entered")
20+
log.info("$PATH=%s" % os.environ["PATH"])
2121

22-
name = 'idom_jupyter'
23-
LONG_DESCRIPTION = 'A client for IDOM implemented using Jupyter widgets'
22+
name = "idom_jupyter"
23+
LONG_DESCRIPTION = "A client for IDOM implemented using Jupyter widgets"
2424

2525
# Get idom_jupyter version
26-
version = get_version(pjoin(name, '_version.py'))
26+
version = get_version(pjoin(name, "_version.py"))
2727

28-
js_dir = pjoin(here, 'js')
28+
js_dir = pjoin(here, "js")
2929

3030
# Representative files that should exist after a successful build
3131
jstargets = [
32-
pjoin(js_dir, 'dist', 'index.js'),
32+
pjoin(js_dir, "dist", "index.js"),
3333
]
3434

3535
data_files_spec = [
36-
('share/jupyter/nbextensions/idom-client-jupyter', 'idom_jupyter/nbextension', '*.*'),
37-
('share/jupyter/labextensions/idom-client-jupyter', 'idom_jupyter/labextension', "**"),
38-
("share/jupyter/labextensions/idom-client-jupyter", '.', "install.json"),
39-
('etc/jupyter/nbconfig/notebook.d', '.', 'idom-client-jupyter.json'),
40-
("etc/jupyter/nbconfig", "jupyter-config", "**/*.json"),
36+
(
37+
"share/jupyter/nbextensions/idom-client-jupyter",
38+
"idom_jupyter/nbextension",
39+
"*.*",
40+
),
41+
(
42+
"share/jupyter/labextensions/idom-client-jupyter",
43+
"idom_jupyter/labextension",
44+
"**",
45+
),
46+
(
47+
"share/jupyter/labextensions/idom-client-jupyter",
48+
".",
49+
"install.json",
50+
),
51+
(
52+
"etc/jupyter/nbconfig/notebook.d",
53+
".",
54+
"idom-client-jupyter.json",
55+
),
56+
(
57+
"etc/jupyter/nbconfig",
58+
"jupyter-config",
59+
"**/*.json",
60+
),
4161
]
4262

43-
cmdclass = create_cmdclass('jsdeps', data_files_spec=data_files_spec)
44-
cmdclass['jsdeps'] = combine_commands(
45-
install_npm(js_dir, npm=['yarn'], build_cmd='build:prod'), ensure_targets(jstargets),
63+
cmdclass = create_cmdclass("jsdeps", data_files_spec=data_files_spec)
64+
cmdclass["jsdeps"] = combine_commands(
65+
install_npm(js_dir, npm=["yarn"], build_cmd="build:prod"),
66+
ensure_targets(jstargets),
4667
)
4768

4869
setup_args = dict(
4970
name=name,
5071
version=version,
51-
description='A client for IDOM implemented using Jupyter widgets',
72+
description="A client for IDOM implemented using Jupyter widgets",
5273
long_description=LONG_DESCRIPTION,
5374
include_package_data=True,
54-
install_requires=[
55-
'ipywidgets>=7.6.0', "idom>=0.20.1"
56-
],
75+
install_requires=["ipywidgets>=7.6.0", "idom>=0.20.1"],
5776
packages=find_packages(),
5877
zip_safe=False,
5978
cmdclass=cmdclass,
60-
author='Ryan Morshead',
61-
author_email='ryan.morshead@gmail.com',
62-
url='https://github.com/idom-team/idom-jupyter',
79+
author="Ryan Morshead",
80+
author_email="ryan.morshead@gmail.com",
81+
url="https://github.com/idom-team/idom-jupyter",
6382
keywords=[
64-
'ipython',
65-
'jupyter',
66-
'widgets',
83+
"ipython",
84+
"jupyter",
85+
"widgets",
6786
],
6887
classifiers=[
69-
'Development Status :: 4 - Beta',
70-
'Framework :: IPython',
71-
'Intended Audience :: Developers',
72-
'Intended Audience :: Science/Research',
73-
'Topic :: Multimedia :: Graphics',
74-
'Programming Language :: Python :: 3.6',
75-
'Programming Language :: Python :: 3.7',
76-
'Programming Language :: Python :: 3.8',
77-
'Programming Language :: Python :: 3.9',
88+
"Development Status :: 4 - Beta",
89+
"Framework :: IPython",
90+
"Intended Audience :: Developers",
91+
"Intended Audience :: Science/Research",
92+
"Topic :: Multimedia :: Graphics",
93+
"Programming Language :: Python :: 3.6",
94+
"Programming Language :: Python :: 3.7",
95+
"Programming Language :: Python :: 3.8",
96+
"Programming Language :: Python :: 3.9",
7897
],
7998
)
8099

0 commit comments

Comments
 (0)