MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / HTMLDoc

Class HTMLDoc

tools/python-3.11.9-amd64/Lib/pydoc.py:580–1181  ·  view source on GitHub ↗

Formatter class for HTML documentation.

Source from the content-addressed store, hash-verified

578 repr_unicode = repr_string
579
580class HTMLDoc(Doc):
581 """Formatter class for HTML documentation."""
582
583 # ------------------------------------------- HTML formatting utilities
584
585 _repr_instance = HTMLRepr()
586 repr = _repr_instance.repr
587 escape = _repr_instance.escape
588
589 def page(self, title, contents):
590 """Format an HTML page."""
591 return '''\
592<!DOCTYPE html>
593<html lang="en">
594<head>
595<meta charset="utf-8">
596<title>Python: %s</title>
597</head><body>
598%s
599</body></html>''&#x27; % (title, contents)
600
601 def heading(self, title, extras=''):
602 """Format a page heading."""
603 return ''&#x27;
604<table class="heading">
605<tr class="heading-text decor">
606<td class="title">&nbsp;<br>%s</td>
607<td class="extra">%s</td></tr></table>
608 ''' % (title, extras or '&nbsp;&#x27;)
609
610 def section(self, title, cls, contents, width=6,
611 prelude='', marginalia=None, gap='&nbsp;'):
612 """Format a section with a heading."""
613 if marginalia is None:
614 marginalia = '<span class="code">' + '&nbsp;' * width + '</span>'
615 result = ''&#x27;<p>
616<table class="section">
617<tr class="decor %s-decor heading-text">
618<td class="section-title" colspan=3>&nbsp;<br>%s</td></tr>
619 ''&#x27; % (cls, title)
620 if prelude:
621 result = result + ''&#x27;
622<tr><td class="decor %s-decor" rowspan=2>%s</td>
623<td class="decor %s-decor" colspan=2>%s</td></tr>
624<tr><td>%s</td>''&#x27; % (cls, marginalia, cls, prelude, gap)
625 else:
626 result = result + ''&#x27;
627<tr><td class="decor %s-decor">%s</td><td>%s</td>''&#x27; % (cls, marginalia, gap)
628
629 return result + '\n<td class="singlecolumn">%s</td></tr></table>' % contents
630
631 def bigsection(self, title, *args):
632 """Format a section with a big heading."""
633 title = '<strong class="bigsection">%s</strong>' % title
634 return self.section(title, *args)
635
636 def preformat(self, text):
637 """Format literal preformatted text."""

Callers 1

pydoc.pyFile · 0.85

Calls 1

HTMLReprClass · 0.85

Tested by

no test coverage detected