Skip to contentSkip to conversation

Scripts: generate one blank line if sphinx table is empty

PATCH In review Lucas Dutra Nunes 2 participants 2 messages Apr 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Scripts: generate one blank line if sphinx table is empty

An empty table without at least a empty line is not valid on Sphinx, so a blank line must be added when generating a table like so.

---
 scripts/doc_utils.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
scripts/doc_utils.py +5 -4
index 9d11bd8..fe6dd88 100644
@@ -21,9 +21,10 @@ def tabularize(lines, spacing=2):
     if lines:
         col_widths = map(lambda col: apply(max, map(len, col) + [0]),
                          apply(zip, lines))
-        return '\n'.join([format_header(lines[0], col_widths, spc),
-                          format_body(lines[1:], col_widths, spc),
-                          format_border(col_widths)]) + \
-               '\n'
+        table_data = [format_header(lines[0], col_widths, spc),
+                      format_body(lines[1:], col_widths, spc),
+                      format_border(col_widths)]
+        table_data = filter(lambda x: len(x) > 0, table_data)
+        return '\n'.join(table_data) + '\n'
     else:
         return ""
Signature · 1 line
2.1.4
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Lucas Dutra Nunes

An empty table without at least a empty line is not valid on Sphinx, so a blank line must be added when generating a table like so.

Signature · 3 lines
Otavio Salvador                             O.S. Systems
http://www.ossystems.com.br        http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854            Mobile: +1 (347) 903-9750