Skip to content
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

Missing icons sizes and styles #691

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
46 changes: 42 additions & 4 deletions generate_icons_md.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import os
from collections import defaultdict

# Define the icon sizes and styles
icon_sizes = ["12", "16", "20", "24", "28", "32", "48"]
icon_styles = ["regular", "filled"]

def to_camel_case(snake_str):
components = snake_str.split("_")
return components[0] + "".join(x.title() for x in components[1:])


def write_file(icons_md, weight_type):
def write_icon_file(icons_md, weight_type):
icons_md.write("<!-- This file is generated using generate_icons_md.py -->\n")
icons_md.write(f"# {weight_type.title()} Icons\n")
icons_md.write("\n")
Expand Down Expand Up @@ -51,8 +53,44 @@ def write_file(icons_md, weight_type):
f'|{"<br />".join(android_references_by_weight[weight])}|\n'
)

def check_missing_icons():
missing_icons_dict = {}
for folder in os.listdir("assets"):
svg_dir = os.path.join("assets", folder, "SVG")
if os.path.exists(svg_dir):
icon_name = folder.lower().replace(" ", "_")
for style in icon_styles:
missing_sizes = []
for size in icon_sizes:
filename = f"ic_fluent_{icon_name}_{size}_{style}.svg"
if not os.path.exists(os.path.join(svg_dir, filename)):
missing_sizes.append(size)
if missing_sizes:
missing_icons_dict.setdefault((folder, style), []).extend(missing_sizes)

# Convert the dictionary into a list of tuples
missing_icons = [(icon_name, style, ", ".join(sizes)) for (icon_name, style), sizes in missing_icons_dict.items()]
return missing_icons

# Function to generate Markdown file listing missing icons
def write_missing_icons_file(md_file):
missing_icons = check_missing_icons()
# Sort the missing icons alphabetically by icon name
missing_icons.sort(key=lambda x: x[0])

md_file.write("<!-- This file is generated by a script to list missing icons -->\n")
md_file.write("# Missing Sizes and Styles\n\n")
md_file.write("| Icon Name | Style | Size |\n")
md_file.write("|-----------|-------|------|\n")
for item in missing_icons:
if len(item) == 3:
md_file.write(f"| {item[0]} | {item[1].title()} | {item[2]} |\n")

with open("icons_filled.md", "w") as icons_filled_md:
write_file(icons_filled_md, "filled")
write_icon_file(icons_filled_md, "filled")

with open("icons_regular.md", "w") as icons_regular_md:
write_file(icons_regular_md, "regular")
write_icon_file(icons_regular_md, "regular")

with open("missing_icons.md", "w") as missing_icons_md:
write_missing_icons_file(missing_icons_md)
Loading
Loading