MCPcopy Index your code
hub / github.com/RustPython/RustPython / HTMLDoc

Class HTMLDoc

Lib/pydoc.py:644–1234  ·  view source on GitHub ↗

Formatter class for HTML documentation.

Source from the content-addressed store, hash-verified

642 repr_unicode = repr_string
643
644class HTMLDoc(Doc):
645 """Formatter class for HTML documentation."""
646
647 # ------------------------------------------- HTML formatting utilities
648
649 _repr_instance = HTMLRepr()
650 repr = _repr_instance.repr
651 escape = _repr_instance.escape
652
653 def page(self, title, contents):
654 """Format an HTML page."""
655 return '''\
656<!DOCTYPE html>
657<html lang="en">
658<head>
659<meta charset="utf-8">
660<title>Python: %s</title>
661</head><body>
662%s
663</body></html>''&#x27; % (title, contents)
664
665 def heading(self, title, extras=''):
666 """Format a page heading."""
667 return ''&#x27;
668<table class="heading">
669<tr class="heading-text decor">
670<td class="title">&nbsp;<br>%s</td>
671<td class="extra">%s</td></tr></table>
672 ''' % (title, extras or '&nbsp;&#x27;)
673
674 def section(self, title, cls, contents, width=6,
675 prelude='', marginalia=None, gap='&nbsp;'):
676 """Format a section with a heading."""
677 if marginalia is None:
678 marginalia = '<span class="code">' + '&nbsp;' * width + '</span>'
679 result = ''&#x27;<p>
680<table class="section">
681<tr class="decor %s-decor heading-text">
682<td class="section-title" colspan=3>&nbsp;<br>%s</td></tr>
683 ''&#x27; % (cls, title)
684 if prelude:
685 result = result + ''&#x27;
686<tr><td class="decor %s-decor" rowspan=2>%s</td>
687<td class="decor %s-decor" colspan=2>%s</td></tr>
688<tr><td>%s</td>''&#x27; % (cls, marginalia, cls, prelude, gap)
689 else:
690 result = result + ''&#x27;
691<tr><td class="decor %s-decor">%s</td><td>%s</td>''&#x27; % (cls, marginalia, gap)
692
693 return result + '\n<td class="singlecolumn">%s</td></tr></table>' % contents
694
695 def bigsection(self, title, *args):
696 """Format a section with a big heading."""
697 title = '<strong class="bigsection">%s</strong>' % title
698 return self.section(title, *args)
699
700 def preformat(self, text):
701 """Format literal preformatted text."""

Callers 1

pydoc.pyFile · 0.85

Calls 1

HTMLReprClass · 0.85

Tested by

no test coverage detected