tests/test-minirst.py
changeset 28752 6b2f9a4e2f97
parent 28751 67a4e42a651f
child 28840 8717d4609ab3
equal deleted inserted replaced
28751:67a4e42a651f 28752:6b2f9a4e2f97
     1 from __future__ import absolute_import
     1 from __future__ import absolute_import, print_function
     2 from pprint import (
     2 from pprint import (
     3     pprint,
     3     pprint,
     4 )
     4 )
     5 from mercurial import (
     5 from mercurial import (
     6     minirst,
     6     minirst,
     7 )
     7 )
     8 
     8 
     9 def debugformat(text, form, **kwargs):
     9 def debugformat(text, form, **kwargs):
    10     if form == 'html':
    10     if form == 'html':
    11         print "html format:"
    11         print("html format:")
    12         out = minirst.format(text, style=form, **kwargs)
    12         out = minirst.format(text, style=form, **kwargs)
    13     else:
    13     else:
    14         print "%d column format:" % form
    14         print("%d column format:" % form)
    15         out = minirst.format(text, width=form, **kwargs)
    15         out = minirst.format(text, width=form, **kwargs)
    16 
    16 
    17     print "-" * 70
    17     print("-" * 70)
    18     if type(out) == tuple:
    18     if type(out) == tuple:
    19         print out[0][:-1]
    19         print(out[0][:-1])
    20         print "-" * 70
    20         print("-" * 70)
    21         pprint(out[1])
    21         pprint(out[1])
    22     else:
    22     else:
    23         print out[:-1]
    23         print(out[:-1])
    24     print "-" * 70
    24     print("-" * 70)
    25     print
    25     print()
    26 
    26 
    27 def debugformats(title, text, **kwargs):
    27 def debugformats(title, text, **kwargs):
    28     print "== %s ==" % title
    28     print("== %s ==" % title)
    29     debugformat(text, 60, **kwargs)
    29     debugformat(text, 60, **kwargs)
    30     debugformat(text, 30, **kwargs)
    30     debugformat(text, 30, **kwargs)
    31     debugformat(text, 'html', **kwargs)
    31     debugformat(text, 'html', **kwargs)
    32 
    32 
    33 paragraphs = """
    33 paragraphs = """
   244          ['foo', 'bar', 'baz this list is very very very long man']]
   244          ['foo', 'bar', 'baz this list is very very very long man']]
   245 
   245 
   246 rst = minirst.maketable(data, 2, True)
   246 rst = minirst.maketable(data, 2, True)
   247 table = ''.join(rst)
   247 table = ''.join(rst)
   248 
   248 
   249 print table
   249 print(table)
   250 
   250 
   251 debugformats('table', table)
   251 debugformats('table', table)
   252 
   252 
   253 data = [['s', 'long', 'line\ngoes on here'],
   253 data = [['s', 'long', 'line\ngoes on here'],
   254         ['', 'xy', 'tried to fix here\n        by indenting']]
   254         ['', 'xy', 'tried to fix here\n        by indenting']]
   255 
   255 
   256 rst = minirst.maketable(data, 1, False)
   256 rst = minirst.maketable(data, 1, False)
   257 table = ''.join(rst)
   257 table = ''.join(rst)
   258 
   258 
   259 print table
   259 print(table)
   260 
   260 
   261 debugformats('table+nl', table)
   261 debugformats('table+nl', table)
   262 
   262