Merge commit '3d83740f88b6aaba6962256be517656496b83f25' into lsp-server
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import importlib.util
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SCRIPT = ROOT / "scripts" / "playbook.py"
|
||||
|
||||
|
||||
def load_playbook_module():
|
||||
spec = importlib.util.spec_from_file_location("playbook_script", SCRIPT)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
assert spec.loader is not None
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
|
||||
|
||||
class PlaybookDocsIndexTests(unittest.TestCase):
|
||||
def test_build_docs_index_lines_uses_canonical_sections(self):
|
||||
playbook = load_playbook_module()
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp_dir:
|
||||
source = Path(tmp_dir) / "index.md"
|
||||
source.write_text(
|
||||
"\n".join(
|
||||
[
|
||||
"# 文档导航(Docs Index)",
|
||||
"",
|
||||
"仓库级说明。",
|
||||
"",
|
||||
"## 跨语言(common)",
|
||||
"",
|
||||
"- 公共入口:`common/commit_message.md`",
|
||||
"",
|
||||
"## TSL(tsl/tsf)",
|
||||
"",
|
||||
"- 自定义 TSL 入口:`tsl/custom.md`",
|
||||
"",
|
||||
"## Python(python)",
|
||||
"",
|
||||
"- Python 入口:`python/style_guide.md`",
|
||||
"",
|
||||
]
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
lines = playbook.build_docs_index_lines(["tsl"], source)
|
||||
|
||||
self.assertEqual(lines[0], "# 文档导航(Docs Index)")
|
||||
self.assertEqual(lines[2], "本快照为裁剪版 Playbook(langs: tsl)。")
|
||||
self.assertIn("## 跨语言(common)", lines)
|
||||
self.assertIn("- 公共入口:`common/commit_message.md`", lines)
|
||||
self.assertIn("## TSL(tsl/tsf)", lines)
|
||||
self.assertIn("- 自定义 TSL 入口:`tsl/custom.md`", lines)
|
||||
self.assertNotIn("## Python(python)", lines)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user