Skip to content

Commit 8f2e717

Browse files
authored
Merge pull request #17 from FoamyGuy/sd_dir
Single guide screenshots. and add /sd/ dir to screenshot
2 parents da6907b + ee7184f commit 8f2e717

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

Diff for: README.md

+8
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,11 @@ With that pointed at a learn guide repo you can run:
1616
python3 create_requirement_images.py
1717
```
1818
It will create images in the `generated_images` directory.
19+
20+
### Generate Single Learn Guide Image
21+
22+
```shell
23+
python3 create_requirement_images.py --guide [Learn Guide Name]
24+
# OR
25+
python3 create_requirement_images.py -g [Learn Guide Name]
26+
```

Diff for: create_requirement_images.py

+33-10
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,13 @@ def make_libraries(libraries, position):
370370
triangle_icon=triangle_icon,
371371
)
372372

373+
def make_sd_dir(position):
374+
make_line(
375+
"sd",
376+
position,
377+
triangle_icon=right_triangle,
378+
)
379+
373380
final_list_to_render = sort_libraries(libs)
374381
if settings_required(final_list_to_render):
375382
context["added_settings_toml"] = True
@@ -388,6 +395,7 @@ def make_libraries(libraries, position):
388395
+ len(final_list_to_render) * LINE_SPACING
389396
+ (project_files_count) * LINE_SPACING
390397
+ (1 if context["added_settings_toml"] else 0) * LINE_SPACING
398+
+ 1 * LINE_SPACING # /sd/ dir
391399
)
392400
img = Image.new("RGB", (OUT_WIDTH, image_height), "#303030")
393401
draw = ImageDraw.Draw(img)
@@ -396,15 +404,23 @@ def make_libraries(libraries, position):
396404
7
397405
+ len(final_list_to_render)
398406
+ project_files_count
399-
+ (1 if context["added_settings_toml"] else 0),
407+
+ (1 if context["added_settings_toml"] else 0)
408+
+ 1, # for /sd/ dir
400409
offset=(PADDING, PADDING),
401410
)
402411
print(f"fltr: {final_list_to_render}")
403412
make_header((PADDING, PADDING), project_files, final_list_to_render)
404-
make_libraries(
405-
final_list_to_render,
406-
(PADDING, PADDING + (LINE_SPACING * (7 + project_files_count))),
413+
_libraries_position = (
414+
PADDING,
415+
PADDING + (LINE_SPACING * (7 + project_files_count)),
407416
)
417+
make_libraries(final_list_to_render, _libraries_position)
418+
_sd_dir_position = (
419+
76,
420+
PADDING
421+
+ (LINE_SPACING * (7 + project_files_count + len(final_list_to_render))),
422+
)
423+
make_sd_dir(_sd_dir_position)
408424

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

@@ -440,13 +456,20 @@ def cli(ctx):
440456

441457

442458
@cli.command()
443-
def learn():
459+
@click.option(
460+
"-g", "--guide", help="Guide Name of a single Learn Guide to generate an image for."
461+
)
462+
def learn(guide=None):
444463
"""Generate images for a learn-style repo"""
445-
with Pool() as pool:
446-
for _ in pool.imap(
447-
generate_learn_requirement_image, get_learn_guide_cp_projects()
448-
):
449-
pass
464+
if guide is None:
465+
with Pool() as pool:
466+
for _ in pool.imap(
467+
generate_learn_requirement_image, get_learn_guide_cp_projects()
468+
):
469+
pass
470+
else:
471+
print(f"generating image for single guide: {guide}")
472+
generate_learn_requirement_image(guide)
450473

451474

452475
@cli.command()

0 commit comments

Comments
 (0)