18 from itertools
import chain
22 from robot.utils import getshortdoc, Sortable, setter
24 from .htmlutils
import DocFormatter, DocToHtml, HtmlToText
25 from .writer
import LibdocWriter
26 from .output
import LibdocOutput, get_generation_time
32 def __init__(self, name='', doc='', version='', type='LIBRARY', scope='TEST',
33 doc_format='ROBOT', source=None, lineno=-1):
56 return '\n'.join(line
if line.strip() !=
'%TOC%' else toc
57 for line
in doc.splitlines())
60 entries = re.findall(
r'^\s*=\s+(.+?)\s+=\s*$', doc, flags=re.MULTILINE)
62 entries.append(
'Importing')
64 entries.append(
'Keywords')
65 return '\n'.join(
'- `%s`' % entry
for entry
in entries)
69 return format
or 'ROBOT'
94 return Tags(chain.from_iterable(kw.tags
for kw
in self.
keywordskeywordskeywords))
96 def save(self, output=None, format='HTML', theme=None):
102 self.
_doc_doc = formatter.html(self.
docdocdoc, intro=
True)
106 item.shortdoc = item.shortdoc
107 item.doc = formatter.html(item.doc)
110 if type_doc.type == type_doc.STANDARD:
112 if not type_doc.doc.startswith(
'<p>'):
113 type_doc.doc =
DocToHtml(
'ROBOT')(type_doc.doc)
115 type_doc.doc = formatter.html(type_doc.doc)
121 'name': self.
namename,
123 'version': self.
versionversion,
125 'type': self.
typetype,
126 'scope': self.
scopescope,
128 'source': self.
sourcesource,
129 'lineno': self.
linenolineno,
131 'inits': [init.to_dictionary()
for init
in self.
initsinitsinits],
133 if include_private
or not kw.private],
139 data[
'theme'] = theme.lower()
143 enums = sorted(t
for t
in types
if t.type ==
'Enum')
144 typed_dicts = sorted(t
for t
in types
if t.type ==
'TypedDict')
146 'enums': [t.to_dictionary(legacy=
True)
for t
in enums],
147 'typedDicts': [t.to_dictionary(legacy=
True)
for t
in typed_dicts]
150 def to_json(self, indent=None, include_private=True, theme=None):
151 data = self.
to_dictionaryto_dictionary(include_private, theme)
152 return json.dumps(data, indent=indent)
158 def __init__(self, name='', args=None, doc='', shortdoc='', tags=(), private=
False,
159 deprecated=
False, source=
None, lineno=-1, parent=
None):
161 self.
argsargs = args
or ArgumentSpec()
180 if self.
parentparent
and self.
parentparent.doc_format ==
'HTML':
195 return self.
namename.lower()
199 'name': self.
namename,
203 'tags': list(self.
tagstags),
204 'source': self.
sourcesource,
205 'lineno': self.
linenolineno
208 data[
'private'] =
True
210 data[
'deprecated'] =
True
216 'types': arg.types_reprs,
217 'typedocs': self.
type_docstype_docs.get(arg.name, {}),
218 'defaultValue': arg.default_repr,
220 'required': arg.required,
Documentation for a single keyword or an initializer.
def _doc_to_shortdoc(self)
def _arg_to_dict(self, arg)
def shortdoc(self, shortdoc)
def __init__(self, name='', args=None, doc='', shortdoc='', tags=(), private=False, deprecated=False, source=None, lineno=-1, parent=None)
Documentation for a library, a resource file or a suite file.
def inits(self, inits)
Initializer docs as :class:~KeywordDoc instances.
def doc_format(self, format)
def _get_data_types(self, types)
def _process_keywords(self, kws)
def to_dictionary(self, include_private=False, theme=None)
def type_docs(self, type_docs)
def _create_toc(self, doc)
def keywords(self, kws)
Keyword docs as :class:~KeywordDoc instances.
def __init__(self, name='', doc='', version='', type='LIBRARY', scope='TEST', doc_format='ROBOT', source=None, lineno=-1)
def save(self, output=None, format='HTML', theme=None)
def to_json(self, indent=None, include_private=True, theme=None)
def convert_docs_to_html(self)
def write(msg, level='INFO', html=False)
Writes the message to the log file using the given level.
def get_generation_time()
Return a timestamp that honors SOURCE_DATE_EPOCH.
def LibdocWriter(format=None, theme=None)
def getshortdoc(doc_or_item, linesep='\n')