tests/test-minirst.py
author Olav Reinert <seroton10@gmail.com>
Fri, 01 Jun 2012 11:58:23 +0200
changeset 16815 e740746ea557
parent 15263 70d7293c41d6
child 19996 52b437586435
permissions -rw-r--r--
minirst: generate tables as a list of joined lines
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10444
e99e0e077bc4 minirst: report pruned container types
Martin Geisler <mg@lazybytes.net>
parents: 10443
diff changeset
     1
from pprint import pprint
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     2
from mercurial import minirst
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
     3
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
     4
def debugformat(text, form, **kwargs):
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
     5
    if form == 'html':
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
     6
        print "html format:"
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
     7
        out = minirst.format(text, style=form, **kwargs)
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
     8
    else:
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
     9
        print "%d column format:" % form
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    10
        out = minirst.format(text, width=form, **kwargs)
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    11
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    12
    print "-" * 70
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    13
    if type(out) == tuple:
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    14
        print out[0][:-1]
10444
e99e0e077bc4 minirst: report pruned container types
Martin Geisler <mg@lazybytes.net>
parents: 10443
diff changeset
    15
        print "-" * 70
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    16
        pprint(out[1])
10444
e99e0e077bc4 minirst: report pruned container types
Martin Geisler <mg@lazybytes.net>
parents: 10443
diff changeset
    17
    else:
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    18
        print out[:-1]
15261
e2df5b866d22 minirst: add basic HTML formatting support
Matt Mackall <mpm@selenic.com>
parents: 15039
diff changeset
    19
    print "-" * 70
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    20
    print
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    21
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    22
def debugformats(title, text, **kwargs):
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    23
    print "== %s ==" % title
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    24
    debugformat(text, 60, **kwargs)
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    25
    debugformat(text, 30, **kwargs)
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    26
    debugformat(text, 'html', **kwargs)
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    27
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    28
paragraphs = """
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    29
This is some text in the first paragraph.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    30
9736
26d3ade60fa6 test-minirst: don't test on invalid reST input
Martin Geisler <mg@lazybytes.net>
parents: 9293
diff changeset
    31
  A small indented paragraph.
26d3ade60fa6 test-minirst: don't test on invalid reST input
Martin Geisler <mg@lazybytes.net>
parents: 9293
diff changeset
    32
  It is followed by some lines
26d3ade60fa6 test-minirst: don't test on invalid reST input
Martin Geisler <mg@lazybytes.net>
parents: 9293
diff changeset
    33
  containing random whitespace.
10289
987df17f85bb test-minirst: hide trailing whitespace from check-code
Matt Mackall <mpm@selenic.com>
parents: 10065
diff changeset
    34
 \n  \n   \nThe third and final paragraph.
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    35
"""
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    36
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    37
debugformats('paragraphs', paragraphs)
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    38
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    39
definitions = """
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    40
A Term
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    41
  Definition. The indented
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    42
  lines make up the definition.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    43
Another Term
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    44
  Another definition. The final line in the
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    45
   definition determines the indentation, so
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    46
    this will be indented with four spaces.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    47
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    48
  A Nested/Indented Term
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    49
    Definition.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    50
"""
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    51
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    52
debugformats('definitions', definitions)
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    53
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    54
literals = r"""
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    55
The fully minimized form is the most
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    56
convenient form::
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    57
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    58
  Hello
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    59
    literal
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    60
      world
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    61
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    62
In the partially minimized form a paragraph
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    63
simply ends with space-double-colon. ::
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    64
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    65
  ////////////////////////////////////////
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    66
  long un-wrapped line in a literal block
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    67
  \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    68
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    69
::
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    70
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    71
  This literal block is started with '::',
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    72
    the so-called expanded form. The paragraph
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    73
      with '::' disappears in the final output.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    74
"""
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    75
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
    76
