构建 README 顶部数据概览。
(type_counts: dict[str, int], category_count: int)
| 120 | return "<br>".join(links) |
| 121 | |
| 122 | def build_stats_table(type_counts: dict[str, int], category_count: int) -> str: |
| 123 | """构建 README 顶部数据概览。""" |
| 124 | total = sum(type_counts.values()) |
| 125 | stat_items = [ |
| 126 | ("总收录", format_count(total), "频道 / 群组 / 机器人"), |
| 127 | ("分类", format_count(category_count), "主题索引"), |
| 128 | ("频道", format_count(type_counts.get("channel", 0)), "Channel"), |
| 129 | ("群组", format_count(type_counts.get("group", 0)), "Group"), |
| 130 | ] |
| 131 | if type_counts.get("bot", 0) > 0: |
| 132 | stat_items.append(("机器人", format_count(type_counts.get("bot", 0)), "Bot")) |
| 133 | |
| 134 | cells = [] |
| 135 | for label, value, hint in stat_items: |
| 136 | cells.append( |
| 137 | " " |
| 138 | f'<td align="center"><strong>{html.escape(value)}</strong><br>' |
| 139 | f'<sub>{html.escape(label)} · {html.escape(hint)}</sub></td>' |
| 140 | ) |
| 141 | |
| 142 | return "\n".join(["<table>", " <tr>", *cells, " </tr>", "</table>"]) |
| 143 | |
| 144 | def generate_readme(conn: sqlite3.Connection) -> str: |
| 145 | """从数据库生成 README.md 内容。""" |
no test coverage detected