21 from robot.running import (ResourceFileBuilder, TestLibrary, TestSuiteBuilder,
22 UserLibrary, UserErrorHandler)
23 from robot.utils import is_string, split_tags_from_doc, type_repr, unescape
26 from .datatypes
import TypeDoc
27 from .model
import LibraryDoc, KeywordDoc
34 _argument_separator =
'::'
43 doc_format=lib.doc_format,
48 libdoc.type_docs = self.
_get_type_docs_get_type_docs(libdoc.inits + libdoc.keywords,
58 path = library.replace(
'/', os.sep)
59 if os.path.exists(path):
60 return os.path.abspath(path)
64 return lib.doc
or f
"Documentation for library ``{lib.name}``."
67 if lib.init.arguments.maxargs:
75 kw.type_docs[arg.name] = {}
77 type_doc = TypeDoc.for_type(typ, custom_converters)
79 kw.type_docs[arg.name][
type_repr(typ)] = type_doc.name
80 type_docs.setdefault(type_doc, set()).add(kw.name)
81 for type_doc, usages
in type_docs.items():
82 type_doc.usages = sorted(usages, key=str.lower)
93 doc=self.
_get_doc_get_doc(res, name),
102 model = ResourceFileBuilder(process_curdir=
False).
build(path)
103 resource = UserLibrary(model)
104 return resource, resource.name
107 if os.path.isfile(path):
108 return os.path.normpath(os.path.abspath(path))
109 for dire
in [item
for item
in sys.path
if os.path.isdir(item)]:
110 candidate = os.path.normpath(os.path.join(dire, path))
111 if os.path.isfile(candidate):
112 return os.path.abspath(candidate)
113 raise DataError(f
"Resource file '{path}' does not exist.")
118 return f
"Documentation for resource file ``{name}``."
125 builder = TestSuiteBuilder(process_curdir=
False)
126 if os.path.basename(path).lower() ==
'__init__.robot':
127 path = os.path.dirname(path)
128 builder.included_suites = ()
129 builder.allow_empty_suite =
True
130 suite = builder.build(path)
131 return UserLibrary(suite.resource), suite.name
134 return f
"Documentation for keywords in suite ``{name}``."
143 return [self.
build_keywordbuild_keyword(kw)
for kw
in lib.handlers]
153 private=tags.robot(
'private'),
154 deprecated=doc.startswith(
'*DEPRECATED')
and '*' in doc[1:],
159 for name, value
in defaults.items():
161 value = re.sub(
r'[\\\r\n\t]',
lambda x: repr(str(x.group()))[1:-1], value)
163 defaults[name] = re.sub(
'^(?= )|(?<= )$|(?<= )(?= )',
r'\\', value)
169 result +=
r'%s\%s{%s}' % (match.before, match.identifier,
171 for item
in match.items:
174 return result + match.string
179 return doc, kw.tags + tags
182 if self.
_resource_resource
and not isinstance(kw, UserErrorHandler):
Documentation for a single keyword or an initializer.
Documentation for a library, a resource file or a suite file.
def __init__(self, resource=False)
def build_keyword(self, kw)
def _escape_variables(self, value)
def _escape_strings_in_defaults(self, defaults)
def _get_doc_and_tags(self, kw)
def build_keywords(self, lib)
def _normalize_library_path(self, library)
def _get_initializers(self, lib)
string _argument_separator
def _split_library_name_and_args(self, library)
def _get_type_docs(self, keywords, custom_converters)
def _import_resource(self, path)
def _find_resource_file(self, path)
def _get_doc(self, resource, name)
def _import_resource(self, path)
def _get_doc(self, resource, name)
def TestLibrary(name, args=None, variables=None, create_handlers=True, logger=LOGGER)
def type_repr(typ)
Return string representation for types.
def split_tags_from_doc(doc)
def search_variable(string, identifiers='$@&% *', ignore_errors=False)