Generate TSL API Markdown from YAML or JSON into a configurable project scope.\nAdd file and directory lint modes, tags-aware indexing, and keyword search across tags and descriptions.\nBundle the toolkit through the playbook build and sync workflows.
41 lines
969 B
Python
41 lines
969 B
Python
import importlib.util
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
SCRIPT = (
|
|
Path(__file__).resolve().parents[3]
|
|
/ "skills"
|
|
/ "tsl-api-reference"
|
|
/ "scripts"
|
|
/ "lookup.py"
|
|
)
|
|
|
|
|
|
def load_script():
|
|
spec = importlib.util.spec_from_file_location("tsl_lookup", SCRIPT)
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
class LookupTest(unittest.TestCase):
|
|
def test_keyword_search_includes_tags_and_summary(self):
|
|
module = load_script()
|
|
rows = [
|
|
{
|
|
"name": "demo",
|
|
"signature": "demo()",
|
|
"module": "base",
|
|
"tags": "数组 列表",
|
|
"summary": "返回示例值",
|
|
}
|
|
]
|
|
|
|
self.assertEqual(rows, module.search_keyword(rows, ["数组"]))
|
|
self.assertEqual(rows, module.search_keyword(rows, ["返回示例"]))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|