Plugin architecture

General architecture

Papis uses the package stevedore for general plugin management.

The only papis module invoking stevedore should be papis/plugin.py.

The different plugins in papis like papis.command, papis.exporter etc. define a so-called ExtensionManager which loads various objects that have been declared in a python package somewhere.

For example, the yaml exporter is defined as

def exporter(documents: List[papis.document.Document]) -> str:
    string = yaml.dump_all(
        [papis.document.to_dict(document) for document in documents],
        allow_unicode=True)
    return str(string)

and declared in setup.py as

setup(
    ...
    entry_points={
        'papis.exporter': [
            'bibtex=papis.bibtex:exporter',
            'json=papis.json:exporter',
            'yaml=papis.yaml:exporter',
        ],
    ...
)

and the exporter can be used as in the code below

import papis.plugin
extension_manager = papis.plugin.get_extension_manager("papis.exporter")
# yaml_exporter is the function defined above
yaml_exporter = extension_manager["yaml"].plugin

yaml_string = yaml_exporter(mydocs)

Now a developer is able to write another exporter in some package and install the package in the system. The extension_manager will be able to access the provided functions in the package if they have been declared in the entry points of the setup.py script of the named package.

Exporter

TO DOCUMENT

Command

TO DOCUMENT

Importer

TO DOCUMENT

Explore

TO DOCUMENT