debugformats('literals', literals)
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    77
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    78
lists = """
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    79
- This is the first list item.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    80
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    81
  Second paragraph in the first list item.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    82
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    83
- List items need not be separated
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    84
  by a blank line.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    85
- And will be rendered without
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    86
  one in any case.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    87
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    88
We can have indented lists:
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    89
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    90
  - This is an indented list item
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    91
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    92
  - Another indented list item::
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    93
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    94
      - A literal block in the middle
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    95
            of an indented list.
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    96
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    97
      (The above is not a list item since we are in the literal block.)
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    98
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
    99
::
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   100
9291
cd5b6a11b607 minirst: indent literal blocks with two spaces
Martin Geisler <mg@lazybytes.net>
parents: 9156
diff changeset
   101
  Literal block with no indentation (apart from
cd5b6a11b607 minirst: indent literal blocks with two spaces
Martin Geisler <mg@lazybytes.net>
parents: 9156
diff changeset
   102
  the two spaces added to all literal blocks).
9739
75cff8f12910 minirst: support enumerated lists
Martin Geisler <mg@lazybytes.net>
parents: 9736
diff changeset
   103
75cff8f12910 minirst: support enumerated lists
Martin Geisler <mg@lazybytes.net>
parents: 9736
diff changeset
   104
1. This is an enumerated list (first item).
75cff8f12910 minirst: support enumerated lists
Martin Geisler <mg@lazybytes.net>
parents: 9736
diff changeset
   105
2. Continuing with the second item.
75cff8f12910 minirst: support enumerated lists
Martin Geisler <mg@lazybytes.net>
parents: 9736
diff changeset
   106
75cff8f12910 minirst: support enumerated lists
Martin Geisler <mg@lazybytes.net>
parents: 9736
diff changeset
   107
(1) foo
75cff8f12910 minirst: support enumerated lists
Martin Geisler <mg@lazybytes.net>
parents: 9736
diff changeset
   108
(2) bar
75cff8f12910 minirst: support enumerated lists
Martin Geisler <mg@lazybytes.net>
parents: 9736
diff changeset
   109
75cff8f12910 minirst: support enumerated lists
Martin Geisler <mg@lazybytes.net>
parents: 9736
diff changeset
   110
1) Another
75cff8f12910 minirst: support enumerated lists
Martin Geisler <mg@lazybytes.net>
parents: 9736
diff changeset
   111
2) List
10447
e957cc7cbd14 minirst: support line blocks
Martin Geisler <mg@lazybytes.net>
parents: 10444
diff changeset
   112
e957cc7cbd14 minirst: support line blocks
Martin Geisler <mg@lazybytes.net>
parents: 10444
diff changeset
   113
Line blocks are also a form of list:
e957cc7cbd14 minirst: support line blocks
Martin Geisler <mg@lazybytes.net>
parents: 10444
diff changeset
   114
e957cc7cbd14 minirst: support line blocks
Martin Geisler <mg@lazybytes.net>
parents: 10444
diff changeset
   115
| This is the first line.
e957cc7cbd14 minirst: support line blocks
Martin Geisler <mg@lazybytes.net>
parents: 10444
diff changeset
   116
  The line continues here.
e957cc7cbd14 minirst: support line blocks
Martin Geisler <mg@lazybytes.net>
parents: 10444
diff changeset
   117
| This is the second line.
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   118
"""
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   119
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   120
debugformats('lists', lists)
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   121
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   122
options = """
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   123
There is support for simple option lists,
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   124
but only with long options:
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   125
13011
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   126
-X, --exclude  filter  an option with a short and long option with an argument
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   127
-I, --include          an option with both a short option and a long option
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   128
--all                  Output all.
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   129
--both                 Output both (this description is
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   130
                       quite long).
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   131
--long                 Output all day long.
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   132
13011
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   133
--par                 This option has two paragraphs in its description.
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   134
                      This is the first.
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   135
13011
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   136
                      This is the second.  Blank lines may be omitted between
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   137
                      options (as above) or left in (as here).
4936a04b6792 minirst: improved support for option lists.
Erik Zielke <ez@aragost.com>
parents: 13009
diff changeset
   138
9156
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   139
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   140
The next paragraph looks like an option list, but lacks the two-space
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   141
marker after the option. It is treated as a normal paragraph:
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   142
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   143
--foo bar baz
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   144
"""
c9c7e8cdac9c minimal reStructuredText parser
Martin Geisler <mg@lazybytes.net>
parents:
diff changeset
   145
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   146
debugformats('options', options)
9293
e48a48b754d3 minirst: parse field lists
Martin Geisler <mg@lazybytes.net>
parents: 9291
diff changeset
   147
e48a48b754d3 minirst: parse field lists
Martin Geisler <mg@lazybytes.net>
parents: 9291
diff changeset
   148
