mirror of
https://github.com/tradecatlabs/vibe-coding-cn.git
synced 2026-08-07 08:07:45 +00:00
docs: remove references source fragments
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
- 新增检查脚本时,同步更新 `scripts/README.md`、`Makefile`、CI 和根目录 `AGENTS.md` 的命令清单。
|
||||
- `check-directory-docs.py` 对根 `.github/` 只要求 `AGENTS.md`,不要重新补 `.github/README.md`。
|
||||
- 修改 docs 线性 README 的主章节或锚点后,优先运行 `python3 scripts/sync-doc-toc.py`,再运行 `make test`。
|
||||
- 修改 `docs/references/sources/` 后,运行 `make sync-reference-readme`,再运行 `make test`。
|
||||
- 检查失败输出应包含文件路径、行号或可定位的错误信息。
|
||||
- 跳过目录必须明确,至少跳过 `.git`、`.history`、`node_modules` 和外部源码快照。
|
||||
|
||||
|
||||
@@ -11,4 +11,3 @@
|
||||
- `check-metadata.py`:`metadata/taxonomy.yml` 与 `metadata/redirects.yml` 路径和锚点检查脚本。
|
||||
- `check-ai-citation.py`:`llms.txt`、`assets/ai-citation/llms-full.txt` 与 AI 引用语料路径和锚点检查脚本。
|
||||
- `sync-doc-toc.py`:根据 `metadata/taxonomy.yml` 和文档锚点重建 docs 线性 README 的完整细粒度目录。
|
||||
- `build-reference-readme.py`:根据 `docs/references/sources/*.md` 生成并校验 `docs/references/README.md`。
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Build docs/references/README.md from ordered source fragments."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SOURCE_DIR = ROOT / "docs" / "references" / "sources"
|
||||
TARGET = ROOT / "docs" / "references" / "README.md"
|
||||
EXCLUDED_SOURCE_NAMES = {"README.md", "AGENTS.md"}
|
||||
|
||||
|
||||
def iter_source_files() -> list[Path]:
|
||||
if not SOURCE_DIR.exists():
|
||||
raise FileNotFoundError(f"source directory not found: {SOURCE_DIR}")
|
||||
|
||||
files = sorted(
|
||||
path
|
||||
for path in SOURCE_DIR.glob("*.md")
|
||||
if path.name not in EXCLUDED_SOURCE_NAMES
|
||||
)
|
||||
if not files:
|
||||
raise FileNotFoundError(f"no source fragments found in: {SOURCE_DIR}")
|
||||
return files
|
||||
|
||||
|
||||
def build_content() -> str:
|
||||
parts: list[str] = []
|
||||
for path in iter_source_files():
|
||||
content = path.read_text(encoding="utf-8").strip()
|
||||
if content:
|
||||
parts.append(content)
|
||||
return "\n\n".join(parts).rstrip() + "\n"
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Build docs/references/README.md from docs/references/sources/*.md."
|
||||
)
|
||||
parser.add_argument(
|
||||
"--check",
|
||||
action="store_true",
|
||||
help="Fail if docs/references/README.md is not synced with source fragments.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
expected = build_content()
|
||||
if args.check:
|
||||
actual = TARGET.read_text(encoding="utf-8") if TARGET.exists() else ""
|
||||
if actual != expected:
|
||||
print(
|
||||
"docs/references/README.md is out of sync. "
|
||||
"Run `make sync-reference-readme`.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 1
|
||||
print("docs/references/README.md is synced with source fragments.")
|
||||
return 0
|
||||
|
||||
TARGET.write_text(expected, encoding="utf-8")
|
||||
print(f"wrote {TARGET.relative_to(ROOT)}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -16,10 +16,6 @@ SKIP_PREFIXES = [
|
||||
Path("tools/external"),
|
||||
Path("tools/chat-vault"),
|
||||
]
|
||||
GENERATED_SOURCE_DIRS = {
|
||||
Path("docs/references/sources"),
|
||||
}
|
||||
SOURCE_DOC_NAMES = {"README.md", "AGENTS.md"}
|
||||
LINK_PATTERNS = [
|
||||
re.compile(r"!??\[[^\]]*\]\(([^)]+)\)"),
|
||||
re.compile(r"\b(?:href|src)=[\"']([^\"']+)[\"']"),
|
||||
@@ -105,8 +101,6 @@ def should_skip(path: Path) -> bool:
|
||||
rel = path.relative_to(ROOT)
|
||||
if any(part in SKIP_PARTS for part in rel.parts):
|
||||
return True
|
||||
if rel.parent in GENERATED_SOURCE_DIRS and rel.name not in SOURCE_DOC_NAMES:
|
||||
return True
|
||||
return any(rel == prefix or prefix in rel.parents for prefix in SKIP_PREFIXES)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user