Complicated example¶
These python commands setup the table:
1import pyRestTable
2t = pyRestTable.Table()
3t.addLabel('Name\nand\nAttributes')
4t.addLabel('Type')
5t.addLabel('Units')
6t.addLabel('Description\n(and Occurrences)')
7t.addRow( ['one,\ntwo', "buckle my", "shoe.\n\n\nthree,\nfour", "..."] )
8t.addRow( ['class', 'NX_FLOAT', '', None, ] )
9t.addRow( range(0,4) )
10t.addRow( [None, {'a': 1, 'b': 'dreamy'}, 1.234, range(3)] )
Format: print(t.reST(fmt=’simple’))¶
this reST code:
1========== ======================= ====== =================
2Name Type Units Description
3and (and Occurrences)
4Attributes
5========== ======================= ====== =================
6one, buckle my shoe. ...
7two
8
9 three,
10 four
11class NX_FLOAT None
120 1 2 3
13None {'a': 1, 'b': 'dreamy'} 1.234 [0, 1, 2]
14========== ======================= ====== =================
is rendered as:
Name |
Type |
Units |
Description |
---|---|---|---|
and |
(and Occurrences) |
||
Attributes |
|||
one, |
buckle my |
shoe. |
… |
two |
three, four |
||
class |
NX_FLOAT |
None |
|
0 |
1 |
2 |
3 |
None |
{‘a’: 1, ‘b’: ‘dreamy’} |
1.234 |
[0, 1, 2] |
Format: print(t.reST(fmt=’grid’))¶
this reST code:
1+------------+-------------------------+--------+-------------------+
2| Name | Type | Units | Description |
3| and | | | (and Occurrences) |
4| Attributes | | | |
5+============+=========================+========+===================+
6| one, | buckle my | shoe. | ... |
7| two | | | |
8| | | | |
9| | | three, | |
10| | | four | |
11+------------+-------------------------+--------+-------------------+
12| class | NX_FLOAT | | None |
13+------------+-------------------------+--------+-------------------+
14| 0 | 1 | 2 | 3 |
15+------------+-------------------------+--------+-------------------+
16| None | {'a': 1, 'b': 'dreamy'} | 1.234 | [0, 1, 2] |
17+------------+-------------------------+--------+-------------------+
is rendered as:
Name and Attributes |
Type |
Units |
Description (and Occurrences) |
---|---|---|---|
one, two |
buckle my |
shoe. three, four |
… |
class |
NX_FLOAT |
None |
|
0 |
1 |
2 |
3 |
None |
{‘a’: 1, ‘b’: ‘dreamy’} |
1.234 |
[0, 1, 2] |
Format: print(t.reST(fmt=’list-table’))¶
this reST code:
1.. list-table::
2 :header-rows: 1
3 :widths: 10 23 6 17
4
5 * - Name
6 and
7 Attributes
8 - Type
9 - Units
10 - Description
11 (and Occurrences)
12 * - one,
13 two
14 - buckle my
15 - shoe.
16
17
18 three,
19 four
20 - ...
21 * - class
22 - NX_FLOAT
23 -
24 -
25 * - 0
26 - 1
27 - 2
28 - 3
29 * - None
30 - {'a': 1, 'b': 'dreamy'}
31 - 1.234
32 - [0, 1, 2]
is rendered as:
Name and Attributes |
Type |
Units |
Description (and Occurrences) |
---|---|---|---|
one, two |
buckle my |
shoe. three, four |
… |
class |
NX_FLOAT |
||
0 |
1 |
2 |
3 |
None |
{‘a’: 1, ‘b’: ‘dreamy’} |
1.234 |
[0, 1, 2] |