From eb478d99760f17857514d471b19fb4e847a960ef Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 30 Oct 2022 20:52:57 -0600 Subject: [PATCH 1/2] docs: Move preset style docs and subheading emojis --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 48ee314..fc0605d 100644 --- a/README.md +++ b/README.md @@ -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 @@ -43,7 +43,7 @@ print(output) """ ``` -### Set first or last column headings +### 🏆 Set first or last column headings ```py from table2ascii import table2ascii @@ -63,7 +63,7 @@ print(output) """ ``` -### Set column widths and alignments +### 📰 Set column widths and alignments ```py from table2ascii import table2ascii, Alignment @@ -88,7 +88,9 @@ 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 @@ -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. @@ -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. @@ -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
(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 From c8e74bdad87d70ff34219fb639b979d88f4def8c Mon Sep 17 00:00:00 2001 From: Jonah Lawrence Date: Sun, 30 Oct 2022 20:54:53 -0600 Subject: [PATCH 2/2] Improve code readabilty --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fc0605d..c646278 100644 --- a/README.md +++ b/README.md @@ -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) @@ -98,7 +98,7 @@ 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 )