代码拉取完成,页面将自动刷新
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
import os
from collections import defaultdict
def to_camel_case(snake_str):
components = snake_str.split("_")
return components[0] + "".join(x.title() for x in components[1:])
with open("icons.md", "w") as icons_md:
icons_md.write("<!-- This file is generated using generate_icons_md.py -->\n")
icons_md.write("# Icons\n")
icons_md.write("\n")
icons_md.write("|Name|Icon|iOS|Android|\n")
icons_md.write("|---|---|---|---|\n")
for asset_dir in sorted(os.listdir("assets")):
if asset_dir == ".DS_Store":
continue
largest_svg_icon_path_by_weight = {}
ios_references_by_weight = defaultdict(list)
android_references_by_weight = defaultdict(list)
weights = set()
pdf_dir = os.path.join("assets", asset_dir, "PDF")
for filename in sorted(os.listdir(pdf_dir)):
components = filename.replace(".pdf", "").split("_")[2:]
weight = components[-1]
weights.add(weight)
ios_references_by_weight[weight].append(f'`{to_camel_case("_".join(components))}`')
svg_dir = os.path.join("assets", asset_dir, "SVG")
for filename in sorted(os.listdir(svg_dir)):
weight = filename.split("_")[-1].replace(".svg", "")
weights.add(weight)
android_references_by_weight[weight].append(f'`{filename.replace(".svg", "")}`')
largest_svg_icon_path_by_weight[weight] = filename
for weight in sorted(weights, reverse=True):
icons_md.write(
f"|{asset_dir} ({weight.title()})"
f'|<img src="{svg_dir}/{largest_svg_icon_path_by_weight[weight]}?raw=true" width="24" height="24">'
f'|{"<br />".join(ios_references_by_weight[weight])}'
f'|{"<br />".join(android_references_by_weight[weight])}|\n'
)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。