16 from inspect
import cleandoc
22 from .model
import LibraryDoc, KeywordDoc
36 libdoc.keywords = self.
_keywords_keywords(doc)
40 text = doc.getRawCommentText()
41 return cleandoc(text).rstrip()
44 return self.
_get_attr_get_attr(doc,
'VERSION')
47 scope = self.
_get_attr_get_attr(doc,
'SCOPE', upper=
True)
48 return {
'TESTSUITE':
'test suite',
49 'GLOBAL':
'global'}.get(scope,
'test suite')
52 return self.
_get_attr_get_attr(doc,
'DOC_FORMAT', upper=
True)
55 name =
'ROBOT_LIBRARY_' + name
56 for field
in doc.fields():
57 if field.name() == name
and field.isPublic():
58 value = field.constantValue()
60 value =
normalize(value, ignore=
'_').upper()
65 inits = [self.
_keyword_doc_keyword_doc(init)
for init
in doc.constructors()]
66 if len(inits) == 1
and not inits[0].args:
71 return [self.
_keyword_doc_keyword_doc(m)
for m
in doc.methods()]
83 params = method.parameters()
86 names = [p.name()
for p
in params]
88 names[-1] =
'*' + names[-1]
90 names[-1] =
'**' + names[-1]
91 if len(params) > 1
and self.
_is_varargs_is_varargs(params[-2]):
92 names[-2] =
'*' + names[-2]
96 return (param.typeName().startswith(
'java.util.List')
97 or param.type().dimension() ==
'[]')
100 return param.typeName().startswith(
'java.util.Map')
111 from com.sun.tools.javadoc
import JavadocTool, Messager, ModifierFilter
112 from com.sun.tools.javac.util
import List, Context
113 from com.sun.tools.javac.code.Flags
import PUBLIC
115 raise DataError(
"Creating documentation from Java source files "
116 "requires 'tools.jar' to be in CLASSPATH.")
118 Messager.preRegister(context,
'libdoc')
119 jdoctool = JavadocTool.make0(context)
120 filter = ModifierFilter(PUBLIC)
121 java_names = List.of(path)
122 if JAVA_VERSION < (1, 8):
123 root = jdoctool.getRootDocImpl(
'en',
'utf-8', filter, java_names,
124 List.nil(),
False, List.nil(),
125 List.nil(),
False,
False,
True)
127 root = jdoctool.getRootDocImpl(
'en',
'utf-8', filter, java_names,
128 List.nil(), List.nil(),
False, List.nil(),
129 List.nil(),
False,
False,
True)
130 return root.classes()[0]
Used when variable does not exist.
def _get_doc_format(self, doc)
def _initializers(self, doc)
def _get_keyword_arguments(self, method)
def _get_attr(self, doc, name, upper=False)
def _keyword_doc(self, method)
def _get_scope(self, doc)
def _is_kwargs(self, param)
def _get_version(self, doc)
def _is_varargs(self, param)
def ClassDoc(path)
Process the given Java source file and return ClassDoc instance.
def printable_name(string, code_style=False)
Generates and returns printable name from the given string.
def normalize(string, ignore=(), caseless=True, spaceless=True)
Normalizes given string according to given spec.
def split_tags_from_doc(doc)