Prerequisites and Installation Steps

Prerequisites

This plugin requires JupyterLab installed under a Python3.6+ environment.

Note

Black (one of the most popular formatter) requires Python3.6+.

Also this project uses typing, a 3.6+ feature.

Installation Step 1 (Installing the plugin itself)

Option 1) With Pip

jupyter labextension install @ryantam626/jupyterlab_code_formatter
pip install jupyterlab_code_formatter
jupyter serverextension enable --py jupyterlab_code_formatter

Option 2) With Conda

conda install nodejs
jupyter labextension install @ryantam626/jupyterlab_code_formatter
conda install -c conda-forge jupyterlab_code_formatter
jupyter serverextension enable --py jupyterlab_code_formatter

Important

You will also need to install a code formatter for this plugin to work. The default formatter for Python are isort and black, and formatR for R. Installing these would be a good place to start.

Installation Step 2 (Installing a supported code formatter)

Python Code Formatters

Supported formatters are:

Install one of them via your favourite package management tool. For example, one of the following (these are not exhaustive!)

# Installing black and isort, the default python formatters of choice in this plugin
# ONLY ONE OF THESE WILL DO!!!!!!!!
pip install black isort
conda install black isort

R Code Formatters

Supported formatters are:

Install one of them via your favourite package management tool again. For example, via conda or via R directly.

Danger

You will also need to install the rpy2 Python package for this plugin to work!

Installation Step 3 (Restarting Jupyterlab)

If you have been following the above steps while Jupyterlab is already running, you will need to restart it for the changes to fully take effect.

Installation Step 4 (Configuring the plugin)

You might need to change the default formatter selection via configuration as shown in Changing Default Formatter, if you are unsure, continue reading in How To Use This Plugin.