Skip to content

gh-153906: Modernize pydoc HTML output - #153909

Merged
serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:pydoc-modern-html
Jul 19, 2026
Merged

serhiy-storchaka merged 2 commits into
python:mainfrom
serhiy-storchaka:pydoc-modern-html

Conversation

@serhiy-storchaka

@serhiy-storchaka serhiy-storchaka commented Jul 18, 2026 •

Copy link
Copy Markdown
Member

Finish the modernization started in gh-54925: replace the remaining 1990s-era markup with semantic HTML5 and restyle the pages after the python-docs-theme used by docs.python.org.

  • <header>/<section>/<h1>–<h4> instead of layout tables; flexbox <nav> for the server's navigation bar
  • multi-column lists via CSS columns; docstrings rendered with white-space: pre-wrap instead of &nbsp;/<br>
  • id= anchors instead of the obsolete <a name=...> (anchor names unchanged)
  • members inherited from other classes are collapsed by default using <details>
  • new style sheet: python-docs-theme fonts and colors, dark mode, docs.python.org-style literal blocks for topic pages
  • ServerHTMLDoc in xmlrpc.server updated to match

The HTMLDoc API is unchanged: all method signatures are kept, obsolete parameters are accepted and ignored.

🤖 Generated with Claude Code

Follow-up of the HTML5 migration in bpo-10716: replace the layout
tables, the &nbsp;/<br> encoding of docstrings and the obsolete
<a name=...> anchors with semantic markup (header, section, h1-h4,
CSS multi-column lists, white-space: pre-wrap, id= anchors), and
restyle the pages after the python-docs-theme used by docs.python.org,
including dark mode support.  Members inherited from other classes
are now collapsed by default.  The pydoc API is unchanged; obsolete
arguments of HTMLDoc methods are accepted and ignored.  ServerHTMLDoc
in xmlrpc.server is updated to match.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@read-the-docs-community

read-the-docs-community Bot commented Jul 18, 2026 •

Copy link
Copy Markdown

@picnixz picnixz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nits but otheriwse LGTM.

Comment thread Lib/pydoc.py Resolved
Comment thread Lib/pydoc.py Resolved
Comment thread Lib/pydoc.py
heading = html.heading(
'<strong class="title">Index of Modules</strong>'
)
heading = html.heading('Index of Modules')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make it translatable?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is out of scope of this PR. It should be a part of a larger issue -- pydoc has many untranslated strings.

Addressed all other comments. Thank you.

Comment thread Lib/pydoc.py Resolved
- Restore the non-breakable space before "(package)" in module index
  links.
- Indent the navigation bar HTML template.
- Use the "keyword" CSS class for keyword help pages, in addition to
  "topic" for topic help pages.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@serhiy-storchaka
serhiy-storchaka enabled auto-merge (squash) July 19, 2026 09:37
@serhiy-storchaka
serhiy-storchaka merged commit cae8ec8 into python:main Jul 19, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants