Opened 3 weeks ago

Closed 3 weeks ago

Last modified 3 weeks ago

#37150 closed Cleanup/optimization (fixed)

Version added/changed text, console tabs missing from RTD preview builds, dirhtml builds, etc.

Reported by: Mike Edmunds Owned by: Mike Edmunds
Component: Documentation Version: 6.0
Severity: Normal Keywords: sphinx
Cc: James Beard Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

There are several related issues in the docs._ext.djangodocs Sphinx extension. The symptom is missing content in most html-like Sphinx builds, including ReadTheDocs PR preview builds:

  • Missing text for versionadded and versionchanged directives: the html contains an empty <div> where something like "New in Django 6.1" or "Changed in Django development version" should be.
  • Missing console tabs: the html does not include Windows console examples when they are available.

This affects the html builder (which RTD uses by default), the dirhtml builder, plus htmlhelp and singlehtml.

The fix is for the djangodocs extension to:

  • Register DjangoHTMLTranslator for all html-like builders (solves missing version text)
  • Handle all HTML-like builders in visit_console_html() and ConsoleDirective.run() (solves missing console tabs)

[Currently, the extension only handles version and console directives for a custom "djangohtml" builder—used in the docs/Makefile "html" target—and the "json" builder which is used for the docs.djangoproject.com site.]

Also, the custom DjangoStandaloneHTMLBuilder class can and should be removed. Its only function is generating templatebuiltins.js, which is meant to enable client-side hyperlinking of template tags and filters in code examples. But that feature isn't enabled on docs.djangoproject.com and has been broken in local docs builds since Sphinx 6.0 removed jQuery in 2023. It's effectively dead code.

Change History (7)

comment:1 by Mike Edmunds, 3 weeks ago

Has patch: set

https://github.com/django/django/pull/21440.

[The djangodocs Sphinx extension and theme template files are undocumented, so I think deprecation would not apply to the removed code.]

comment:2 by Natalia Bidart, 3 weeks ago

Triage Stage: UnreviewedAccepted

Thank you Mike, this makes sense. Will review the PR soon!

comment:3 by Natalia Bidart, 3 weeks ago

Triage Stage: AcceptedReady for checkin

comment:4 by nessita <124304+nessita@…>, 3 weeks ago

Resolution: fixed
Status: assignedclosed

In 9b1db9c:

Fixed #37150 -- Made djangodocs Sphinx extension work with any html builder.

Changed djangodocs extension to register DjangoHTMLTranslator for any
html-format builder (in the builder-inited hook), rather than a limited
list of builders at startup. That fixes missing content in dirhtml and
standard html builds (including ReadTheDocs PR previews):

  • Missing console tabs
  • Empty divs for versionadded and versionchanged directives

Removed JS code that depended on jQuery, which hasn't worked since
Sphinx 6.0 dropped jQuery in 2023:

  • Unnecessary console tabs click handling. (Console tab behavior is implemented purely in CSS.)
  • Client-side hyperlinking of Django template tags and filters in code examples. (This is also not supported on docs.djangoproject.com.)

Removed custom DjangoStandaloneHTMLBuilder and "djangohtml" builder
type. Its sole purpose was to generate the "templatebuiltins.js" file
used for the (non-functional) client-side template filter/tag linking.

Changed docs "make html" target from "djangohtml" to standard "html".

comment:5 by Natalia <124304+nessita@…>, 3 weeks ago

In a09323d:

[6.1.x] Fixed #37150 -- Made djangodocs Sphinx extension work with any html builder.

Changed djangodocs extension to register DjangoHTMLTranslator for any
html-format builder (in the builder-inited hook), rather than a limited
list of builders at startup. That fixes missing content in dirhtml and
standard html builds (including ReadTheDocs PR previews):

  • Missing console tabs
  • Empty divs for versionadded and versionchanged directives

Removed JS code that depended on jQuery, which hasn't worked since
Sphinx 6.0 dropped jQuery in 2023:

  • Unnecessary console tabs click handling. (Console tab behavior is implemented purely in CSS.)
  • Client-side hyperlinking of Django template tags and filters in code examples. (This is also not supported on docs.djangoproject.com.)

Removed custom DjangoStandaloneHTMLBuilder and "djangohtml" builder
type. Its sole purpose was to generate the "templatebuiltins.js" file
used for the (non-functional) client-side template filter/tag linking.

Changed docs "make html" target from "djangohtml" to standard "html".

Backport of 9b1db9cb2c38c75b8fb0fc64ba5f73a6012e5b2d from main.

comment:6 by GitHub <noreply@…>, 3 weeks ago

In bc65586c:

Refs #37150 -- Synced docs/make.bat with docs/Makefile.

comment:7 by Natalia <124304+nessita@…>, 3 weeks ago

In 3a5c377:

[6.1.x] Refs #37150 -- Synced docs/make.bat with docs/Makefile.

Backport of bc65586cfb69c0c0c399e40a22494501e0da2008 from main.

Note: See TracTickets for help on using tickets.
Back to Top