1
0
Files
lanyuanxiaoyao cd7988cbd5 feat: initial implementation of html2pptx with OpenSpec documentation
Add core Python script (yaml2pptx.py) for converting YAML to PowerPoint:
- Element rendering: text, image, shape, table, chart
- Template system with placeholders
- PPTX generation with python-pptx

OpenSpec workflow setup:
- 3 archived changes: browser-preview, template-dir-cli, yaml-to-pptx
- 7 main specifications covering all core modules
- Config and documentation structure

30 files changed, 4984 insertions(+)
2026-03-02 14:28:25 +08:00

41 lines
1.9 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 1. 添加命令行参数
- [x] 1.1 在 `parse_args` 函数中添加 `--template-dir` 参数定义
- [x] 1.2 设置参数类型为 `str`,默认值为 `None`
- [x] 1.3 添加清晰的帮助信息,说明参数用途和路径格式
## 2. 修改 Template 类
- [x] 2.1 修改 `Template.__init__` 方法签名,将 `templates_dir='templates'` 改为 `templates_dir=None`
- [x] 2.2 添加 templates_dir 为 None 的检查,抛出清晰的错误信息
- [x] 2.3 添加模板名称验证,检查是否包含 `/``\` 路径分隔符
- [x] 2.4 移除 `if not template_path.is_absolute() and not template_path.exists()` 的逻辑
- [x] 2.5 直接使用 `Path(templates_dir) / f"{template_file}.yaml"` 构建模板路径
- [x] 2.6 改进模板文件不存在时的错误信息,包含查找位置和期望路径
## 3. 修改 Presentation 类
- [x] 3.1 修改 `Presentation.__init__` 方法签名,将 `templates_dir='templates'` 改为 `templates_dir=None`
- [x] 3.2 确保 templates_dir 参数正确传递给 Template 类
## 4. 修改 main 函数
- [x] 4.1 从 `args.template_dir` 获取参数值
- [x] 4.2 将 `templates_dir=args.template_dir` 传递给 Presentation 构造函数
## 5. 错误信息优化
- [x] 5.1 实现"未指定模板目录"错误信息,包含使用建议
- [x] 5.2 实现"模板名称包含路径分隔符"错误信息,包含正确格式示例
- [x] 5.3 实现"模板文件不存在"错误信息,包含查找位置、期望路径和解决建议
## 6. 测试验证
- [x] 6.1 测试不使用模板的纯自定义幻灯片(不指定 --template-dir
- [x] 6.2 测试使用模板但未指定 --template-dir 的错误提示
- [x] 6.3 测试使用绝对路径指定 template-dir
- [x] 6.4 测试使用相对路径指定 template-dir
- [x] 6.5 测试模板名称包含路径分隔符的错误提示
- [x] 6.6 测试模板文件不存在的错误提示
- [x] 6.7 在 Mac 和 Windows 上验证路径处理的跨平台兼容性