Skip to content

Commit d79644b

Browse files
committed
☕ ️update cli documentation and guidebook
- Added CLI section to the documentation. - Included toml dependency in pyproject.toml. - Improved the guidebook for better clarity and usability.
1 parent 4ca2f24 commit d79644b

File tree

12 files changed

+94
-146
lines changed

12 files changed

+94
-146
lines changed

BeatPrints/write.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ def render_singleline(
139139
size: int,
140140
anchor: Optional[str] = None,
141141
align: Literal["left", "center", "right"] = "left",
142-
direction: Literal["rtl", "ltr", "ttb"] = "ltr",
143142
) -> None:
144143
"""
145144
Renders a single line of text on the image with specified styling.
@@ -153,7 +152,6 @@ def render_singleline(
153152
size (int): The font size.
154153
anchor (str, optional): Text anchor for alignment.
155154
align (str, optional): Text alignment ("left", "center", "right").
156-
direction (str, optional): Text direction ("rtl", "ltr", "ttb").
157155
"""
158156
offset = 0
159157
formatted_text = group_by_font(text, fonts)
@@ -177,7 +175,6 @@ def render_singleline(
177175
font=font,
178176
anchor=anchor,
179177
align=align,
180-
direction=direction,
181178
embedded_color=True,
182179
)
183180

@@ -222,10 +219,9 @@ def text(
222219
anchor: Optional[str] = None,
223220
spacing: int = 0,
224221
align: Literal["left", "center", "right"] = "left",
225-
direction: Literal["rtl", "ltr", "ttb"] = "ltr",
226222
) -> None:
227223
"""
228-
Renders text on an image at a specified position with customizable font, size, color, alignment, direction, and spacing.
224+
Renders text on an image at a specified position with customizable font, size, color, alignment, and spacing.
229225
230226
Args:
231227
draw (ImageDraw.ImageDraw): The drawing context.
@@ -237,7 +233,6 @@ def text(
237233
anchor (str, optional): Text anchor for alignment.
238234
spacing (int, optional): Vertical spacing between lines.
239235
align (str, optional): Text alignment ("left", "center", "right").
240-
direction (str, optional): Text direction ("rtl", "ltr", "ttb").
241236
"""
242237
x, y = pos
243238