fields = """
10065
a1ae0ed78d1a minirst: improve layout of field lists
Martin Geisler <mg@lazybytes.net>
parents: 9739
diff changeset
   149
:a: First item.
a1ae0ed78d1a minirst: improve layout of field lists
Martin Geisler <mg@lazybytes.net>
parents: 9739
diff changeset
   150
:ab: Second item. Indentation and wrapping
a1ae0ed78d1a minirst: improve layout of field lists
Martin Geisler <mg@lazybytes.net>
parents: 9739
diff changeset
   151
     is handled automatically.
9293
e48a48b754d3 minirst: parse field lists
Martin Geisler <mg@lazybytes.net>
parents: 9291
diff changeset
   152
10065
a1ae0ed78d1a minirst: improve layout of field lists
Martin Geisler <mg@lazybytes.net>
parents: 9739
diff changeset
   153
Next list:
a1ae0ed78d1a minirst: improve layout of field lists
Martin Geisler <mg@lazybytes.net>
parents: 9739
diff changeset
   154
a1ae0ed78d1a minirst: improve layout of field lists
Martin Geisler <mg@lazybytes.net>
parents: 9739
diff changeset
   155
:small: The larger key below triggers full indentation here.
a1ae0ed78d1a minirst: improve layout of field lists
Martin Geisler <mg@lazybytes.net>
parents: 9739
diff changeset
   156
:much too large: This key is big enough to get its own line.
9293
e48a48b754d3 minirst: parse field lists
Martin Geisler <mg@lazybytes.net>
parents: 9291
diff changeset
   157
"""
e48a48b754d3 minirst: parse field lists
Martin Geisler <mg@lazybytes.net>
parents: 9291
diff changeset
   158
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   159
debugformats('fields', fields)
10443
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   160
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   161
containers = """
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   162
Normal output.
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   163
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   164
.. container:: debug
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   165
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   166
   Initial debug output.
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   167
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   168
.. container:: verbose
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   169
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   170
   Verbose output.
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   171
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   172
   .. container:: debug
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   173
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   174
      Debug output.
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   175
"""
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   176
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   177
debugformats('containers (normal)', containers)
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   178
debugformats('containers (verbose)', containers, keep=['verbose'])
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   179
debugformats('containers (debug)', containers, keep=['debug'])
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   180
debugformats('containers (verbose debug)', containers,
10443
62d484a81dfe minirst: support containers
Martin Geisler <mg@lazybytes.net>
parents: 10289
diff changeset
   181
            keep=['verbose', 'debug'])
10972
0a2c6948f5f4 doc, minirst: support hg interpreted text role
Martin Geisler <mg@aragost.com>
parents: 10447
diff changeset
   182
0a2c6948f5f4 doc, minirst: support hg interpreted text role
Martin Geisler <mg@aragost.com>
parents: 10447
diff changeset
   183
roles = """Please see :hg:`add`."""
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   184
debugformats('roles', roles)
10977
f4778f942a4e minirst: add test for sections
Martin Geisler <mg@lazybytes.net>
parents: 10972
diff changeset
   185
f4778f942a4e minirst: add test for sections
Martin Geisler <mg@lazybytes.net>
parents: 10972
diff changeset
   186
f4778f942a4e minirst: add test for sections
Martin Geisler <mg@lazybytes.net>
parents: 10972
diff changeset
   187
