收集目录下所有待处理的文件,跳过派生产物(*.outline.json / *.outline.md)。
(scan_dir: Path, extensions: set[str] | None)
| 134 | |
| 135 | |
| 136 | def collect_files(scan_dir: Path, extensions: set[str] | None) -> list[Path]: |
| 137 | """收集目录下所有待处理的文件,跳过派生产物(*.outline.json / *.outline.md)。""" |
| 138 | allowed = extensions if extensions else SUPPORTED_EXTENSIONS |
| 139 | files = [] |
| 140 | for file_path in sorted(scan_dir.rglob("*")): |
| 141 | if not file_path.is_file(): |
| 142 | continue |
| 143 | if file_path.suffix.lower() not in allowed: |
| 144 | continue |
| 145 | if file_path.name == ".gitkeep": |
| 146 | continue |
| 147 | # 跳过 convert.py 自己的派生产物(避免被再次处理) |
| 148 | if file_path.stem.lower().endswith(".outline"): |
| 149 | continue |
| 150 | files.append(file_path) |
| 151 | return files |
| 152 | |
| 153 | |
| 154 | # doc_path 的相对基准:默认项目根;--workspace 模式下由 main() 设为该 workspace 根, |