pyRestTable

author:Pete R. Jemian
version:2020.0.2
release:2020.0.2+35.g6dbd9a5.dirty
published:Nov 09, 2020

source code documentation

Format a nice table in reST (restructured text)

User Interface Description
Table Construct a table in reST
addLabel() add label for one additional column
addRow() add list of items for one additional row
setLongtable() set longtable attribute
setTabularColumns() set use_tabular_columns & alignment attributes
reST() render the table in reST format
Table() Construct a table in reST (no row or column spans).
example_minimal() minimal example table
example_basic() basic example table
example_complicated() complicated example table
class pyRestTable.rest_table.Table[source]

Construct a table in reST (no row or column spans).

Parameters:

MAIN METHODS

addLabel(text) add label for one additional column
addRow(list_of_items) add list of items for one additional row
reST([indentation, fmt]) render the table in reST format

SUPPORTING METHODS

setLongtable([state]) set longtable attribute
setTabularColumns([state, column_spec]) set use_tabular_columns & alignment attributes
plain_table([indentation]) render the table in plain reST format
simple_table([indentation]) render the table in simple reST format
grid_table([indentation]) render the table in grid reST format
list_table([indentation]) render the table in list-table reST format:
html_table([indentation]) render the table in HTML
addLabel(text)[source]

add label for one additional column

Parameters:text (str) – column label text
Return int:number of labels
addRow(list_of_items)[source]

add list of items for one additional row

Parameters:list_of_items ([obj]) – list of items for one complete row
Return int:number of rows
find_widths()[source]

measure the maximum width of each column, considering possible line breaks in each cell

grid_table(indentation='')[source]

render the table in grid reST format

html_table(indentation='')[source]

render the table in HTML

list_table(indentation='')[source]

render the table in list-table reST format:

See:http://docutils.sourceforge.net/docs/ref/rst/directives.html
Frozen Delights!
Treat Quantity Description
Albatross 2.99 On a stick!
Crunchy Frog 1.49 If we took the bones out, it wouldn’t be crunchy, now would it?
Gannet Ripple 1.99 On a stick!
markdown_table(indentation='')[source]

render the table in GitHub-flavored markdown (not reST) format

see: https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#tables

plain_table(indentation='')[source]

render the table in plain reST format

reST(indentation='', fmt='simple')[source]

render the table in reST format

setLongtable(state=True)[source]

set longtable attribute

Parameters:longtable (bool) – True | False
setTabularColumns(state=True, column_spec=None)[source]

set use_tabular_columns & alignment attributes

Parameters:
  • state (bool) – True | False
  • column_spec ([str]) – list of column specifications
simple_table(indentation='')[source]

render the table in simple reST format

pyRestTable.rest_table.example_basic()[source]

basic example table

pyRestTable.rest_table.example_complicated()[source]

complicated example table

pyRestTable.rest_table.example_minimal()[source]

minimal example table