Fixed crash building HTML docs since Sphinx 4.3.

See dd2ff3e911.
This commit is contained in:
Mariusz Felisiak 2021-11-17 12:31:25 +01:00 committed by GitHub
parent 2d124f6a1c
commit f0480ddd2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -8,7 +8,7 @@ import re
from docutils import nodes 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, 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
@ -115,11 +115,17 @@ class DjangoHTMLTranslator(HTMLTranslator):
def visit_table(self, node): def visit_table(self, node):
self.context.append(self.compact_p) self.context.append(self.compact_p)
self.compact_p = True self.compact_p = True
self._table_row_index = 0 # Needed by Sphinx # Needed by Sphinx.
if sphinx_version >= (4, 3):
self._table_row_indices.append(0)
else:
self._table_row_index = 0
self.body.append(self.starttag(node, 'table', CLASS='docutils')) self.body.append(self.starttag(node, 'table', CLASS='docutils'))
def depart_table(self, node): def depart_table(self, node):
self.compact_p = self.context.pop() self.compact_p = self.context.pop()
if sphinx_version >= (4, 3):
self._table_row_indices.pop()
self.body.append('</table>\n') self.body.append('</table>\n')
def visit_desc_parameterlist(self, node): def visit_desc_parameterlist(self, node):