@@ -94,6 +94,52 @@ Example
9494 pass
9595
9696
97+ Plugin API
98+ ----------
99+ It is possible to create plugin API to a library by using PythonLibCore. This allows extending library
100+ with external Python classes. Plugins can be imported during library import time, example by defining argumet
101+ in library `__init__ ` which allows defining the plugins. It is possible to define multiple plugins, by seperating
102+ plugins with with comma. Also it is possible to provide arguments to plugin by seperating arguments with
103+ semicolon.
104+
105+
106+ .. sourcecode :: python
107+
108+ from robot.api.deco import keyword # noqa F401
109+
110+ from robotlibcore import DynamicCore, PluginParser
111+
112+ from mystuff import Library1, Library2
113+
114+
115+ class PluginLib(DynamicCore):
116+
117+ def __init__(self, plugins):
118+ plugin_parser = PluginParser()
119+ libraries = [Library1(), Library2()]
120+ parsed_plugins = plugin_parser.parse_plugins(plugins)
121+ libraries.extend(parsed_plugins)
122+ DynamicCore.__init__(self, libraries)
123+
124+
125+ When plugin class can look like this:
126+
127+ .. sourcecode :: python
128+
129+ class MyPlugi:
130+
131+ @keyword
132+ def plugin_keyword(self):
133+ return 123
134+
135+ Then Library can be imported in Robot Framework side like this:
136+
137+ .. sourcecode :: bash
138+
139+ Library ${CURDIR}/PluginLib.py plugins=${CURDIR}/MyPlugin.py
140+
141+
142+
97143.. _Robot Framework : http://robotframework.org
98144.. _SeleniumLibrary : https://github.com/robotframework/SeleniumLibrary/
99145.. _WhiteLibrary : https://pypi.org/project/robotframework-whitelibrary/
0 commit comments