##// END OF EJS Templates
minirst: generate tables as a list of joined lines
Olav Reinert -
r16815:e740746e default
parent child Browse files
Show More
@@ -3324,7 +3324,8 b' def help_(ui, name=None, unknowncmd=Fals'
3324 ('extensioncommands', _('Extension Commands'))):
3324 ('extensioncommands', _('Extension Commands'))):
3325 if matches[t]:
3325 if matches[t]:
3326 ui.write('%s:\n\n' % title)
3326 ui.write('%s:\n\n' % title)
3327 ui.write(minirst.format(minirst.maketable(matches[t], 1)))
3327 rst = ''.join(minirst.maketable(matches[t], 1))
3328 ui.write(minirst.format(rst))
3328 return
3329 return
3329
3330
3330 if name and name != 'shortlist':
3331 if name and name != 'shortlist':
@@ -58,9 +58,9 b' def optrst(options, verbose):'
58 rst = minirst.maketable(data, 1)
58 rst = minirst.maketable(data, 1)
59
59
60 if multioccur:
60 if multioccur:
61 rst += _("\n[+] marked option can be specified multiple times\n")
61 rst.append(_("\n[+] marked option can be specified multiple times\n"))
62
62
63 return rst
63 return ''.join(rst)
64
64
65 # list all option lists
65 # list all option lists
66 def opttext(optlist, width, verbose):
66 def opttext(optlist, width, verbose):
@@ -658,7 +658,7 b' def decorateblocks(blocks, width):'
658 return lines
658 return lines
659
659
660 def maketable(data, indent=0, header=False):
660 def maketable(data, indent=0, header=False):
661 '''Generate an RST table for the given table data'''
661 '''Generate an RST table for the given table data as a list of lines'''
662
662
663 widths = [max(encoding.colwidth(e) for e in c) for c in zip(*data)]
663 widths = [max(encoding.colwidth(e) for e in c) for c in zip(*data)]
664 indent = ' ' * indent
664 indent = ' ' * indent
@@ -674,4 +674,4 b' def maketable(data, indent=0, header=Fal'
674 if header and len(data) > 1:
674 if header and len(data) > 1:
675 out.insert(2, div)
675 out.insert(2, div)
676 out.append(div)
676 out.append(div)
677 return ''.join(out)
677 return out
@@ -237,7 +237,8 b" data = [['a', 'b', 'c'],"
237 ['1', '2', '3'],
237 ['1', '2', '3'],
238 ['foo', 'bar', 'baz this list is very very very long man']]
238 ['foo', 'bar', 'baz this list is very very very long man']]
239
239
240 table = minirst.maketable(data, 2, True)
240 rst = minirst.maketable(data, 2, True)
241 table = ''.join(rst)
241
242
242 print table
243 print table
243
244
General Comments 0
You need to be logged in to leave comments. Login now