You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
866 B

6 days ago
# -*- coding: utf-8 -*-
# t10 前置:导出文档仓明细树(目录 → folder.bru 有无 → .bru 名清单),供分区 README 撰写
import os, sys, io
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
DOCS = r'E:\code\crm-api-docs'
rows = []
for dp, dns, fns in os.walk(DOCS):
dns[:] = [d for d in dns if d.lower() != 'environments' and d != '.git']
rel = os.path.relpath(dp, DOCS).replace('\\', '/')
brus = sorted(fn for fn in fns if fn.endswith('.bru') and fn not in ('folder.bru', 'collection.bru'))
rows.append((rel, 'folder.bru' in fns, brus))
rows.sort()
for rel, has_folder, brus in rows:
depth = 0 if rel == '.' else rel.count('/') + 1
indent = '' if rel == '.' else ' ' * depth
print(f'{indent}{rel} [folder.bru={has_folder}] [n={len(brus)}]')
for b in brus:
print(f'{indent} {b}')