Skip to content

Single guide screenshots. and add /sd/ dir to screenshot #17

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 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ With that pointed at a learn guide repo you can run:
python3 create_requirement_images.py
```
It will create images in the `generated_images` directory.

### Generate Single Learn Guide Image

```shell
python3 create_requirement_images.py --guide [Learn Guide Name]
# OR
python3 create_requirement_images.py -g [Learn Guide Name]
```
43 changes: 33 additions & 10 deletions create_requirement_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,13 @@ def make_libraries(libraries, position):
triangle_icon=triangle_icon,
)

def make_sd_dir(position):
make_line(
"sd",
position,
triangle_icon=right_triangle,
)

final_list_to_render = sort_libraries(libs)
if settings_required(final_list_to_render):
context["added_settings_toml"] = True
Expand All @@ -388,6 +395,7 @@ def make_libraries(libraries, position):
+ len(final_list_to_render) * LINE_SPACING
+ (project_files_count) * LINE_SPACING
+ (1 if context["added_settings_toml"] else 0) * LINE_SPACING
+ 1 * LINE_SPACING # /sd/ dir
)
img = Image.new("RGB", (OUT_WIDTH, image_height), "#303030")
draw = ImageDraw.Draw(img)
Expand All @@ -396,15 +404,23 @@ def make_libraries(libraries, position):
7
+ len(final_list_to_render)
+ project_files_count
+ (1 if context["added_settings_toml"] else 0),
+ (1 if context["added_settings_toml"] else 0)
+ 1, # for /sd/ dir
offset=(PADDING, PADDING),
)
print(f"fltr: {final_list_to_render}")
make_header((PADDING, PADDING), project_files, final_list_to_render)
make_libraries(
final_list_to_render,
(PADDING, PADDING + (LINE_SPACING * (7 + project_files_count))),
_libraries_position = (
PADDING,
PADDING + (LINE_SPACING * (7 + project_files_count)),
)
make_libraries(final_list_to_render, _libraries_position)
_sd_dir_position = (
76,
PADDING
+ (LINE_SPACING * (7 + project_files_count + len(final_list_to_render))),
)
make_sd_dir(_sd_dir_position)

img.save("generated_images/{}.png".format(image_name))

Expand Down Expand Up @@ -440,13 +456,20 @@ def cli(ctx):


@cli.command()
def learn():
@click.option(
"-g", "--guide", help="Guide Name of a single Learn Guide to generate an image for."
)
def learn(guide=None):
"""Generate images for a learn-style repo"""
with Pool() as pool:
for _ in pool.imap(
generate_learn_requirement_image, get_learn_guide_cp_projects()
):
pass
if guide is None:
with Pool() as pool:
for _ in pool.imap(
generate_learn_requirement_image, get_learn_guide_cp_projects()
):
pass
else:
print(f"generating image for single guide: {guide}")
generate_learn_requirement_image(guide)


@cli.command()
Expand Down