@@ -250,20 +245,12 @@ def text(
250245
# Call render_singleline drawing for each line
251246
for line in lines:
252247
render_singleline(
253-
draw,
254-
(x, y + y_offset),
255-
line,
256-
color,
257-
fonts,
258-
size,
259-
anchor,
260-
align,
261-
direction,
248+
draw, (x, y + y_offset), line, color, fonts, size, anchor, align
262249
)
263250
y_offset += size + scale + spacing
264251
else:
265252
# Draw a single line
266-
render_singleline(draw, pos, text, color, fonts, size, anchor, align, direction)
253+
render_singleline(draw, pos, text, color, fonts, size, anchor, align)
267254

268255

269256
def heading(

README.md

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -79,50 +79,11 @@ highlighted_lyrics = ly.select_lines(lyrics, "5-9")
7979
ps.track(metadata, highlighted_lyrics)
8080
```
8181

82-
## 🥞 CLI Setup
82+
## 🥞 CLI
8383

84-
To get started with the BeatPrints CLI, you'll need to set up a configuration file.
84+
Here’s a short video showing how to generate posters using the CLI. For more information refer to the documentation [here](https://beatprints.readthedocs.io/en/latest/guidebook/cli.html)
8585

86-
### Windows
87-
88-
1. Create a folder named `BeatPrints` in the following directory:
89-
90-
```python
91-
C:\Users\<YourUsername>\AppData\Roaming\BeatPrints\
92-
```
93-
94-
2. Inside this folder, create a file called `config.toml` with the following contents:
95-
96-
```toml
97-
[general]
98-
search_limit = 7
99-
output_directory = "<path-to-save-your-posters>"
100-
101-
[credentials]
102-
client_id = "your-client-id"
103-
client_secret = "your-client-secret"
104-
```
105-
106-
Replace `<path-to-save-your-posters>` with the path where you'd like to save the generated posters, and fill in the `client_id` and `client_secret` with your Spotify credentials.
107-
108-
### Linux or macOS
109-
110-
1. Create a folder named `BeatPrints` in your `~/.config/` directory:
111-
112-
```python
113-
~/.config/BeatPrints/
114-
```
115-
116-
3. Inside this folder, create a file called `config.toml` with the same contents as mentioned above.
117-
118-
### Running the CLI
119-
120-
Once the config file is set up, you can run the BeatPrints CLI:
121-
122-
1. Open your terminal.
123-
2. Type `beatprints` and press Enter.
124-
125-
Your poster will be saved in the output directory you specified in the `config.toml` file.
86+
https://github.com/user-attachments/assets/3efb7028-c533-4bf4-880b-da3a71f8a3db
12687

12788
## 🖼️ Examples
12889

cli/exutils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from questionary import Style
66
from typing import List, Union
77

8-
from BeatPrints.spotify import TrackMetadata, AlbumMetadata
8+
from BeatPrints import spotify
99

1010
default = Style(
1111
[
@@ -37,7 +37,7 @@ def clear() -> None:
3737
print(BEATPRINTS_ANSI)
3838

3939

40-
def tablize_track(tracks: List[TrackMetadata]):
40+
def tablize_track(tracks: List[spotify.TrackMetadata]):
4141
"""
4242
Creates a pretty table for displaying track search results.
4343
"""
@@ -55,7 +55,7 @@ def tablize_track(tracks: List[TrackMetadata]):
5555
return table
5656

5757

58-
def tablize_albums(albums: List[AlbumMetadata]) -> Table:
58+
def tablize_albums(albums: List[spotify.AlbumMetadata]) -> Table:
5959
"""
6060
Creates a pretty table for displaying album search results.
6161
"""

docs/conf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,17 @@
1111
project = "BeatPrints"
1212
copyright = "2024, elysianmyst"
1313
author = "elysianmyst"
14-
release = "v1.0.4"
14+
release = "v1.0.5"
1515

1616
# -- General configuration ---------------------------------------------------
1717
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
1818

19-
extensions = ["sphinx.ext.autodoc", "sphinx.ext.napoleon", "sphinx_copybutton"]
19+
extensions = [
20+
"sphinx.ext.autodoc",
21+
"sphinx.ext.napoleon",
22+
"sphinx_copybutton",
23+
"sphinxcontrib.video",
24+
]
2025

2126
templates_path = ["_templates"]
2227
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]

docs/guidebook/cli.rst

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
🥞 CLI Setup
2+
------------
3+
4+
To get started with the BeatPrints CLI, you'll need to set up a configuration file.
5+
6+
Windows
7+
~~~~~~~
8+
9+
1. Create a folder named ``BeatPrints`` in the following directory:
10+
11+
.. code:: python
12+
13+
C:\Users\<YourUsername>\AppData\Roaming\
14+
15+
2. Inside this folder, create a file called ``config.toml`` with the
16+
following contents:
17+
18+
.. code:: toml
19+
20+
[general]
21+
search_limit = 7
22+
output_directory = "<path-to-save-your-posters>"
23+
24+
[credentials]
25+
client_id = "your-client-id"
26+
client_secret = "your-client-secret"
27+
28+
Replace ``<path-to-save-your-posters>`` with the path where you'd like to save the generated posters, and fill in the ``client_id`` and ``client_secret`` with your Spotify credentials.
29+
30+
31+
.. important::
32+
33+
If you're using **Windows**, please ensure you use **double backslashes** (``\\``) rather than a single backslash when specifying your output path. For example:
34+
35+
.. code:: python
36+
37+
output_directory = "C:\\Users\\<YourUsername>\\Downloads\\Posters"
38+
39+
Linux or macOS
40+
~~~~~~~~~~~~~~
41+
42+
1. Create a folder named ``BeatPrints`` in your ``~/.config/`` directory:
43+
44+
.. code:: python
45+
46+
~/.config/BeatPrints/
47+
48+
2. Inside this folder, create a file called ``config.toml`` with the same contents as mentioned above.
49+
50+
Running the CLI
51+
~~~~~~~~~~~~~~~
52+
53+
Once the config file is set up, you can run the BeatPrints CLI:
54+
55+
1. Open your terminal.
56+
2. Type ``beatprints`` and press Enter.
57+
58+
Your poster will be saved in the output directory you specified in the ``config.toml`` file.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Generate Posters
2-
================
1+
🎨 Code Examples
2+
===================
33

4-
This is a quick guide on how you can generate posters using *BeatPrints*.
4+
This is a quick guide on how to generate posters using **BeatPrints** through code.
55

66
🎷 Track Posters
77
^^^^^^^^^^^^^^^^^
@@ -64,6 +64,8 @@ Like tracks, you can also create an album poster, follow these steps below.
6464
# Generate the album poster
6565
ps.album(metadata)
6666
67+
This is a basic guide on generating your posters. You can extend it by creating your own functions to make them more useful.
68+
6769
.. tip::
6870

6971
Use a hyphen (-) between the track/album and the artist for more accurate results.

docs/guidebook/index.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ Quick Start
44
A quick short guide on how to generate track or album posters.
55

66
.. toctree::
7+
:maxdepth: 1
78

8-
guide
9+
cli
10+
generate

docs/index.rst

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ keys:
4949

5050
.. code:: python
5151
52-
SPOTIFY_CLIENT_ID = ""
53-
SPOTIFY_CLIENT_SECRET = ""
52+
SPOTIFY_CLIENT_ID = "<your-client-id>"
53+
SPOTIFY_CLIENT_SECRET = "<your-client-secret>"
5454
5555
You can get these from the `Spotify Developer Dashboard <https://developer.spotify.com/dashboard/>`_ by creating a new app with **Web API** as the scope.
5656

@@ -76,7 +76,7 @@ Here’s how you can create your first poster:
7676
sp = spotify.Spotify(CLIENT_ID, CLIENT_SECRET)
7777
7878
# Search for a track
79-
search = sp.get_track("Juno Clairo", limit=1)
79+
search = sp.get_track("Saturn - SZA", limit=1)
8080
8181
# Get the track's metadata and lyrics
8282
metadata = search[0]
@@ -86,55 +86,13 @@ Here’s how you can create your first poster:
8686
# Generate the track poster
8787
ps.track(metadata, highlighted_lyrics)
8888
89-
🥞 CLI Setup
90-
------------
89+
🥞 CLI
90+
------
9191

92-
To get started with the BeatPrints CLI, you'll need to set up a configuration file.
92+
Here’s a short video showing how to generate posters using the CLI. For more information refer to the documentation `here <https://beatprints.readthedocs.io/en/latest/guidebook/cli.html>`_
9393

94-
Windows
95-
~~~~~~~
96-
97-
1. Create a folder named ``BeatPrints`` in the following directory:
98-
99-
.. code:: python
100-
101-
C:\Users\<YourUsername>\AppData\Roaming\BeatPrints\
102-
103-
2. Inside this folder, create a file called ``config.toml`` with the
104-
following contents:
105-
106-
.. code:: toml
107-
108-
[general]
109-
search_limit = 7
110-
output_directory = "<path-to-save-your-posters>"
111-
112-
[credentials]
113-
client_id = "your-client-id"
114-
client_secret = "your-client-secret"
115-
116-
Replace ``<path-to-save-your-posters>`` with the path where you'd like to save the generated posters, and fill in the ``client_id`` and ``client_secret`` with your Spotify credentials.
117-
118-
Linux or macOS
119-
~~~~~~~~~~~~~~
120-
121-
1. Create a folder named ``BeatPrints`` in your ``~/.config/`` directory:
122-
123-
.. code:: python
124-
125-
~/.config/BeatPrints/
126-
127-
2. Inside this folder, create a file called ``config.toml`` with the same contents as mentioned above.
128-
129-
Running the CLI
130-
~~~~~~~~~~~~~~~
131-
132-
Once the config file is set up, you can run the BeatPrints CLI:
133-
134-
1. Open your terminal.
135-
2. Type ``beatprints`` and press Enter.
136-
137-
Your poster will be saved in the output directory you specified in the ``config.toml`` file.
94+
.. video:: https://github.com/user-attachments/assets/3efb7028-c533-4bf4-880b-da3a71f8a3db
95+
:width: 700
13896

13997
🖼️ Examples
14098
-----------

docs/misc/FAQ.rst

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,3 @@ The lack of support for some languages is due to the large size of font files (a
1616
I've got a really interesting idea for a feature for BeatPrints.
1717
----------------------------------------------------------------
1818
I really appreciate that you want to contribute! Feel free to create an issue on the GitHub page. Just keep in mind that I started this project for fun, so actively maintaining it can be tough for me. I’m not always able to dedicate a lot of time, but I truly appreciate all ideas and contributions, and I’ll try my best to work on it when I can. Your suggestions are always welcome!
19-
20-
How do I fix the libraqm error?
21-
-------------------------------
22-
23-
If you encounter this following error:
24-
25-
.. code::
26-
27-
"KeyError: 'setting text direction, language or font features is not supported without libraqm'"
28-
29-
For Windows Users
30-
~~~~~~~~~~~~~~~~~
31-
You can resolve this by downloading ``fribidi.dll`` from `here <https://www.dllme.com/dll/files/fribidi>`_ and placing it in your Python directory, such as:
32-
33-
.. code::
34-
35-
C:\Program Files\Python312\
36-
37-
For macOS Users
38-
~~~~~~~~~~~~~~~
39-
If you run into the same issue, fix it by reinstalling Pillow with the correct configuration:
40-
41-
.. code::
42-
43-
pip uninstall Pillow
44-
pip install Pillow --global-option="build_ext" --config-settings="-I=/opt/homebrew/Cellar"

docs/misc/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Misc
2-
====
1+
Miscellaneous
2+
=============
33

44
.. toctree::
55

0 commit comments

Comments
 (0)