Skip to content

Commit 93f985d

Browse files
committed
Improved documentation
1 parent 852adfe commit 93f985d

File tree

1 file changed

+44
-8
lines changed

1 file changed

+44
-8
lines changed

README.rst

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,65 @@
1-
Python Library Core
2-
===================
1+
PythonLibraryCore
2+
=================
33

44
Tools to ease creating larger test libraries for `Robot Framework`_ using
5-
Python.
5+
Python. The Robot Framework `hybrid`_ and `dynamic library API`_ gives more
6+
flexibility for library than the static library API, but they also sets requirements
7+
for libraries which needs to be implemented in the library side. PythonLibCore
8+
eases the problem by providing simpler interface and handling all the requirements
9+
towards the Robot Framework library APIs.
610

7-
Code is stable and version 1.0 is already used by SeleniumLibrary_.
8-
Better documentation and packaging still to do.
11+
Code is stable and version 1.0 is already used by SeleniumLibrary_ and
12+
WhiteLibrary_. The version 2.0 support changes in the Robot Framework
13+
3.2.
914

1015
.. image:: https://github.com/robotframework/PythonLibCore/workflows/CI/badge.svg?branch=master
1116
:target: https://github.com/robotframework/PythonLibCore
1217

18+
Usage
19+
-----
20+
There are two ways to use PythonLinCore, either by `HybridCore` or by using `DynamicCore`.
21+
`HybridCore` provides support for the hybrid library API and `DynamicCore` provides support
22+
for dynamic library API. Consult the Robot Framework `User Guide`_, for choosing the
23+
correct API for library.
24+
25+
Regardless which library API is chosen, both have similar requirements.
26+
27+
1) Library must inherit either the `HybridCore` or `DynamicCore`.
28+
2) Library keywords must be decorated with Robot Framework `@keyword`_ decorator.
29+
3) Provide a list of class instances implementing keywords to `library_components` argument in the `HybridCore` or `DynamicCore` `__init__`.
30+
31+
It is also possible implement keywords in the library main class, by marking method with
32+
`@keyword` as keywords. It is not requires pass main library instance in the
33+
`library_components` argument.
34+
35+
All keyword, also keywords implemented in the classes outside of the main library are
36+
available in the library instance as methods. This automatically publish library keywords
37+
in as methods in the Python public API.
38+
39+
The example in below demonstrates how the PythonLibCore can be used with a library.
40+
1341
Example
1442
-------
1543

1644
.. sourcecode:: python
1745

1846
"""Main library."""
1947

20-
from robotlibcore import HybridCore
48+
from robotlibcore import DynamicCore
2149

2250
from mystuff import Library1, Library2
2351

2452

25-
class MyLibrary(HybridCore):
53+
class MyLibrary(DynamicCore):
2654
"""General library documentation."""
2755

2856
def __init__(self):
2957
libraries = [Library1(), Library2()]
30-
HybridCore.__init__(self, libraries)
58+
DynamicCore.__init__(self, libraries)
3159

60+
@keyword
61+
def keyword_in_main(self):
62+
pass
3263

3364
.. sourcecode:: python
3465

@@ -65,3 +96,8 @@ Example
6596

6697
.. _Robot Framework: http://robotframework.org
6798
.. _SeleniumLibrary: https://github.com/robotframework/SeleniumLibrary/
99+
.. _WhiteLibrary: https://pypi.org/project/robotframework-whitelibrary/
100+
.. _hybrid: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#hybrid-library-api
101+
.. _dynamic library API: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#dynamic-library-api
102+
.. _User Guide: https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#creating-test-libraries
103+
.. _@keyword: https://github.com/robotframework/robotframework/blob/master/src/robot/api/deco.py

0 commit comments

Comments
 (0)