Skip to content

Commit

Permalink
[2.2.x] Fixed crash building HTML docs since Sphinx 4.3.
Browse files Browse the repository at this point in the history
See sphinx-doc/sphinx@dd2ff3e.
Backport of f0480dd from main
  • Loading branch information
felixxm committed Nov 18, 2021
1 parent 5289fcf commit 4bc10b7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/_ext/djangodocs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from docutils import nodes
from docutils.parsers.rst import Directive
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.directives.code import CodeBlock
from sphinx.domains.std import Cmdoption
Expand Down Expand Up @@ -114,11 +114,17 @@ class DjangoHTMLTranslator(HTMLTranslator):
def visit_table(self, node):
self.context.append(self.compact_p)
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'))

def depart_table(self, node):
self.compact_p = self.context.pop()
if sphinx_version >= (4, 3):
self._table_row_indices.pop()
self.body.append('</table>\n')

def visit_desc_parameterlist(self, node):
Expand Down

0 comments on commit 4bc10b7

Please sign in to comment.