21 from docutils.core
import publish_doctree
22 from docutils.parsers.rst
import directives
23 from docutils.parsers.rst
import roles
24 from docutils.parsers.rst.directives
import register_directive
25 from docutils.parsers.rst.directives.body
import CodeBlock
26 from docutils.parsers.rst.directives.misc
import Include
28 raise DataError(
"Using reStructuredText test data requires having "
29 "'docutils' module version 0.9 or newer installed.")
35 if not hasattr(doctree,
'_robot_data'):
36 doctree._robot_data = []
52 if 'robotframework' in self.arguments:
54 store.add_data(self.content)
58 register_directive(
'code', RobotCodeBlock)
59 register_directive(
'code-block', RobotCodeBlock)
60 register_directive(
'sourcecode', RobotCodeBlock)
63 relevant_directives = (RobotCodeBlock, Include)
66 @functools.wraps(directives.directive)
68 directive_class, messages = directive.__wrapped__(*args, **kwargs)
69 if directive_class
not in relevant_directives:
71 directive_class = (
lambda *args, **kwargs: [])
72 return directive_class, messages
75 @functools.wraps(roles.role)
77 role_function = role.__wrapped__(*args, **kwargs)
78 if role_function
is None:
79 role_function = (
lambda *args, **kwargs: [], [])
83 directives.directive = directive
88 doctree = publish_doctree(
90 source_path=rstfile.name,
92 'input_encoding':
'UTF-8',
96 return store.get_data()
def __init__(self, doctree)
def directive(*args, **kwargs)
def role(*args, **kwargs)
def read_rest_data(rstfile)