diff --git a/README.md b/README.md index c3ca897..eb0f0d0 100644 --- a/README.md +++ b/README.md @@ -70,8 +70,36 @@ DEPENDENCIES = { `--advice` 参数根据文件扩展名识别类型,检测当前平台,从 `config.DEPENDENCIES` 读取对应配置,生成 `uv run --with` 和 `pip install` 命令。 +## 快速开始 + +### 验证环境 + +首先验证项目可以正常运行: + +```bash +# 测试 --advice 功能(仅需 chardet) +uv run --with chardet python scripts/lyxy_document_reader.py test.pdf --advice +``` + +### 运行基础测试 + +```bash +# 运行 CLI 测试(验证项目基本功能) +uv run \ + --with pytest \ + --with chardet \ + pytest tests/test_cli/test_main.py::TestCLIAdviceOption -v +``` + ## 开发指南 +### 测试前置依赖说明 + +由于 `HtmlReader` 模块在导入时会加载 `cleaner.py`,但 `cleaner.py` 中的第三方库已改为动态导入,因此仅需基础依赖: +- **chardet**:编码检测 + +`beautifulsoup4` 仅在实际使用 HTML 清理功能时才需要,模块导入时不依赖。 + ### 如何添加新的 Reader 1. 在 `scripts/readers/` 下创建新目录 @@ -177,12 +205,18 @@ uv run \ #### 运行特定测试文件或方法 ```bash -# 运行特定测试文件 +# 运行特定测试文件(CLI 测试仅需 chardet) uv run \ --with pytest \ --with chardet \ pytest tests/test_cli/test_main.py +# 仅运行 --advice 相关测试(不需要额外依赖) +uv run \ + --with pytest \ + --with chardet \ + pytest tests/test_cli/test_main.py::TestCLIAdviceOption + # 运行特定测试类或方法 uv run \ --with pytest \ diff --git a/scripts/readers/html/cleaner.py b/scripts/readers/html/cleaner.py index 7ba0d87..2c35989 100644 --- a/scripts/readers/html/cleaner.py +++ b/scripts/readers/html/cleaner.py @@ -3,8 +3,6 @@ import re from typing import Optional, Tuple -from bs4 import BeautifulSoup - def clean_html_content(html_content: str) -> Tuple[Optional[str], Optional[str]]: """