Skip to content

Commit

Permalink
pythongh-127276: add embedded styles to documentation pages created b…
Browse files Browse the repository at this point in the history
…y a 'python -m pydoc -w' call
  • Loading branch information
denisbukanov authored and yahuaska committed Nov 26, 2024
1 parent 26ff32b commit 3997ec6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Lib/pydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class or function within a module or module in a package. If the
import importlib._bootstrap
import importlib._bootstrap_external
import importlib.machinery
import importlib.resources
import importlib.util
import inspect
import io
Expand Down Expand Up @@ -631,15 +632,19 @@ class HTMLDoc(Doc):

def page(self, title, contents):
"""Format an HTML page."""
css_data = importlib.resources.files('pydoc_data').joinpath('_pydoc.css').read_text()
return '''\
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Python: %s</title>
<style>
%s
</style>
</head><body>
%s
</body></html>''' % (title, contents)
</body></html>''' % (title, css_data, contents)

def heading(self, title, extras=''):
"""Format a page heading."""
Expand Down

0 comments on commit 3997ec6

Please sign in to comment.