jupyterlab_code_formatter icon indicating copy to clipboard operation
jupyterlab_code_formatter copied to clipboard

Feat: use entrypoints to extend to other formatters

Open agoose77 opened this issue 3 years ago • 3 comments

This would:

  • Allow independent releases of the various formatter integrations
  • Allow for new formatter integrations by other developers

agoose77 avatar Jan 04 '22 13:01 agoose77

Sorry for the late reply, was extremely burnt out and just switched off.

I am not quite sure what you mean here, could you please elaborate?

ryantam626 avatar Apr 18 '22 23:04 ryantam626

like SQL?

leihao-git avatar Oct 28 '22 07:10 leihao-git

Oh, I missed this! Sorry to hear that you've been burnt out Ryan, hope you've been able to take a break of some kind :/

Let's say that I wanted to use clang-format (or some other tool). If this plugin supported entry-points, it would be able to discover additional third-party formatters that provided these entry-points. This would mean that you'd end up maintaining the entry-point interface, rather than N plugin implementations. Effectively, this package just becomes a way of launching a formatted and applying the result.

E.g.

pyproject.toml

[project.entry-points.jupyterlab-code-formatter]
isort = "isort-formatter:plugin"

jupyterlab_code_formatter/plugins.py

import importlib.metadata

def load_formatters():
    entry_points = importlib.metadata.entry_points(group="jupyterlab-code-formatter")
    return {
        ep.name: ep.load() for ep in entry_points
    }

agoose77 avatar Oct 28 '22 08:10 agoose77