comparison tests/test-minirst.py @ 43076:2372284d9457

formatting: blacken the codebase This is using my patch to black (https://github.com/psf/black/pull/826) so we don't un-wrap collection literals. Done with: hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**"' | xargs black -S # skip-blame mass-reformatting only # no-check-commit reformats foo_bar functions Differential Revision: https://phab.mercurial-scm.org/D6971
author Augie Fackler <augie@google.com>
date Sun, 06 Oct 2019 09:45:02 -0400
parents a2a5d4ad5276
children aaff3bc75306
comparison
equal deleted inserted replaced
43075:57875cf423c9 43076:2372284d9457
1 from __future__ import absolute_import, print_function 1 from __future__ import absolute_import, print_function
2 from mercurial import ( 2 from mercurial import minirst
3 minirst, 3 from mercurial.utils import stringutil
4 ) 4
5 from mercurial.utils import (
6 stringutil,
7 )
8 5
9 def debugformat(text, form, **kwargs): 6 def debugformat(text, form, **kwargs):
10 blocks, pruned = minirst.parse(text, **kwargs) 7 blocks, pruned = minirst.parse(text, **kwargs)
11 if form == b'html': 8 if form == b'html':
12 print("html format:") 9 print("html format:")
21 print("-" * 70) 18 print("-" * 70)
22 print(stringutil.pprint(pruned).decode('utf8')) 19 print(stringutil.pprint(pruned).decode('utf8'))
23 print("-" * 70) 20 print("-" * 70)
24 print() 21 print()
25 22
23
26 def debugformats(title, text, **kwargs): 24 def debugformats(title, text, **kwargs):
27 print("== %s ==" % title) 25 print("== %s ==" % title)
28 debugformat(text, 60, **kwargs) 26 debugformat(text, 60, **kwargs)
29 debugformat(text, 30, **kwargs) 27 debugformat(text, 30, **kwargs)
30 debugformat(text, b'html', **kwargs) 28 debugformat(text, b'html', **kwargs)
29
31 30
32 paragraphs = b""" 31 paragraphs = b"""
33 This is some text in the first paragraph. 32 This is some text in the first paragraph.
34 33
35 A small indented paragraph. 34 A small indented paragraph.
186 """ 185 """
187 186
188 debugformats('containers (normal)', containers) 187 debugformats('containers (normal)', containers)
189 debugformats('containers (verbose)', containers, keep=[b'verbose']) 188 debugformats('containers (verbose)', containers, keep=[b'verbose'])
190 debugformats('containers (debug)', containers, keep=[b'debug']) 189 debugformats('containers (debug)', containers, keep=[b'debug'])
191 debugformats('containers (verbose debug)', containers, 190 debugformats(
192 keep=[b'verbose', b'debug']) 191 'containers (verbose debug)', containers, keep=[b'verbose', b'debug']
192 )
193 193
194 roles = b"""Please see :hg:`add`.""" 194 roles = b"""Please see :hg:`add`."""
195 debugformats('roles', roles) 195 debugformats('roles', roles)
196 196
197 197
243 """ 243 """
244 244
245 debugformats('comments', comments) 245 debugformats('comments', comments)
246 246
247 247
248 data = [[b'a', b'b', b'c'], 248 data = [
249 [b'1', b'2', b'3'], 249 [b'a', b'b', b'c'],
250 [b'foo', b'bar', b'baz this list is very very very long man']] 250 [b'1', b'2', b'3'],
251 [b'foo', b'bar', b'baz this list is very very very long man'],
252 ]
251 253
252 rst = minirst.maketable(data, 2, True) 254 rst = minirst.maketable(data, 2, True)
253 table = b''.join(rst) 255 table = b''.join(rst)
254 256
255 print(table.decode('utf8')) 257 print(table.decode('utf8'))
256 258
257 debugformats('table', table) 259 debugformats('table', table)
258 260
259 data = [[b's', b'long', b'line\ngoes on here'], 261 data = [
260 [b'', b'xy', b'tried to fix here\n by indenting']] 262 [b's', b'long', b'line\ngoes on here'],
263 [b'', b'xy', b'tried to fix here\n by indenting'],
264 ]
261 265
262 rst = minirst.maketable(data, 1, False) 266 rst = minirst.maketable(data, 1, False)
263 table = b''.join(rst) 267 table = b''.join(rst)
264 268
265 print(table.decode('utf8')) 269 print(table.decode('utf8'))