✨ feat(tsl-api-reference): expand and reorganize api catalog
Flatten builtin pages, add third-party and platform scopes, and import financial and data warehouse references. Keep the existing generated index without rebuilding after signature normalization.
This commit is contained in:
@@ -204,15 +204,17 @@ skills/tsl-api-reference/
|
||||
│ └─ function_index.tsv
|
||||
├─ references/
|
||||
│ └─ codegen/
|
||||
│ ├─ builtin/ playbook 维护
|
||||
│ ├─ builtin/ playbook 维护,页面直接平铺
|
||||
│ │ └─ <page>.md
|
||||
│ ├─ dotnet/ playbook 维护
|
||||
│ │ └─ <module-dir>/<page>.md
|
||||
│ └─ project/ 用户项目文档的默认 scope
|
||||
│ └─ <module-dir>/<page>.md
|
||||
└─ scripts/
|
||||
└─ lookup.py
|
||||
```
|
||||
|
||||
markdown 目标路径固定为:
|
||||
用户录入的 markdown 目标路径固定为:
|
||||
|
||||
```text
|
||||
skills/tsl-api-reference/references/codegen/<scope>/<module-dir>/<page>.md
|
||||
@@ -223,6 +225,9 @@ skills/tsl-api-reference/references/codegen/<scope>/<module-dir>/<page>.md
|
||||
- `<module-dir>`:功能分类目录,例如 `base`、`runtime`、`document`
|
||||
- `<page>.md`:相关 API 的叶子文档,例如 `array.md`、`elements.md`
|
||||
|
||||
`builtin` 是维护侧的特例:页面直接位于 `codegen/builtin/<page>.md`,索引中的
|
||||
`module` 等于文件名(不含 `.md`)。
|
||||
|
||||
录入文件的 `module` 是 markdown 一级标题,不是目录名。例如:
|
||||
|
||||
```text
|
||||
|
||||
@@ -9,7 +9,7 @@ Columns (tab-separated, LF line endings, UTF-8):
|
||||
name scope module signature page anchor tags summary
|
||||
kind binding visibility owner qualified_name
|
||||
- name: signature text up to the first '('
|
||||
- scope: first path segment under the codegen root (for example project)
|
||||
- scope: first path segment, or the file stem for a root-level page
|
||||
- module: second path segment for nested pages, else the flat file stem
|
||||
- signature: verbatim from the heading, backticks stripped
|
||||
- page: POSIX path relative to the codegen root
|
||||
@@ -188,6 +188,9 @@ def parse_page(codegen_root, md):
|
||||
|
||||
def scope_module(page):
|
||||
parts = page.split("/")
|
||||
if len(parts) == 1:
|
||||
stem = Path(parts[0]).stem
|
||||
return stem, stem
|
||||
scope = parts[0]
|
||||
module = parts[1] if len(parts) >= 3 else Path(parts[-1]).stem
|
||||
return scope, module
|
||||
|
||||
@@ -28,10 +28,10 @@ class FunctionIndexTest(unittest.TestCase):
|
||||
self.skill_dir = Path(self.temp_dir.name) / "tsl-api-reference"
|
||||
self.codegen_root = self.skill_dir / "references" / "codegen"
|
||||
self.data_dir = self.skill_dir / "data"
|
||||
leaf = self.codegen_root / "builtin" / "base" / "array.md"
|
||||
leaf = self.codegen_root / "builtin" / "array.md"
|
||||
leaf.parent.mkdir(parents=True)
|
||||
leaf.write_text(
|
||||
"# Builtin - 基础 / 数组\n\n"
|
||||
"# Builtin - 数组\n\n"
|
||||
"## `demo()`\n\n"
|
||||
"声明:function\n\n"
|
||||
"返回示例值。\n\n"
|
||||
@@ -71,6 +71,24 @@ class FunctionIndexTest(unittest.TestCase):
|
||||
self.assertEqual("数组 列表", row["tags"])
|
||||
self.assertEqual("返回示例值。", row["summary"])
|
||||
|
||||
def test_root_page_uses_file_stem_for_scope_and_module(self):
|
||||
self.write_page(
|
||||
"deprecated.md",
|
||||
"# Deprecated\n\n"
|
||||
"## `legacy()`\n\n"
|
||||
"声明:function\n\n"
|
||||
"已废弃。\n",
|
||||
)
|
||||
|
||||
rows = {
|
||||
row[0]: dict(zip(self.module.HEADER, row))
|
||||
for row in self.module.build_rows(self.codegen_root)
|
||||
}
|
||||
|
||||
self.assertEqual("deprecated", rows["legacy"]["scope"])
|
||||
self.assertEqual("deprecated", rows["legacy"]["module"])
|
||||
self.assertEqual("deprecated.md", rows["legacy"]["page"])
|
||||
|
||||
def test_declaration_does_not_become_a_missing_description_summary(self):
|
||||
self.write_page(
|
||||
"project/missing_description.md",
|
||||
@@ -113,9 +131,9 @@ class FunctionIndexTest(unittest.TestCase):
|
||||
[
|
||||
"demo",
|
||||
"builtin",
|
||||
"base",
|
||||
"array",
|
||||
"demo()",
|
||||
"builtin/base/array.md",
|
||||
"builtin/array.md",
|
||||
"demo",
|
||||
"数组 列表",
|
||||
"返回示例值。",
|
||||
|
||||
@@ -573,6 +573,17 @@ class LookupTest(unittest.TestCase):
|
||||
self.assertEqual(2, result.returncode)
|
||||
self.assertIn("--limit must be >= 1", result.stderr)
|
||||
|
||||
def test_help_lists_all_bundled_scopes(self):
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(SCRIPT), "--help"],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
self.assertEqual(0, result.returncode, result.stderr)
|
||||
self.assertIn("builtin、dotnet、third 与 deprecated", result.stdout)
|
||||
|
||||
def test_exact_search_uses_anchor_for_duplicate_signatures(self):
|
||||
module = load_script()
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
@@ -767,6 +778,7 @@ class LookupTest(unittest.TestCase):
|
||||
text = SKILL_MD.read_text(encoding="utf-8")
|
||||
|
||||
self.assertIn("完全限定名称", text)
|
||||
self.assertIn("--scope third", text)
|
||||
self.assertIn("qualified_name", text)
|
||||
self.assertIn("owner、kind、binding、visibility", text)
|
||||
self.assertIn("class function", text)
|
||||
|
||||
Reference in New Issue
Block a user