From 03a954b867b668c6e03312319c071ab446e706e2 Mon Sep 17 00:00:00 2001 From: Doug Hellmann Date: Sun, 6 May 2012 21:22:14 -0400 Subject: update formatter documentation --- docs/source/list_commands.rst | 55 ++++++++++++++-------------- 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 + + + + + + + + + + + + + + + +
NameSize
build136
cliffdemo.log3252
Makefile5569
requirements.txt33
source782
+ 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 - - - - - - - - - - - - - - - -
NameSize
build136
cliffdemo.log3252
Makefile5569
requirements.txt33
source782
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 + + + + + + + + + + + + + + + +
FieldValue
Namesetup.py
Size6373
UID527
GID501
Modified Time1336353173.0
+ +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 -- cgit v1.2.1