Skip to content

docs(readme): Readability improvements and subheading emojis #55

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Documentation and examples are available at [table2ascii.rtfd.io](https://table2

## 🧑‍💻 Usage

### Convert lists to ASCII tables
### 🚀 Convert lists to ASCII tables

```py
from table2ascii import table2ascii
Expand All @@ -43,7 +43,7 @@ print(output)
"""
```

### Set first or last column headings
### 🏆 Set first or last column headings

```py
from table2ascii import table2ascii
Expand All @@ -63,7 +63,7 @@ print(output)
"""
```

### Set column widths and alignments
### 📰 Set column widths and alignments

```py
from table2ascii import table2ascii, Alignment
Expand All @@ -72,8 +72,8 @@ output = table2ascii(
header=["#", "G", "H", "R", "S"],
body=[["1", "30", "40", "35", "30"], ["2", "30", "40", "35", "30"]],
first_col_heading=True,
column_widths=[5] * 5, # [5, 5, 5, 5, 5]
alignments=[Alignment.LEFT] + [Alignment.RIGHT] * 4, # First is left, remaining 4 are right
column_widths=[5, 5, 5, 5, 5]
alignments=[Alignment.LEFT, Alignment.RIGHT, Alignment.RIGHT, Alignment.RIGHT, Alignment.RIGHT],
)

print(output)
Expand All @@ -88,15 +88,17 @@ print(output)
"""
```

### Use a preset style
### 🎨 Use a preset style

See a list of 30+ preset styles [here](https://table2ascii.readthedocs.io/en/latest/styles.html).

```py
from table2ascii import table2ascii, Alignment, PresetStyle

output = table2ascii(
header=["First", "Second", "Third", "Fourth"],
body=[["10", "30", "40", "35"], ["20", "10", "20", "5"]],
column_widths=[10] * 4,
column_widths=[10, 10, 10, 10],
style=PresetStyle.ascii_box
)

Expand Down Expand Up @@ -129,7 +131,7 @@ First Second Third Fourth
"""
```

### Define a custom style
### 🎲 Define a custom style

Check [`TableStyle`](https://github.com/DenverCoder1/table2ascii/blob/main/table2ascii/table_style.py) for more info and [`PresetStyle`](https://github.com/DenverCoder1/table2ascii/blob/main/table2ascii/preset_style.py) for examples.

Expand Down Expand Up @@ -157,10 +159,6 @@ print(output)
"""
```

## 🎨 Preset styles

See a list of all preset styles [here](https://table2ascii.readthedocs.io/en/latest/styles.html).

## ⚙️ Options

All parameters are optional.
Expand All @@ -172,23 +170,25 @@ All parameters are optional.
| `footer` | `List[Any]` | `None` | Last table row seperated by header row seperator. Values should support `str()`. |
| `column_widths` | `List[Optional[int]]` | `None` (automatic) | List of column widths in characters for each column |
| `alignments` | `List[Alignment]` | `None` (all centered) | Column alignments<br/>(ex. `[Alignment.LEFT, Alignment.CENTER, Alignment.RIGHT]`) |
| `style` | `TableStyle` | `double_thin_compact` | Table style to use for the table |
| `style` | `TableStyle` | `double_thin_compact` | Table style to use for the table\* |
| `first_col_heading` | `bool` | `False` | Whether to add a heading column seperator after the first column |
| `last_col_heading` | `bool` | `False` | Whether to add a heading column seperator before the last column |
| `cell_padding` | `int` | `1` | The minimum number of spaces to add between the cell content and the cell border. |

\*See a list of all preset styles [here](https://table2ascii.readthedocs.io/en/latest/styles.html).

See the [API Reference](https://table2ascii.readthedocs.io/en/latest/api.html) for more info.

## 👨‍🎨 Use cases

### Discord messages and embeds
### 🗨️ Discord messages and embeds

- Display tables nicely inside markdown code blocks on Discord
- Useful for making Discord bots with [Discord.py](https://github.com/Rapptz/discord.py)

![image](https://user-images.githubusercontent.com/20955511/116203248-2973c600-a744-11eb-97d8-4b75ed2845c9.png)

### Terminal outputs
### 💻 Terminal outputs

- Tables display nicely whenever monospace fonts are fully supported
- Tables make terminal outputs look more professional
Expand Down