Skip to content

Commit 030fd08

Browse files
committed
updated docloc plugin document with "help msg" function, added it to the example plugin (http)
1 parent 05a8096 commit 030fd08

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

documentation/plugins.rst

+6
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ To add a document location handler plugin, you need to implement a Python `"pack
2828

2929
#. the package must be named ``mmif_docloc_<SCHEME>``. For example, to implement a handler for ``s3`` scheme, the package name must be ``mmif_docloc_s3``. The prefix is important as it's used in the plugin discovery process from the core ``mmif-python`` modules.
3030
#. the top module of the package must have a function named ``resolve``. The function must take a single argument, which is a :class:`str` of the document location URI. The function must return a :class:`str` of the local file path. For example, if the document location is ``s3://mybucket/myfile.mp4``, a Python user should be able to to something like this;
31+
#. Optionally (but highly recommended), the top module also can provide another function named ``help``. The function must take no arguments and return a :class:`str` that explains how the input string to the ``resolve`` function should be formatted.
3132

3233
.. code-block:: python
3334
@@ -76,6 +77,11 @@ And the plugin code.
7677
else:
7778
raise ValueError(f'cannot handle document location scheme: {docloc}')
7879
80+
def help():
81+
return "location format: `<DOCUMENT_ID>.video`"
82+
83+
84+
7985
Bulit-in Document Location Scheme Plugins
8086
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8187

mmif_docloc_http/__init__.py

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ def resolve(docloc):
1010
raise ValueError(f'cannot handle document location scheme: {docloc}')
1111
except urllib.error.URLError as e:
1212
raise e
13+
14+
15+
def help():
16+
return "location must be a URL string."

0 commit comments

Comments
 (0)