diff --git a/Lib/pydoc.py b/Lib/pydoc.py index c863794ea14ef9..1a829e31cac49e 100644 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -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 @@ -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 '''\ Python: %s + %s -''' % (title, contents) +''' % (title, css_data, contents) def heading(self, title, extras=''): """Format a page heading.""" diff --git a/Misc/NEWS.d/next/Documentation/2024-11-26-00-09-16.gh-issue-127276.4ST1Wf.rst b/Misc/NEWS.d/next/Documentation/2024-11-26-00-09-16.gh-issue-127276.4ST1Wf.rst new file mode 100644 index 00000000000000..ae983345702bce --- /dev/null +++ b/Misc/NEWS.d/next/Documentation/2024-11-26-00-09-16.gh-issue-127276.4ST1Wf.rst @@ -0,0 +1 @@ +Add embedded styles to documentation pages created by a 'python -m pydoc -w' call