Add compatibility with docutils 0.13

In docutils 0.13.1, the get_column_widths method of Table directive
returns a tuple, where the widths array is the second item.

Also, get_column_widths now has a “if type(self.widths) == list” check,
so use the list syntax when setting the widths property.

Change-Id: I9888a649313c60257ce6dfc46cfbd2dcbf7ac189
This commit is contained in:
Dmitry Shachnev 2016-12-18 19:58:37 +03:00
parent f694119d39
commit f30d53cda0
2 changed files with 12 additions and 2 deletions

View File

@ -357,8 +357,13 @@ class RestParametersDirective(Table):
# TODO(sdague): it would be good to dynamically set column
# widths (or basically make the colwidth thing go away
# entirely)
self.options['widths'] = (20, 10, 10, 60)
self.options['widths'] = [20, 10, 10, 60]
self.col_widths = self.get_column_widths(self.max_cols)
if isinstance(self.col_widths, tuple):
# In docutils 0.13.1, get_column_widths returns a (widths,
# colwidths) tuple, where widths is a string (i.e. 'auto').
# See https://sourceforge.net/p/docutils/patches/120/.
self.col_widths = self.col_widths[1]
# Actually convert the yaml
title, messages = self.make_title()
# self.app.info("Title %s, messages %s" % (title, messages))

View File

@ -100,8 +100,13 @@ class HTTPResponseCodeDirective(Table):
# TODO(sdague): it would be good to dynamically set column
# widths (or basically make the colwidth thing go away
# entirely)
self.options['widths'] = (30, 70)
self.options['widths'] = [30, 70]
self.col_widths = self.get_column_widths(self.max_cols)
if isinstance(self.col_widths, tuple):
# In docutils 0.13.1, get_column_widths returns a (widths,
# colwidths) tuple, where widths is a string (i.e. 'auto').
# See https://sourceforge.net/p/docutils/patches/120/.
self.col_widths = self.col_widths[1]
# Actually convert the yaml
title, messages = self.make_title()
# self.app.info("Title %s, messages %s" % (title, messages))