import logging
import os
import re
import sys
import sysconfig
from typing import Any, Callable, Dict, Sequence, Tuple, Union
from pydoc_fork import inline_styles
from pydoc_fork.utils import resolve
from pydoc_fork.all_found import MENTIONED_MODULES
from pydoc_fork.html_repr_class import HTMLRepr
from pydoc_fork.jinja_code import JINJA_ENV
from pydoc_fork.string_utils import replace
LOGGER = logging.getLogger(__name__)
STDLIB_BASEDIR = sysconfig.get_path("stdlib")
DOCUMENT_INTERNALS = False
OUTPUT_FOLDER = ""
PYTHONDOCS = os.environ.get(
    "PYTHONDOCS", "https://docs.python.org/%d.%d/library" % sys.version_info[:2]
)monkey patching was messing with mypy– is this now a redeclare? Turn method into function
def html_repr(value: Any) -> str:  # noqa - unhiding could break code?    _repr_instance = HTMLRepr()
    return _repr_instance.repr(value)HTML safe repr and escape
def escape(value: Any) -> str:    _repr_instance = HTMLRepr()
    result = _repr_instance.escape(value)
    if ">" in result:
        print("possible double escape")
    return resultFormat a page heading.
def heading(title: str, fgcol: str, bgcol: str, extras: str = "") -> str:    template = JINJA_ENV.get_template("heading.jinja2")
    return template.render(title=title, fgcol=fgcol, bgcol=bgcol, extras=extras)
#     return f"""| {title} | {extras or ' '} | 
# """Format a section with a heading.
def section(
    title: str,
    fgcol: str,
    bgcol: str,
    contents: str,
    width: int = 6,  # used by marginalia?
    prelude: str = "",
    marginalia: str = "",  # not used
    gap: str = " ",  # not used
) -> str:    if marginalia is None:
        marginalia = "<tt>" + " " * width + "</tt>"
    template = JINJA_ENV.get_template("section.jinja2")
    return template.render(
        title=title,
        fgcol=fgcol,
        bgcol=bgcol,
        marginalia=marginalia,
        prelude=prelude,
        contents=contents,
        gap=gap,
    )This is only used by docclass
if marginalia is None:
    marginalia = "<tt>" + " " * width + "</tt>"
result = f"""<p>
| {title} | ||
| {marginalia} | {prelude} | |