sections = """
10984
68b7d2d668ce minirst: support all recommended title adornments
Martin Geisler <mg@lazybytes.net>
parents: 10983
diff changeset
   188
Title
68b7d2d668ce minirst: support all recommended title adornments
Martin Geisler <mg@lazybytes.net>
parents: 10983
diff changeset
   189
=====
68b7d2d668ce minirst: support all recommended title adornments
Martin Geisler <mg@lazybytes.net>
parents: 10983
diff changeset
   190
68b7d2d668ce minirst: support all recommended title adornments
Martin Geisler <mg@lazybytes.net>
parents: 10983
diff changeset
   191
Section
68b7d2d668ce minirst: support all recommended title adornments
Martin Geisler <mg@lazybytes.net>
parents: 10983
diff changeset
   192
-------
68b7d2d668ce minirst: support all recommended title adornments
Martin Geisler <mg@lazybytes.net>
parents: 10983
diff changeset
   193
68b7d2d668ce minirst: support all recommended title adornments
Martin Geisler <mg@lazybytes.net>
parents: 10983
diff changeset
   194
Subsection
68b7d2d668ce minirst: support all recommended title adornments
Martin Geisler <mg@lazybytes.net>
parents: 10983
diff changeset
   195
''''''''''
10983
287a5cdf7743 minirst: correctly format sections containing inline markup
Martin Geisler <mg@lazybytes.net>
parents: 10977
diff changeset
   196
287a5cdf7743 minirst: correctly format sections containing inline markup
Martin Geisler <mg@lazybytes.net>
parents: 10977
diff changeset
   197
Markup: ``foo`` and :hg:`help`
287a5cdf7743 minirst: correctly format sections containing inline markup
Martin Geisler <mg@lazybytes.net>
parents: 10977
diff changeset
   198
------------------------------
10977
f4778f942a4e minirst: add test for sections
Martin Geisler <mg@lazybytes.net>
parents: 10972
diff changeset
   199
"""
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   200
debugformats('sections', sections)
12388
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   201
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   202
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   203
admonitions = """
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   204
.. note::
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   205
   This is a note
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   206
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   207
   - Bullet 1
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   208
   - Bullet 2
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   209
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   210
   .. warning:: This is a warning Second
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   211
      input line of warning
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   212
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   213
.. danger::
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   214
   This is danger
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   215
"""
75f044d4dbf5 minirst: Support for admonitions
Erik Zielke <ez@aragost.com>
parents: 10984
diff changeset
   216
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   217
debugformats('admonitions', admonitions)
12819
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   218
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   219
comments = """
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   220
Some text.
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   221
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   222
.. A comment
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   223
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   224
   .. An indented comment
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   225
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   226
   Some indented text.
13009
54be08fa4d1d minirst: modified minirst to also recognize empty comments.
Erik Zielke <ez@aragost.com>
parents: 12865
diff changeset
   227
54be08fa4d1d minirst: modified minirst to also recognize empty comments.
Erik Zielke <ez@aragost.com>
parents: 12865
diff changeset
   228
..
54be08fa4d1d minirst: modified minirst to also recognize empty comments.
Erik Zielke <ez@aragost.com>
parents: 12865
diff changeset
   229
54be08fa4d1d minirst: modified minirst to also recognize empty comments.
Erik Zielke <ez@aragost.com>
parents: 12865
diff changeset
   230
Empty comment above
12819
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   231
"""
5082e2f3f8e0 minirst: ignore comments
Martin Geisler <mg@lazybytes.net>
parents: 12388
diff changeset
   232
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   233
debugformats('comments', comments)
15037
df47381b41d6 minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents: 13011
diff changeset
   234
15039
c981f4a9ea74 minirst: add a helper function to build an RST table from an array
Matt Mackall <mpm@selenic.com>
parents: 15037
diff changeset
   235
c981f4a9ea74 minirst: add a helper function to build an RST table from an array
Matt Mackall <mpm@selenic.com>
parents: 15037
diff changeset
   236
data = [['a', 'b', 'c'],
c981f4a9ea74 minirst: add a helper function to build an RST table from an array
Matt Mackall <mpm@selenic.com>
parents: 15037
diff changeset
   237
         ['1', '2', '3'],
c981f4a9ea74 minirst: add a helper function to build an RST table from an array
Matt Mackall <mpm@selenic.com>
parents: 15037
diff changeset
   238
         ['foo', 'bar', 'baz this list is very very very long man']]
c981f4a9ea74 minirst: add a helper function to build an RST table from an array
Matt Mackall <mpm@selenic.com>
parents: 15037
diff changeset
   239
16815
e740746ea557 minirst: generate tables as a list of joined lines
Olav Reinert <seroton10@gmail.com>
parents: 15263
diff changeset
   240
rst = minirst.maketable(data, 2, True)
e740746ea557 minirst: generate tables as a list of joined lines
Olav Reinert <seroton10@gmail.com>
parents: 15263
diff changeset
   241
table = ''.join(rst)
15039
c981f4a9ea74 minirst: add a helper function to build an RST table from an array
Matt Mackall <mpm@selenic.com>
parents: 15037
diff changeset
   242
c981f4a9ea74 minirst: add a helper function to build an RST table from an array
Matt Mackall <mpm@selenic.com>
parents: 15037
diff changeset
   243
print table
15037
df47381b41d6 minirst: add simple table support
Matt Mackall <mpm@selenic.com>
parents: 13011
diff changeset
   244
15263
70d7293c41d6 minirst: improve test harness
Matt Mackall <mpm@selenic.com>
parents: 15262
diff changeset
   245
debugformats('table', table)