
- 将 dataset、dataset_item 和 doc 类的首字母大写,以符合 Python 类命名惯例 - 更新相关模块中的导入和引用,以适应新的类名 - 此更改不影响功能,仅提高了代码的一致性和可读性
33 lines
980 B
Python
33 lines
980 B
Python
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# 添加项目根目录到sys.path
|
|
sys.path.append(str(Path(__file__).resolve().parent.parent))
|
|
from schema import Doc
|
|
|
|
def scan_docs_directory(workdir: str):
|
|
docs_dir = os.path.join(workdir, "docs")
|
|
|
|
doc_list = os.listdir(docs_dir)
|
|
|
|
to_return = []
|
|
|
|
for doc_name in doc_list:
|
|
doc_path = os.path.join(docs_dir, doc_name)
|
|
if os.path.isdir(doc_path):
|
|
markdown_files = []
|
|
for root, dirs, files in os.walk(doc_path):
|
|
for file in files:
|
|
if file.endswith(".md"):
|
|
markdown_files.append(os.path.join(root, file))
|
|
to_return.append(Doc(name=doc_name, path=doc_path, markdown_files=markdown_files))
|
|
|
|
return to_return
|
|
|
|
# 添加测试代码
|
|
if __name__ == "__main__":
|
|
workdir = os.path.join(os.path.dirname(__file__), "..", "workdir")
|
|
docs = scan_docs_directory(workdir)
|
|
print(docs)
|