MCPcopy Index your code
hub / github.com/python/cpython / HTMLDoc

Class HTMLDoc

Lib/pydoc.py:599–1189  ·  view source on GitHub ↗

Formatter class for HTML documentation.

Source from the content-addressed store, hash-verified

597 repr_unicode = repr_string
598
599class HTMLDoc(Doc):
600 """Formatter class for HTML documentation."""
601
602 # ------------------------------------------- HTML formatting utilities
603
604 _repr_instance = HTMLRepr()
605 repr = _repr_instance.repr
606 escape = _repr_instance.escape
607
608 def page(self, title, contents):
609 """Format an HTML page."""
610 return '''\
611<!DOCTYPE html>
612<html lang="en">
613<head>
614<meta charset="utf-8">
615<title>Python: %s</title>
616</head><body>
617%s
618</body></html>''&#x27; % (title, contents)
619
620 def heading(self, title, extras=''):
621 """Format a page heading."""
622 return ''&#x27;
623<table class="heading">
624<tr class="heading-text decor">
625<td class="title">&nbsp;<br>%s</td>
626<td class="extra">%s</td></tr></table>
627 ''' % (title, extras or '&nbsp;&#x27;)
628
629 def section(self, title, cls, contents, width=6,
630 prelude='', marginalia=None, gap='&nbsp;'):
631 """Format a section with a heading."""
632 if marginalia is None:
633 marginalia = '<span class="code">' + '&nbsp;' * width + '</span>'
634 result = ''&#x27;<p>
635<table class="section">
636<tr class="decor %s-decor heading-text">
637<td class="section-title" colspan=3>&nbsp;<br>%s</td></tr>
638 ''&#x27; % (cls, title)
639 if prelude:
640 result = result + ''&#x27;
641<tr><td class="decor %s-decor" rowspan=2>%s</td>
642<td class="decor %s-decor" colspan=2>%s</td></tr>
643<tr><td>%s</td>''&#x27; % (cls, marginalia, cls, prelude, gap)
644 else:
645 result = result + ''&#x27;
646<tr><td class="decor %s-decor">%s</td><td>%s</td>''&#x27; % (cls, marginalia, gap)
647
648 return result + '\n<td class="singlecolumn">%s</td></tr></table>' % contents
649
650 def bigsection(self, title, *args):
651 """Format a section with a big heading."""
652 title = '<strong class="bigsection">%s</strong>' % title
653 return self.section(title, *args)
654
655 def preformat(self, text):
656 """Format literal preformatted text."""

Callers 1

pydoc.pyFile · 0.85

Calls 1

HTMLReprClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…