GithubHelp home page GithubHelp logo

isabella232 / mimerender-cookiecutter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jupyterlab/mimerender-cookiecutter

0.0 0.0 0.0 150 KB

A cookiecutter for rendering MIME type based output

License: Creative Commons Zero v1.0 Universal

JavaScript 34.57% CSS 0.61% Python 64.82%

mimerender-cookiecutter's Introduction

mimerender-cookiecutter

A cookiecutter template for creating a JupyterLab and Jupyter Notebook extension for rendering specific mime types and file extensions.

Examples

Usage

Install cookiecutter:

pip install cookiecutter

Use cookiecutter to generate a package:

cookiecutter https://github.com/jupyterlab/mimerender-cookiecutter

Prompts

The cookiecutter will prompt you with the following questions and generate a project according to your responses:

  • author_name: Your full name. This will be used in the generated Python and npm packages.
  • author_email: Your email address. This will be used in the generated Python and npm packages.
  • mime_type: A valid mime type (e.g. application/json, application/geo+json). This will be used to render output data of this mime type with your extension.
  • mime_short_name: A display name (no spaces) for your mime type (e.g. JSON, GeoJSON). This will be used in the generated Python and npm packages, README, and class names.
  • file_type: OPTIONAL A valid file type (e.g. json, geojson). This will be used to open files of this type with your extension.
  • extension_name: Your JupyterLab and Jupyter Notebook extension name (e.g. jupyerlab_json, jupyerlab_geojson).

Project structure

The project is divided into 2 top-level directories, one for each extension (lab and notebook).

In most cases, you will only need to edit the OutputWidget._render method in labextension/src/output.js (for rendering output data of a specific mime type) and the DocWidget.onUpdateRequest method in labextension/src/doc.js (if your extension should render files of a specific type).

  • extension_name
    • extension_name: The Python package
      • static: Compiled Javascript for the notebook extension.
      • __init__.py: Exports paths and metadata of lab and notebook extensions and exports an optional display method that can be imported into a notebook and used to easily display data using this renderer
    • src - The extension source.
      • embed.js: Entry point for embedded widget
      • extension.js: Integration point with Jupyter Notebook
      • index.js: Entry point for the Jupyter Notebook extension
      • plugin.js: Entry point for the JupyterLab extension
      • renderer.js: Methods for rendering output data of mime_type defined in prompts

Workflow

This cookiecutter will change over time to adapt to API changes and best practices, so you should be able to rebase your extension from an updated version of the cookiecutter. The following is the recommended workflow:

workflow

  • Create a branch called cookiecutter that will serve as the base for another branch called develop. All feature branches shoud be based on develop and merged into master.
  • When a new version of mimerender-cookiecutter is available:
    • Checkout cookiecutter branch: git checkout cookiecutter
    • Re-run the cookiecutter command from the repository root: cookiecutter https://github.com/jupyterlab/mimerender-cookiecutter [--checkout BRANCH_NAME] --output-dir .. --config-file .cookiecutter.yaml --no-input --overwrite-if-exists
      • --checkout is optional and specifies a branch of mimerender-cookiecutter to checkout (e.g. react).
      • --output-dir .. allows us to run the cookiecutter in the repo root vs. the parent directory because cookiecutter will always render output in a child directory of the output-dir.
      • --config-file .cookiecutter.yaml will run the cookiecutter with the original inputs which are persisted to .cookiecutter.yaml in the repo root.
      • --no-input will skip the cookiecutter prompts.
      • --overwrite-if-exists will replace our previous cookiecutter output with the most up-to-date output.
    • Commit these changes to cookiecutter with a message like "mimerender-cookiecutter [VERSION_NUMBER]": git commit -m "mimerender-cookiecutter [VERSION_NUMBER]"
    • Checkout the develop branch: git checkout develop
    • Rebase it from cookiecutter: git rebase cookiecutter
      • You may encounter some merge conflicts, so resolve them and complete the rebase using git rebase --continue
    • Publish a new version of your extension by following the instructions in RELEASE.md.

Package names

We suggest that extension names start with jupyterlab_ and use underscores if needed to improve readability, such as jupyterlab_myextension.

mimerender-cookiecutter's People

Contributors

blink1073 avatar ellisonbg avatar gnestor avatar jasongrout avatar jzf2101 avatar vidartf avatar zsailer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.