Skip to content

Commit eadbbab

Browse files
authored
Merge pull request #88 from jovyan/auto-gen-wrappers
Auto gen wrappers
2 parents b0f0891 + 5c9cb4e commit eadbbab

File tree

91 files changed

+12645
-44477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+12645
-44477
lines changed

.editorconfig

Lines changed: 0 additions & 37 deletions
This file was deleted.

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
*.egg-info/
22
.ipynb_checkpoints/
3+
.tern-project
4+
npm-debug.log
35
dist/
46
build/
57
*.py[cod]
@@ -10,3 +12,9 @@ pythreejs/static/
1012

1113
# OS X
1214
.DS_Store
15+
16+
17+
*_autogen.py
18+
*.autogen.js
19+
js/src/**/index.js
20+
pythreejs/**/__init__.py

README.md

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,61 @@
1-
pythreejs
2-
=========
1+
# pythreejs
32

4-
A Python / ThreeJS bridge utilizing the Jupyter widget infrastructure.
53

6-
![Screencast](/screencast.gif)
7-
8-
Getting Started
9-
---------------
4+
## Getting Started
105

116
### Try it online with [Binder](http://mybinder.org/)
127

138
[![Binder](http://mybinder.org/badge.svg)](http://mybinder.org:/repo/jovyan/pythreejs/notebooks/examples)
149

15-
Installation
16-
------------
10+
### Installation
1711

1812
Using pip:
1913

20-
```
14+
```bash
2115
pip install pythreejs
16+
jupyter nbextension install --py --symlink --sys-prefix pythreejs
2217
jupyter nbextension enable --py --sys-prefix pythreejs
2318
```
2419

20+
Note for developers: the `--symlink` argument on Linux or OS X allows one to
21+
modify the JavaScript code in-place. This feature is not available
22+
with Windows.
23+
2524
Using conda
2625

27-
```
28-
$ conda install -c conda-forge pythreejs
26+
```bash
27+
conda install -c conda-forge pythreejs
2928
```
3029

31-
For a development installation (requires npm):
3230

33-
```
34-
$ git clone https://github.com/jovyan/pythreejs.git
35-
$ cd pythreejs
36-
$ pip install -e .
37-
$ jupyter nbextension install --py --symlink --sys-prefix pythreejs
38-
$ jupyter nbextension enable --py --sys-prefix pythreejs
39-
```
31+
## Developers
4032

41-
Note for developers: the `--symlink` argument on Linux or OS X allows one to
42-
modify the JavaScript code in-place. This feature is not available
43-
with Windows.
33+
### Autogen
34+
35+
This is a _significant_ re-work of the pythreejs extension that introduces an "autogen" script that generates the majority of the ipython-widget code to wrap each of three.js's types. It also takes a different view towards the pythreejs API. Whereas pythreejs adds custom functionality to the classes, sometimes renaming, etc., this approach attempts to mimic the low-level three.js API as closely as possible, opening up the possibility for others to build utility libraries on top of this.
36+
37+
The autogen script, `generate-wrappers.js`, takes advantage of a config file `three-class-config.js` to auto-generate both javascript and python files to define the ipywidget wrappers for each three.js class. The generated javascript files will have `.autogen.js` as the extension. The generated python files have `_autogen.py` as their extension. The script uses the handlebars template system to generate the various code files.
38+
39+
The autogen solution allows for overriding the default behavior of the generated classes. E.g., if `Object3D.js` is present, then it will be loaded into the namespace as opposed to loading `Object3D.autogen.js`. It is up to the author of the override classe to decide whether to inherit behavior from the autogen class or not. Same goes for the python modules. This allows for writing custom methods on both the python and javascript side when needed.
40+
41+
The autogen script relies on a json-like config file (`three-class-config.js`) to describe the classes. Reasonable defaults should take care of most, but it allows specifying the base class, constructor args, etc. for each of the wrappers. A base version of this file can be generated by `generate-class-config.js`, but beware, it overwrites any customization to the config file that has already been done.
42+
43+
#### Setup
44+
45+
The relevant commands while working on the repository are included below. These are not meant to be run sequentially, but rather as a list of useful commands:
46+
47+
```bash
48+
# To perform initial dev setup, run:
49+
pip install -e .
50+
51+
# To re-generate autogen files, run:
52+
npm run autogen
53+
54+
# To build and install distribution files, run:
55+
npm run build
56+
jupyter nbextension install --py --symlink --sys-prefix pythreejs
57+
58+
# To clean out generated files, run:
59+
npm run clean
60+
61+
```

0 commit comments

Comments
 (0)