Mercurial > public > mercurial-scm > hg-stable
diff tests/test-minirst.py @ 10443:62d484a81dfe
minirst: support containers
Text can be grouped into generic containers in reStructuredText:
.. container:: foo
This is text inside a "foo" container.
.. container:: bar
This is nested inside two containers.
The minirst parser now recognizes these containers. The containers are
either pruned completely from the output (included all nested blocks)
or they are simply un-indented. So if 'foo' and 'bar' containers are
kept, the above example will result in:
This is text inside a "foo" container.
This is nested inside two containers.
If only 'foo' containers are kept, we get:
This is text inside a "foo" container.
No output is made if only 'bar' containers are kept.
This feature will come in handy for implementing different levels of
help output (e.g., verbose and debug level help texts).
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Sun, 04 Oct 2009 22:03:41 +0200 |
parents | 987df17f85bb |
children | e99e0e077bc4 |
line wrap: on
line diff
--- a/tests/test-minirst.py Sat Feb 13 02:08:27 2010 +0100 +++ b/tests/test-minirst.py Sun Oct 04 22:03:41 2009 +0200 @@ -2,10 +2,10 @@ from mercurial import minirst -def debugformat(title, text, width): +def debugformat(title, text, width, **kwargs): print "%s formatted to fit within %d characters:" % (title, width) print "-" * 70 - print minirst.format(text, width) + print minirst.format(text, width, **kwargs) print "-" * 70 print @@ -143,3 +143,25 @@ debugformat('fields', fields, 60) debugformat('fields', fields, 30) + +containers = """ +Normal output. + +.. container:: debug + + Initial debug output. + +.. container:: verbose + + Verbose output. + + .. container:: debug + + Debug output. +""" + +debugformat('containers (normal)', containers, 60) +debugformat('containers (verbose)', containers, 60, keep=['verbose']) +debugformat('containers (debug)', containers, 60, keep=['debug']) +debugformat('containers (verbose debug)', containers, 60, + keep=['verbose', 'debug'])