I have a working prototype of this in https://github.com/fastai/nbdev/pull/1157. @muellerzr's nbdev-extensions package is a great example of how a processor plugin would be created and packaged. Here's a rough draft of potential docs that also describes how it works at a high level:
Creating a processor plugin
To develop your own processor plugin, sub-class Processor and override any methods you need to. Check out the nbdev.processors module for examples -- all of nbdev's processing is implemented with pluggable processors.
Once its ready, upload your package to PyPI and/or conda.
For example, the nbdev-extensions package provides the nbdev_extensions.codenotes.NoteExportProc processor, which allows you to annotate code snippets with a new #| explain directive.
Using a processor plugin
First install the package containing the processor. Continuing with the nbdev-extensions example which is hosted on PyPI:
pip install nbdev-extensions
Add the import path to your processor under the procs key of your settings.ini. The import path should follow the same syntax as setuptools console scripts (without the name and equals sign). For example:
procs = nbdev_extensions.codenotes:NoteExportProc
The processor will now be applied in your nbdev project!
I have a working prototype of this in https://github.com/fastai/nbdev/pull/1157. @muellerzr's nbdev-extensions package is a great example of how a processor plugin would be created and packaged. Here's a rough draft of potential docs that also describes how it works at a high level:
Creating a processor plugin
To develop your own processor plugin, sub-class
Processor
and override any methods you need to. Check out thenbdev.processors
module for examples -- all of nbdev's processing is implemented with pluggable processors.Once its ready, upload your package to PyPI and/or conda.
For example, the nbdev-extensions package provides the
nbdev_extensions.codenotes.NoteExportProc
processor, which allows you to annotate code snippets with a new#| explain
directive.Using a processor plugin
First install the package containing the processor. Continuing with the nbdev-extensions example which is hosted on PyPI:
Add the import path to your processor under the
procs
key of yoursettings.ini
. The import path should follow the same syntax as setuptools console scripts (without the name and equals sign). For example:The processor will now be applied in your nbdev project!