1
0
mirror of https://github.com/django/django.git synced 2025-01-03 06:55:47 +00:00

Fixed #34756 -- Fixed docs HTML build on Sphinx 7.1+.

This commit is contained in:
David Smith 2023-08-01 21:22:53 +01:00 committed by Mariusz Felisiak
parent 9b9c805ced
commit b3e0170ab5

View File

@ -9,6 +9,7 @@ from docutils import nodes
from docutils.parsers.rst import Directive from docutils.parsers.rst import Directive
from docutils.statemachine import ViewList from docutils.statemachine import ViewList
from sphinx import addnodes from sphinx import addnodes
from sphinx import version_info as sphinx_version
from sphinx.builders.html import StandaloneHTMLBuilder from sphinx.builders.html import StandaloneHTMLBuilder
from sphinx.directives.code import CodeBlock from sphinx.directives.code import CodeBlock
from sphinx.domains.std import Cmdoption from sphinx.domains.std import Cmdoption
@ -127,12 +128,23 @@ class DjangoHTMLTranslator(HTMLTranslator):
def visit_desc_parameterlist(self, node): def visit_desc_parameterlist(self, node):
self.body.append("(") # by default sphinx puts <big> around the "(" self.body.append("(") # by default sphinx puts <big> around the "("
self.first_param = 1
self.optional_param_level = 0 self.optional_param_level = 0
self.param_separator = node.child_text_separator self.param_separator = node.child_text_separator
self.required_params_left = sum( # Counts 'parameter groups' being either a required parameter, or a set
# of contiguous optional ones.
required_params = [
isinstance(c, addnodes.desc_parameter) for c in node.children isinstance(c, addnodes.desc_parameter) for c in node.children
) ]
# How many required parameters are left.
self.required_params_left = sum(required_params)
if sphinx_version < (7, 1):
self.first_param = 1
else:
self.is_first_param = True
self.params_left_at_level = 0
self.param_group_index = 0
self.list_is_required_param = required_params
self.multi_line_parameter_list = False
def depart_desc_parameterlist(self, node): def depart_desc_parameterlist(self, node):
self.body.append(")") self.body.append(")")