83 lines
2.5 KiB
Python
83 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
生成 Fortran 重构追踪 Markdown 文档。
|
|
|
|
用法: python3 generate_tracking.py > FORTRAN_TRACKING.md
|
|
"""
|
|
|
|
import csv
|
|
import os
|
|
|
|
def main():
|
|
csv_path = "/home/fmq/program/tlusty/tl208-s54/rust/fortran_analysis.csv"
|
|
|
|
with open(csv_path, 'r') as f:
|
|
reader = csv.DictReader(f)
|
|
rows = list(reader)
|
|
|
|
# 统计
|
|
total = len(rows)
|
|
done = sum(1 for r in rows if r['status'] == 'done')
|
|
pending = sum(1 for r in rows if r['status'] == 'pending')
|
|
pure = sum(1 for r in rows if r['is_pure'] == 'True')
|
|
has_io = sum(1 for r in rows if r['has_io'] == 'True')
|
|
|
|
# 打印 Markdown 头
|
|
print("""# Fortran 重构追踪表
|
|
|
|
> 自动生成,请勿手动修改。运行 `python3 scripts/generate_tracking.py > FORTRAN_TRACKING.md` 更新。
|
|
|
|
## 统计
|
|
|
|
| 指标 | 数量 |
|
|
|------|------|
|
|
| 总单元数 | {total} |
|
|
| 已完成 | {done} |
|
|
| 待处理 | {pending} |
|
|
| 纯函数 | {pure} |
|
|
| 有文件 I/O | {has_io} |
|
|
| 完成率 | {rate:.1f}% |
|
|
|
|
## 状态说明
|
|
|
|
- ✅ `done` - 已重构为 Rust
|
|
- ⬜ `pending` - 待处理
|
|
- 🔄 `in_progress` - 进行中
|
|
- ⏭️ `skip` - 跳过 (I/O 依赖或暂不处理)
|
|
|
|
## 类型说明
|
|
|
|
- **纯函数**: 无 COMMON 依赖、无文件 I/O、无外部调用依赖
|
|
- **COMMON 依赖**: 需要状态结构体
|
|
- **调用依赖**: 调用其他子程序,需要先实现依赖
|
|
|
|
## 完整追踪表
|
|
|
|
""".format(total=total, done=done, pending=pending, pure=pure, has_io=has_io, rate=100*done/total))
|
|
|
|
# 表格头
|
|
print("| Fortran 文件 | 单元名 | 类型 | 纯函数 | COMMON 依赖 | 调用依赖 | I/O | Rust 模块 | 状态 |")
|
|
print("|-------------|--------|------|--------|-------------|----------|-----|-----------|------|")
|
|
|
|
for r in rows:
|
|
# 状态图标
|
|
status_icon = "✅" if r['status'] == 'done' else "⬜"
|
|
|
|
# 纯函数标记
|
|
pure_mark = "✓" if r['is_pure'] == 'True' else ""
|
|
|
|
# I/O 标记
|
|
io_mark = "📁" if r['has_io'] == 'True' else ""
|
|
|
|
# 依赖显示
|
|
common_deps = r['common_deps'].replace('|', ', ') if r['common_deps'] else ""
|
|
call_deps = r['call_deps'].replace('|', ', ') if r['call_deps'] else ""
|
|
|
|
# Rust 模块链接
|
|
rust_mod = r['rust_module'].replace('src/math/', '') if r['rust_module'] else ""
|
|
|
|
print(f"| {r['fortran_file']} | {r['unit_name']} | {r['unit_type']} | {pure_mark} | {common_deps} | {call_deps} | {io_mark} | {rust_mod} | {status_icon} |")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|