18 from urllib
import quote
20 from urllib.parse
import quote
30 def write(self, libdoc, output):
39 formatter =
DocFormatter(libdoc.keywords, libdoc.doc, libdoc.doc_format)
43 self.
_output_output.
write(
'<script type="text/javascript">\n')
60 'version': libdoc.version,
61 'named_args': libdoc.named_args,
62 'scope': libdoc.scope,
66 'all_tags': tuple(libdoc.all_tags),
67 'contains_tags': bool(libdoc.all_tags)
78 'shortdoc':
' '.join(kw.shortdoc.splitlines()),
79 'tags': tuple(kw.tags),
88 _header_regexp = re.compile(
r'<h([234])>(.+?)</h\1>')
92 _name_regexp = re.compile(
'`(.+?)`')
94 def __init__(self, keywords, introduction, doc_format='ROBOT'):
97 robot_format=doc_format ==
'ROBOT')
101 'introduction':
'Introduction',
102 'library introduction':
'Introduction',
103 'importing':
'Importing',
104 'library importing':
'Importing',
105 'shortcuts':
'Shortcuts',
106 'keywords':
'Keywords'
109 targets[kw.name] = kw.name
112 targets[header] = header
117 for line
in introduction.splitlines():
118 match = headers.match(line)
124 for key, value
in targets.items())
128 return quote(value.encode(
'UTF-8'), safe=
"-_.!~*'()")
130 def html(self, doc, intro=False):
133 doc = self.
_header_regexp_header_regexp.sub(
r'<h\1 id="\2">\2</h\1>', doc)
137 name = match.group(1)
139 return '<a href="#%s" class="name">%s</a>' % (self.
_targets_targets[name], name)
140 return '<span class="name">%s</span>' % name
150 return {
'ROBOT': html_format,
155 raise DataError(
"Invalid documentation format '%s'." % doc_format)
158 return '<p style="white-space: pre-wrap">%s</p>' %
html_escape(doc)
161 return '<div style="margin: 0">%s</div>' % doc
165 from docutils.core
import publish_parts
167 raise DataError(
"reST format requires 'docutils' module to be installed.")
168 parts = publish_parts(doc, writer_name=
'html',
169 settings_overrides={
'syntax_highlight':
'short'})
170 return self.
_format_html_format_html(parts[
'html_body'])
Used when variable does not exist.
def _get_formatter(self, doc_format)
def _format_html(self, doc)
def _format_rest(self, doc)
def _format_text(self, doc)
def __init__(self, doc_format)
def _get_keywords(self, keywords)
def __init__(self, doc_formatter)
def convert(self, libdoc)
def _convert_keyword(self, kw)
def write(self, libdoc, output)
def __init__(self, output, libdoc)
def html_escape(text, linkify=True)
def get_timestamp(daysep='', daytimesep=' ', timesep=':', millissep='.')