changeset 16815:e740746ea557

minirst: generate tables as a list of joined lines
author Olav Reinert <seroton10@gmail.com>
date Fri, 01 Jun 2012 11:58:23 +0200
parents d3b807e673a8
children d10994f1c7a2
files mercurial/commands.py mercurial/help.py mercurial/minirst.py tests/test-minirst.py
diffstat 4 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Sat May 26 20:49:51 2012 +0200
+++ b/mercurial/commands.py	Fri Jun 01 11:58:23 2012 +0200
@@ -3324,7 +3324,8 @@
                          ('extensioncommands', _('Extension Commands'))):
             if matches[t]:
                 ui.write('%s:\n\n' % title)
-                ui.write(minirst.format(minirst.maketable(matches[t], 1)))
+                rst = ''.join(minirst.maketable(matches[t], 1))
+                ui.write(minirst.format(rst))
         return
 
     if name and name != 'shortlist':
--- a/mercurial/help.py	Sat May 26 20:49:51 2012 +0200
+++ b/mercurial/help.py	Fri Jun 01 11:58:23 2012 +0200
@@ -58,9 +58,9 @@
     rst = minirst.maketable(data, 1)
 
     if multioccur:
-        rst += _("\n[+] marked option can be specified multiple times\n")
+        rst.append(_("\n[+] marked option can be specified multiple times\n"))
 
-    return rst
+    return ''.join(rst)
 
 # list all option lists
 def opttext(optlist, width, verbose):
--- a/mercurial/minirst.py	Sat May 26 20:49:51 2012 +0200
+++ b/mercurial/minirst.py	Fri Jun 01 11:58:23 2012 +0200
@@ -658,7 +658,7 @@
     return lines
 
 def maketable(data, indent=0, header=False):
-    '''Generate an RST table for the given table data'''
+    '''Generate an RST table for the given table data as a list of lines'''
 
     widths = [max(encoding.colwidth(e) for e in c) for c in zip(*data)]
     indent = ' ' * indent
@@ -674,4 +674,4 @@
     if header and len(data) > 1:
         out.insert(2, div)
     out.append(div)
-    return ''.join(out)
+    return out
--- a/tests/test-minirst.py	Sat May 26 20:49:51 2012 +0200
+++ b/tests/test-minirst.py	Fri Jun 01 11:58:23 2012 +0200
@@ -237,7 +237,8 @@
          ['1', '2', '3'],
          ['foo', 'bar', 'baz this list is very very very long man']]
 
-table = minirst.maketable(data, 2, True)
+rst = minirst.maketable(data, 2, True)
+table = ''.join(rst)
 
 print table