Skip to content

Commit c13f014

Browse files
committed
Expose stable parsing API (robotframework#3373).
Documentation still mostly missing but robotframework#3293 covers that.
1 parent 765e18d commit c13f014

File tree

3 files changed

+25
-27
lines changed

3 files changed

+25
-27
lines changed

src/robot/api/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
* :func:`~robot.result.resultbuilder.ExecutionResult` factory method
4646
for reading execution results from XML output files and
4747
:class:`~robot.result.visitor.ResultVisitor` abstract class to ease
48-
further processing the results.
48+
further processing the results.
4949
:class:`~robot.result.visitor.ResultVisitor` can also be used as a base
5050
for pre-Rebot modifier that is taken into use with ``--prerebotmodifier``
5151
commandline option.
@@ -68,6 +68,10 @@
6868
"""
6969

7070
from robot.model import SuiteVisitor
71+
# FIXME: Anything else to expose from parsing? Update parsing docs above.
72+
from robot.parsing import (get_model, get_resource_model,
73+
get_tokens, get_resource_tokens,
74+
ModelTransformer, ModelVisitor)
7175
from robot.reporting import ResultWriter
7276
from robot.result import ExecutionResult, ResultVisitor
7377
from robot.running import TestSuite, TestSuiteBuilder

src/robot/parsing/__init__.py

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,37 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
# FIXME misleading maybe??
1716
"""Implements test data parsing.
1817
19-
Classes :class:`~.model.TestCaseFile`, :class:`~.model.TestDataDirectory`
20-
and :class:`~.model.ResourceFile` represented parsed test data. Objects
21-
of these classes can be modified and saved back to disk. In addition,
22-
a convenience factory function :func:`~.model.TestData` can be used to
23-
parse a test case file or directory to a corresponding object.
18+
Main entry points to parsing are the following:
2419
25-
Aforementioned classes and functions are part of the public API. It is
26-
recommended that they are imported through the :mod:`robot.api` package
27-
like in the example below.
20+
* :func:`~.lexer.get_tokens` and :func:`~.lexer.get_resource_tokens`
21+
for parsing test data to tokens.
2822
29-
This package is likely to change radically in Robot Framework 2.9. The main
30-
motivation for the planned changes is making the data easier to use for
31-
external tools that use these modules.
23+
* :func:`~.builders.get_model` and :func:`~.builders.get_resource_model` for
24+
parsing test data into a model represented as an abstract syntax tree (AST).
25+
26+
*TODO:* Document how to modify the returned model using
27+
:class:`~.model.ModelVisitor` and :class:`~.model.ModelTransformer`.
28+
Also mention that the model as well as tokens are part of the public API.
29+
30+
Like with rest of the public API, these functions and classes are exposed
31+
also via :module:`robot.api`.
32+
33+
The :module:`robot.parsing` package has been totally rewritten in Robot
34+
Framework 3.2 and all code using it needs to be updated. Depending on the
35+
use case, it may be possible to use the :func:`robot.running.TestSuiteBuilder`
36+
that has not changed instead.
3237
3338
Example
3439
-------
3540
3641
::
3742
38-
import sys
39-
from robot.api import TestData
40-
41-
def print_suite(suite):
42-
print 'Suite:', suite.name
43-
for test in suite.testcase_table:
44-
print '-', test.name
45-
for child in suite.children:
46-
print_suite(child)
47-
48-
suite = TestData(source=sys.argv[1])
49-
print_suite(suite)
43+
TODO
5044
"""
5145

5246
from .builders import get_model, get_resource_model
5347
from .lexer import get_tokens, get_resource_tokens, Token
54-
from .model import ModelTransformer
48+
from .model import ModelTransformer, ModelVisitor
5549
from .suitestructure import SuiteStructureBuilder, SuiteStructureVisitor

src/robot/parsing/model/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
from .blocks import (File, SettingSection, VariableSection, TestCaseSection,
1717
KeywordSection, CommentSection, TestCase, Keyword, ForLoop)
1818
from .statements import get_statements
19-
from .visitor import ModelTransformer
19+
from .visitor import ModelTransformer, ModelVisitor

0 commit comments

Comments
 (0)