Commit 217e2bfa authored by Dmitry Shachnev's avatar Dmitry Shachnev Committed by Jonathan Corbet

docs: sphinx-extensions: make rstFlatTable work with docutils 0.13

In docutils 0.13, the return type of get_column_widths method of the
Table directive has changed [1], which breaks our flat-table directive
and leads to a TypeError when trying to build the docs [2].

This patch adds support for the new return type, while keeping support
for older docutils versions too.

[1] https://sourceforge.net/p/docutils/patches/120/
[2] https://sourceforge.net/p/docutils/bugs/303/Signed-off-by: default avatarDmitry Shachnev <mitya57@debian.org>
Cc: <stable@vger.kernel.org> # 4.8.x-
Signed-off-by: default avatarJonathan Corbet <corbet@lwn.net>
parent 3fa71d0f
...@@ -157,6 +157,11 @@ class ListTableBuilder(object): ...@@ -157,6 +157,11 @@ class ListTableBuilder(object):
def buildTableNode(self): def buildTableNode(self):
colwidths = self.directive.get_column_widths(self.max_cols) colwidths = self.directive.get_column_widths(self.max_cols)
if isinstance(colwidths, tuple):
# Since docutils 0.13, get_column_widths returns a (widths,
# colwidths) tuple, where widths is a string (i.e. 'auto').
# See https://sourceforge.net/p/docutils/patches/120/.
colwidths = colwidths[1]
stub_columns = self.directive.options.get('stub-columns', 0) stub_columns = self.directive.options.get('stub-columns', 0)
header_rows = self.directive.options.get('header-rows', 0) header_rows = self.directive.options.get('header-rows', 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment