Skip to content

Commit acc1304

Browse files
committed
plugin management docstrings
1 parent f7d923a commit acc1304

2 files changed

Lines changed: 55 additions & 5 deletions

File tree

‎paths_cli/plugin_management.py‎

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@ class PluginRegistrationError(RuntimeError):
88

99
# TODO: make more generic than OPS (requires_ops => requires_lib)
1010
class Plugin(object):
11-
"""Generic OPS plugin object"""
12-
def __init__(self, requires_ops, requires_cli):
13-
self.requires_ops = requires_ops
11+
"""Generic plugin object
12+
13+
parameters
14+
----------
15+
requires_lib: tuple
16+
tuple representing the minimum allowed version of the underlying
17+
library
18+
requires_cli: tuple
19+
tuple representing hte minimum allowed version of the command line
20+
interface application
21+
"""
22+
def __init__(self, requires_lib, requires_cli):
23+
self.requires_lib = requires_lib
1424
self.requires_cli = requires_cli
1525
self.location = None
1626
self.plugin_type = None
@@ -31,8 +41,33 @@ def attach_metadata(self, location, plugin_type):
3141
self.plugin_type = plugin_type
3242

3343

44+
class OPSPlugin(Plugin):
45+
"""Generic OPS plugin object.
46+
47+
Really just to rename ``requires_lib`` to ``requires_ops``.
48+
"""
49+
def __init__(self, requires_ops, requires_cli):
50+
super(OPSPlugin, self).__init__(requires_ops, requires_cli)
51+
52+
@property
53+
def requires_ops(self):
54+
return self.requires_lib
55+
56+
3457
class OPSCommandPlugin(Plugin):
35-
"""Plugin for subcommands to the OPS CLI"""
58+
"""Plugin for subcommands to the OPS CLI
59+
60+
Parameters
61+
----------
62+
command: :class:`click.Command`
63+
the ``click``-wrapped command for this command
64+
section: str
65+
the section of the help where this command should appear
66+
requires_ops: tuple
67+
the minimum allowed version of OPS
68+
requires_cli: tuple
69+
the minimum allowed version of the OPS CLI
70+
"""
3671
def __init__(self, command, section, requires_ops=(1, 0),
3772
requires_cli=(0, 4)):
3873
self.command = command
@@ -69,6 +104,16 @@ class CLIPluginLoader(object):
69104
3 can depend on the specific instance created. By default, it looks for
70105
instances of :class:`.Plugin` (given as ``plugin_class``) but the
71106
``isinstance`` check can be overridden in subclasses.
107+
108+
Parameters
109+
----------
110+
plugin_type : Literal["file", "namespace"]
111+
the type of file
112+
search_path : str
113+
the directory or namespace to search for plugins
114+
plugin_class: type
115+
plugins are identified as instances of this class (override in
116+
``_is_my_plugin``)
72117
"""
73118
def __init__(self, plugin_type, search_path, plugin_class=Plugin):
74119
self.plugin_type = plugin_type
@@ -111,6 +156,9 @@ class FilePluginLoader(CLIPluginLoader):
111156
----------
112157
search_path : str
113158
path to the directory that contains plugins (OS-dependent format)
159+
plugin_class: type
160+
plugins are identified as instances of this class (override in
161+
``_is_my_plugin``)
114162
"""
115163
def __init__(self, search_path, plugin_class):
116164
super().__init__(plugin_type="file", search_path=search_path,
@@ -147,6 +195,9 @@ class NamespacePluginLoader(CLIPluginLoader):
147195
----------
148196
search_path : str
149197
namespace (dot-separated) where plugins can be found
198+
plugin_class: type
199+
plugins are identified as instances of this class (override in
200+
``_is_my_plugin``)
150201
"""
151202
def __init__(self, search_path, plugin_class):
152203
super().__init__(plugin_type="namespace", search_path=search_path,

‎paths_cli/tests/test_cli.py‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
from click.testing import CliRunner
44

55
from paths_cli.cli import *
6-
# from paths_cli.plugin_management import OPSPlugin
76
from .null_command import NullCommandContext
87

98

0 commit comments

Comments
 (0)