1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
Referencer Python Plugin Interface
==================================
Last updated 2008-01-05 by jcspray
Info list
-----------
Every plugin must create a python list called referencer_plugin_info, which
contains [key, value] lists for keys including the following:
"longname"
- Mandatory for all plugins: a description, such as "Martian cat farmer"
"action"
- Mandatory for document_action plugins, a UI item eg "Farm this cat"
"tooltip"
- Mandatory for document_action plugins, a description of
the UI item eg "Farms the selected cat"
"icon"
- Optional for document_action plugins, such as "cat_shovel.png"
Icons are looked for in the referencer data directory.
If the icon is not specified or not found then a default
icon is used instead.
Capability list
---------------
Every plugin must create a python list called referencer_plugin_capabilities
which contains strings including:
"doi"
"pubmed"
"arxiv"
- The above three are metadata fetchers. A fetcher plugin can
have more than one of them. For instance, pubmed.py supports
both doi and pubmed.
"document_action"
- A document action plugin
Metadata plugins
----------------
Implement a function called resolve_metadata (doc, method) which returns a boolean.
Args:
doc: a referencer.document, use get_field and set_field methods
to get ID codes and fill out the metadata
method: a string indicating what kind of ID should be tried,
from the list of capabilities that the plugin listed
in referencer_plugin_info
Return true if the metadata was retrieved successfully, otherwise false.
See pubmed.py for an example.
Document action plugins
-----------------------
Implement a function called do_action (docs) which returns a boolean.
Args:
docs: a python list of referencer.document instances, where
the action is to be performed on each of them.
Return true if the action completed without problems, otherwise false.
See lyx.py for an example.
Exceptions
----------
Passing an exception up to the caller on the C++ is taken as a sign that
something really unexpected has happened that the user needs to know
about. For instance, if a DOI can't be resolved to metadata, DO NOT throw
an exception, simply return false from resolve_metadata. However, if
the user invokes a document action that's somehow impossible (for example
trying to cite something in lyx while lyx isn't running), that can
be an exception the propagates all the way to the C++ side and the user.
|