Skip to content

A node package for generating jupyter widget definitions from a JSON schema

License

Notifications You must be signed in to change notification settings

vidartf/widget-gen

Repository files navigation

widget-gen

Npm version Travis build status codecov

This is a utility library for auto-generating jupyter widget definitions based on the synchronization state. Any bussiness logic will have to be added on top, but this utility can help with:

  • Bootstrapping development
  • Keeping the different definitions (kernels + frontend) in sync

The last point is best accomplished by using the auto-generated definitions as base classes for the classes that actually add the business logic.

It can read (parse) widget definitions from:

  • A custom JSON schema-like format
  • Python widgets based on ipywidgets

And then output corresponding code in the following languages:

  • Python
  • ES5 Javascript
  • ES6 Javascript
  • Typescript

Installation

npm install [-g] widget-gen

Usage

> widgetgen --help
  Usage: main [options] <file> [languages...]

  Options:

    -V, --version                output the version number
    -p, --parser [parser]        The name of the parser to use, either "json" or "python".
    -o, --outputdir [outputdir]  The output directory.
    -t, --template [template]    a template file to use.
    -e, --extension [extension]  The file extension to use for the output.
    -h, --help                   output usage information

Extending language support

To add support for other output languages, you need to add another Writer class. You can either do this by inherting the base Writer class, having full control of the process, or you can inherit the TemplateWriter class that will use Nunjucks templates for creating output.

About

A node package for generating jupyter widget definitions from a JSON schema

Resources

License

Stars

Watchers

Forks

Packages

No packages published