Skip to content

Commit aafcfe5

Browse files
committed
Add column widths and alignments to readme examples
1 parent 7c7c579 commit aafcfe5

File tree

1 file changed

+34
-4
lines changed

1 file changed

+34
-4
lines changed

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,44 @@ print(output)
6565
"""
6666
```
6767

68+
```py
69+
from table2ascii import table2ascii
70+
71+
output = table2ascii(
72+
header=["#", "G", "H", "R", "S"],
73+
body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
74+
first_col_heading=True,
75+
column_widths=[5] * 5, # [5, 5, 5, 5, 5]
76+
alignments=[Alignment.LEFT] + [Alignment.RIGHT] * 4, # First is left, remaining 4 are right
77+
)
78+
79+
print(output)
80+
81+
"""
82+
╔═════╦═══════════════════════╗
83+
║ # ║ G H R S ║
84+
╟─────╫───────────────────────╢
85+
║ 1 ║ 30 40 35 30 ║
86+
║ 2 ║ 30 40 35 30 ║
87+
╚═════╩═══════════════════════╝
88+
"""
89+
```
90+
6891
## ⚙️ Options
6992

93+
All parameters are optional.
94+
7095
Soon table2ascii will support more options for customization.
7196

72-
| Option | Type | Default | Description |
73-
| :-----------------: | :----: | :-----: | :--------------------------------------------------------------: |
74-
| `first_col_heading` | `bool` | `False` | Whether to add a heading column seperator after the first column |
75-
| `last_col_heading` | `bool` | `False` | Whether to add a heading column seperator before the last column |
97+
| Option | Type | Default | Description |
98+
| :-----------------: | :-------: | :----------: | :------------------------------------------------------------------------------------: |
99+
| `header` | `List` | `None` | First row of table seperated by header row seperator |
100+
| `body` | `2D List` | `None` | List of rows for the main section of the table |
101+
| `footer` | `List` | `None` | Last row of table seperated by header row seperator |
102+
| `column_widths` | `List` | automatic | List of column widths in characters for each column |
103+
| `alignments` | `List` | all centered | Alignments for each column (ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT]`) |
104+
| `first_col_heading` | `bool` | `False` | Whether to add a heading column seperator after the first column |
105+
| `last_col_heading` | `bool` | `False` | Whether to add a heading column seperator before the last column |
76106

77107
## 👨‍🎨 Use cases
78108

0 commit comments

Comments
 (0)