pyRestTable#
- author
Pete R. Jemian
- version
2020.0
- release
2020.0.8
- published
Mar 12, 2023
source code documentation#
Format a nice table in reST (restructured text).
User Interface |
Description |
---|---|
Construct a table in reST |
|
|
add label for one additional column |
|
add list of items for one additional row |
|
set longtable attribute |
|
set use_tabular_columns & alignment attributes |
|
render the table in reST format |
|
Construct a table in reST (no row or column spans). |
minimal example table |
|
basic example table |
|
complicated example table |
- class pyRestTable.rest_table.Table(dd={})[source]#
Construct a table in reST (no row or column spans).
- Parameters
use_tabular_columns (bool) – if True, embed table in Sphinx ‘.. tabularcolumns:: |%s|’ % alignment’ role
alignment ([str]) – with use_tabular_columns, each list item is a column format string, as specified by LaTeX tabulary package format: http://sphinx-doc.org/markup/misc.html?highlight=tabularcolumns#directive-tabularcolumns
longtable (bool) – with use_tabular_columns, if True, add Sphinx :longtable: directive
dd (dict) – dictionary with content for the table
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
dict_to_table
(dd)Make (or append to) table from dictionary.
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
- dict_to_table(dd)[source]#
Make (or append to) table from dictionary.
PARAMETERS
- dd dict:
Dictionary to create (or append to) table. Keys are the column labels, values are the rows. Empty cells, created if the values are not of equal lengths, will be filled with
""
(empty string).
(New in version 2020.0.8)
- find_widths()[source]#
measure the maximum width of each column, considering possible line breaks in each cell
- list_table(indentation='')[source]#
render the table in list-table reST format:
# 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
- setLongtable(state=True)[source]#
set longtable attribute
- Parameters
longtable (bool) – True | False