refactor: 移除 doc 和 ppt reader 支持

移除对旧版 .doc 和 .ppt 格式的支持,以简化项目架构和减少维护负担。

变更内容:
- 删除 scripts/readers/doc/ 目录
- 删除 scripts/readers/ppt/ 目录
- 从 readers/__init__.py 中移除 DocReader 和 PptReader
- 从 utils/file_detection.py 中移除 is_valid_doc 和 is_valid_ppt
- 从 config.py 中移除 doc 和 ppt 依赖配置
- 从 advice_generator.py 中移除相关映射
- 更新 CLI 帮助文档
- 更新 README.md 文档
- 删除相关测试用例
- 删除相关规范文档
This commit is contained in:
2026-03-11 00:55:15 +08:00
parent fad0edc46a
commit 65c746c639
22 changed files with 9 additions and 564 deletions

View File

@@ -1 +0,0 @@
"""测试 DocReader 模块。"""

View File

@@ -1,44 +0,0 @@
"""测试所有 DOC Readers 的一致性。"""
import pytest
from readers.doc import markitdown, pypandoc
class TestDocReadersConsistency:
"""验证所有 DOC Readers 解析同一文件时核心文字内容一致。"""
def test_parsers_importable(self):
"""测试所有 parser 模块可以正确导入。"""
# 验证模块导入成功
assert markitdown is not None
assert pypandoc is not None
assert hasattr(markitdown, 'parse')
assert hasattr(pypandoc, 'parse')
def test_parser_functions_callable(self):
"""测试 parse 函数是可调用的。"""
assert callable(markitdown.parse)
assert callable(pypandoc.parse)
def test_all_readers_parse_same_content(self, simple_doc_path):
"""测试所有 Readers 解析同一文件时核心内容一致。"""
# 收集所有 readers 的解析结果
parsers = [
("markitdown", markitdown.parse),
("pypandoc", pypandoc.parse),
]
successful_results = []
for name, parser in parsers:
content, error = parser(simple_doc_path)
if content is not None and content.strip():
successful_results.append((name, content))
# 至少应该有一个 reader 成功解析,或者都不解析也可以(旧格式兼容性问题)
if len(successful_results) > 0:
# 验证所有成功的 readers 都包含核心内容
core_texts = ["测试文档", "第一段", "第二段"]
for name, content in successful_results:
# 至少包含一个核心文本
assert any(text in content for text in core_texts), \
f"{name} 解析结果不包含核心内容"

View File

@@ -1,49 +0,0 @@
"""测试 MarkItDown DOC Reader 的解析功能。"""
import pytest
import os
from readers.doc import markitdown
class TestMarkitdownDocReaderParse:
"""测试 MarkItDown DOC Reader 的 parse 方法。"""
def test_module_importable(self):
"""测试模块可以正确导入。"""
assert markitdown is not None
assert hasattr(markitdown, 'parse')
assert callable(markitdown.parse)
def test_file_not_exists(self, tmp_path):
"""测试文件不存在的情况。"""
non_existent_file = str(tmp_path / "non_existent.doc")
content, error = markitdown.parse(non_existent_file)
# 验证返回 None 和错误信息
assert content is None
assert error is not None
def test_parse_simple_doc(self, simple_doc_path):
"""测试解析简单 DOC 文件。"""
content, error = markitdown.parse(simple_doc_path)
# 只要不崩溃即可,不强制要求成功解析
if content is not None:
assert len(content.strip()) > 0
def test_parse_with_headings_doc(self, with_headings_doc_path):
"""测试解析带标题的 DOC 文件。"""
content, error = markitdown.parse(with_headings_doc_path)
# 只要不崩溃即可
if content is not None:
assert len(content.strip()) > 0
def test_parse_with_table_doc(self, with_table_doc_path):
"""测试解析带表格的 DOC 文件。"""
content, error = markitdown.parse(with_table_doc_path)
# 只要不崩溃即可
if content is not None:
assert len(content.strip()) > 0

View File

@@ -1,33 +0,0 @@
"""测试 pypandoc DOC Reader 的解析功能。"""
import pytest
import os
from readers.doc import pypandoc
class TestPypandocDocReaderParse:
"""测试 pypandoc DOC Reader 的 parse 方法。"""
def test_module_importable(self):
"""测试模块可以正确导入。"""
assert pypandoc is not None
assert hasattr(pypandoc, 'parse')
assert callable(pypandoc.parse)
def test_file_not_exists(self, tmp_path):
"""测试文件不存在的情况。"""
non_existent_file = str(tmp_path / "non_existent.doc")
content, error = pypandoc.parse(non_existent_file)
# 验证返回 None 和错误信息
assert content is None
assert error is not None
def test_parse_simple_doc(self, simple_doc_path):
"""测试解析简单 DOC 文件。"""
content, error = pypandoc.parse(simple_doc_path)
# pypandoc 可能需要额外依赖,只要不崩溃即可
if content is not None:
assert len(content.strip()) > 0