diff --git a/README.md b/README.md index 90a838f..8d2d4ff 100644 --- a/README.md +++ b/README.md @@ -136,16 +136,52 @@ uv run \ ### 如何测试 -项目包含完整的测试套件,覆盖 CLI 和所有 Reader 实现。根据测试类型使用对应的 `uv run --with` 命令。 +项目包含完整的测试套件,覆盖 CLI、核心模块、工具函数和所有 Reader 实现。根据测试类型使用对应的 `uv run --with` 命令。 + +#### 测试目录结构 +- tests/test_cli/ - CLI 功能测试 +- tests/test_core/ - 核心模块测试(markdown, parser, advice_generator) +- tests/test_readers/ - 各格式 Reader 测试 +- tests/test_utils/ - 工具函数测试(file_detection, encoding_detection) #### 运行所有测试 ```bash uv run \ --with pytest \ --with pytest-cov \ + --with docling \ + --with "unstructured[pdf]" \ + --with "unstructured[docx]" \ + --with "unstructured[xlsx]" \ + --with "unstructured[pptx]" \ + --with "markitdown[pdf]" \ + --with "markitdown[docx]" \ + --with "markitdown[xlsx]" \ + --with "markitdown[pptx]" \ + --with "markitdown[xls]" \ + --with pypdf \ + --with markdownify \ + --with reportlab \ + --with pypandoc-binary \ + --with python-docx \ + --with python-pptx \ + --with pandas \ + --with tabulate \ + --with xlrd \ + --with olefile \ + --with trafilatura \ + --with domscribe \ + --with html2text \ + --with beautifulsoup4 \ + --with httpx \ + --with chardet \ + --with pyppeteer \ + --with selenium \ pytest ``` +注:由于依赖较多,也可以按测试类别分别运行(见下文)。 + #### 测试 DOCX reader ```bash uv run \ @@ -236,6 +272,39 @@ uv run \ pytest tests/test_readers/test_xls/ ``` +#### 测试 Core 模块 +```bash +# 测试核心模块(无需额外依赖) +uv run \ + --with pytest \ + pytest tests/test_core/ +``` + +#### 测试 Utils 模块 +```bash +# 测试工具函数(无需额外依赖) +uv run \ + --with pytest \ + pytest tests/test_utils/ +``` + +#### 测试 HTML 下载器 +```bash +# 测试 HTML 下载器 +uv run \ + --with pytest \ + --with trafilatura \ + --with domscribe \ + --with markitdown \ + --with html2text \ + --with beautifulsoup4 \ + --with httpx \ + --with chardet \ + --with pyppeteer \ + --with selenium \ + pytest tests/test_readers/test_html_downloader.py +``` + #### 运行特定测试文件或方法 ```bash # 运行特定测试文件(CLI 测试无需额外依赖) diff --git a/SKILL.md b/SKILL.md index 69ef6d1..959f085 100644 --- a/SKILL.md +++ b/SKILL.md @@ -1,6 +1,6 @@ --- name: lyxy-document-reader -description: 统一文档解析工具 - 将 DOCX、XLSX、PPTX、PDF、HTML/URL 转换为 Markdown。支持全文输出、字数统计、行数统计、标题提取、章节提取、正则搜索。当用户要求"读取/解析/打开文档"、上传 .docx/.xlsx/.pptx/.pdf/.html 文件、或提供 URL 时使用。 +description: 统一文档解析工具 - 将 DOCX、XLS、XLSX、PPTX、PDF、HTML/URL 转换为 Markdown。支持全文输出、字数统计、行数统计、标题提取、章节提取、正则搜索。当用户要求"读取/解析/打开文档"、上传 .docx/.xls/.xlsx/.pptx/.pdf/.html 文件、或提供 URL 时使用。 license: MIT compatibility: Requires Python 3.11+。优先使用 lyxy-runner-python skill,次选 uv run --with,降级到主机 Python。 --- @@ -27,6 +27,7 @@ python scripts/lyxy_document_reader.py <文件路径或URL> **支持格式** - DOCX(Word 文档) +- XLS(Excel 旧格式) - XLSX(Excel 表格) - PPTX(PowerPoint 演示文稿) - PDF(PDF 文档,支持 OCR) @@ -43,8 +44,8 @@ python scripts/lyxy_document_reader.py <文件路径或URL> ### 触发词 - 中文:"读取/解析/打开 文档/Word/Excel/PPT/PDF/网页" -- 英文:"read/parse/extract document/docx/xlsx/pptx/pdf/html" -- 文件扩展名:`.docx`、`.xlsx`、`.pptx`、`.pdf`、`.html`、`.htm` +- 英文:"read/parse/extract document/docx/xls/xlsx/pptx/pdf/html" +- 文件扩展名:`.docx`、`.xls`、`.xlsx`、`.pptx`、`.pdf`、`.html`、`.htm` - URL:`http://`、`https://` ## Quick Reference