diff options
author | Doug Hellmann <doug.hellmann@dreamhost.com> | 2012-05-06 21:22:14 -0400 |
---|---|---|
committer | Doug Hellmann <doug.hellmann@dreamhost.com> | 2012-05-06 21:22:14 -0400 |
commit | 03a954b867b668c6e03312319c071ab446e706e2 (patch) | |
tree | 7f18a33ab8dbe206b3d85a30902d6f1eb125ece0 /docs/source | |
parent | 88c5454768f1b9e442a9aa618687d226cd19f965 (diff) | |
download | cliff-tablib-03a954b867b668c6e03312319c071ab446e706e2.tar.gz |
update formatter documentation
Diffstat (limited to 'docs/source')
-rw-r--r-- | docs/source/list_commands.rst | 55 | ||||
-rw-r--r-- | docs/source/show_commands.rst | 83 |
2 files changed, 95 insertions, 43 deletions
diff --git a/docs/source/list_commands.rst b/docs/source/list_commands.rst index fbca699..d4e697c 100644 --- a/docs/source/list_commands.rst +++ b/docs/source/list_commands.rst @@ -43,6 +43,31 @@ further manipulation. "Makefile",5569 "source",408 +html +---- + +The ``html`` formatter uses tablib_ to produce HTML output as a table. + +:: + + (.venv)$ cliffdemo files -f html + <table> + <thead> + <tr><th>Name</th> + <th>Size</th></tr> + </thead> + <tr><td>build</td> + <td>136</td></tr> + <tr><td>cliffdemo.log</td> + <td>3252</td></tr> + <tr><td>Makefile</td> + <td>5569</td></tr> + <tr><td>requirements.txt</td> + <td>33</td></tr> + <tr><td>source</td> + <td>782</td></tr> + </table> + json ---- @@ -90,34 +115,6 @@ sequence of mappings. - {Name: requirements.txt, Size: 33} - {Name: source, Size: 816} -.. _tablib: https://github.com/kennethreitz/tablib - - -html ----- - -The ``html`` formatter uses tablib_ to produce HTML output as a -sequence of mappings. - -:: - - (.venv)$ cliffdemo files -f html - <table> - <thead> - <tr><th>Name</th> - <th>Size</th></tr> - </thead> - <tr><td>build</td> - <td>136</td></tr> - <tr><td>cliffdemo.log</td> - <td>3252</td></tr> - <tr><td>Makefile</td> - <td>5569</td></tr> - <tr><td>requirements.txt</td> - <td>33</td></tr> - <tr><td>source</td> - <td>782</td></tr> - </table> Creating Your Own Formatter --------------------------- @@ -127,3 +124,5 @@ another formatter with your program by subclassing from :class:`cliff.formatters.base.ListFormatter` and registering the plugin in the ``cliff.formatter.list`` namespace. + +.. _tablib: https://github.com/kennethreitz/tablib diff --git a/docs/source/show_commands.rst b/docs/source/show_commands.rst index 5ad72de..0aa7d9f 100644 --- a/docs/source/show_commands.rst +++ b/docs/source/show_commands.rst @@ -27,26 +27,42 @@ commands. :class:`ShowOne` adds a command line switch to let the user specify the formatter they want, so you don't have to do any extra work in your application. -table ------ +html +---- -The ``table`` formatter uses PrettyTable_ to produce output -formatted for human consumption. +The ``html`` formatter uses tablib_ to produce HTML output as a table. -.. _PrettyTable: http://code.google.com/p/prettytable/ +:: + + (.venv)$ cliffdemo file -f html setup.py + <table> + <thead> + <tr><th>Field</th> + <th>Value</th></tr> + </thead> + <tr><td>Name</td> + <td>setup.py</td></tr> + <tr><td>Size</td> + <td>6373</td></tr> + <tr><td>UID</td> + <td>527</td></tr> + <tr><td>GID</td> + <td>501</td></tr> + <tr><td>Modified Time</td> + <td>1336353173.0</td></tr> + </table> + +json +---- + +The ``json`` formatter uses tablib_ to produce JSON output. :: - (.venv)$ cliffdemo file setup.py - +---------------+--------------+ - | Field | Value | - +---------------+--------------+ - | Name | setup.py | - | Size | 5825 | - | UID | 502 | - | GID | 20 | - | Modified Time | 1335569964.0 | - +---------------+--------------+ + (.venv)$ cliffdemo file -f json setup.py + [{"Field": "Name", "Value": "setup.py"}, {"Field": "Size", + "Value": 6373}, {"Field": "UID", "Value": 527}, {"Field": "GID", + "Value": 501}, {"Field": "Modified Time", "Value": 1336353173.0}] shell ----- @@ -68,6 +84,41 @@ parsing overhead in shell scripts. (.venv)$ echo $example_size 5916 +table +----- + +The ``table`` formatter uses PrettyTable_ to produce output +formatted for human consumption. + +.. _PrettyTable: http://code.google.com/p/prettytable/ + +:: + + (.venv)$ cliffdemo file setup.py + +---------------+--------------+ + | Field | Value | + +---------------+--------------+ + | Name | setup.py | + | Size | 5825 | + | UID | 502 | + | GID | 20 | + | Modified Time | 1335569964.0 | + +---------------+--------------+ + +yaml +---- + +The ``yaml`` formatter uses tablib_ to produce YAML output as a +sequence of mappings. + +:: + + (.venv)$ cliffdemo file -f yaml setup.py + - {Field: Name, Value: setup.py} + - {Field: Size, Value: 6373} + - {Field: UID, Value: 527} + - {Field: GID, Value: 501} + - {Field: Modified Time, Value: 1336353173.0} Creating Your Own Formatter --------------------------- @@ -77,3 +128,5 @@ another formatter with your program by subclassing from :class:`cliff.formatters.base.ShowFormatter` and registering the plugin in the ``cliff.formatter.show`` namespace. + +.. _tablib: https://github.com/kennethreitz/tablib |