MCPcopy Create free account
hub / github.com/RASAAS/docmcp-knowledge / main

Function main

scripts/generate_classification_pages.py:233–277  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

231
232
233def main():
234 catalog = load_catalog()
235 tree = build_tree(catalog)
236
237 ZH_OUT.mkdir(parents=True, exist_ok=True)
238 EN_OUT.mkdir(parents=True, exist_ok=True)
239
240 # Index pages (overwrite existing classification.md)
241 zh_index_path = ZH_OUT.parent / "classification.md"
242 en_index_path = EN_OUT.parent / "classification.md"
243 zh_index_path.write_text(generate_zh_index(catalog, tree), encoding="utf-8")
244 en_index_path.write_text(generate_en_index(catalog, tree), encoding="utf-8")
245 print(f"[written] {zh_index_path}")
246 print(f"[written] {en_index_path}")
247
248 # Per-L1 pages
249 for l1 in catalog["l1_categories"]:
250 c = l1["code"]
251 n = l1["name"]
252 l2_dict = tree.get(c, {})
253 if not l2_dict:
254 continue
255
256 zh_path = ZH_OUT / f"{c}.md"
257 en_path = EN_OUT / f"{c}.md"
258 zh_path.write_text(generate_zh_l1_page(c, n, l2_dict), encoding="utf-8")
259 en_path.write_text(generate_en_l1_page(c, n, l2_dict), encoding="utf-8")
260 print(f"[written] {zh_path}")
261 print(f"[written] {en_path}")
262
263 # Print sidebar config for config.mts
264 print("\n=== VitePress sidebar items (paste into config.mts) ===")
265 print("// ZH sidebar for /zh/nmpa/classification/")
266 print("{")
267 print(" text: '分类目录', link: '/zh/nmpa/classification',")
268 print(" collapsed: true,")
269 print(" items: [")
270 for l1 in catalog["l1_categories"]:
271 c = l1["code"]
272 n = l1["name"]
273 print(f" {{ text: '{c} {n}', link: '/zh/nmpa/classification/{c}' }},")
274 print(" ],")
275 print("},")
276
277 print(f"\nGenerated {len(catalog['l1_categories'])} L1 pages (ZH + EN)")
278
279
280if __name__ == "__main__":

Calls 7

load_catalogFunction · 0.85
build_treeFunction · 0.85
generate_zh_l1_pageFunction · 0.85
generate_en_l1_pageFunction · 0.85
getMethod · 0.80
generate_zh_indexFunction · 0.70
generate_en_indexFunction · 0.70

Tested by

no test coverage detected