✨ feat(vscode): 代码阅读的 FastAPI 接口多一个筛选属性「请求方法」(GET / POST …);库规则自己报的筛选属性由规则起名(LibraryRule.attributeNames)

This commit is contained in:
cruldra committed 2026-09-27 21:21:48 +08:00
1 parent ec34ace7cf
commit b4e4879570
9 files changed
+107 -11

No files matched your search

+12 -1
View File
@@ -1,7 +1,7 @@
import type { BlockView } from './blockView'
import type { CodeBlock, LanguageAdapter, Translator } from './contract'
import { describe, expect, it } from 'vitest'
import { blockAttributes, fileAttributes } from './attributes'
import { blockAttributes, fileAttributes, mergeAttributeNames } from './attributes'
import { toBlockViews } from './blockView'
import { createPythonAdapter } from './languages/python'
import { createTypeScriptAdapter } from './languages/typescript'
@@ -139,6 +139,17 @@ describe('文件里出现过的属性', () => {
expect(found[0].name).toBe('kind')
})
it('几份叫法合成一份:同一个属性、值排在前面的(翻译插件的)先用,没给的再取后面的(库规则的)', () => {
expect(mergeAttributeNames([
{ attributes: { access: '访问级别' }, values: { access: { public: '公共' } } },
undefined,
{ attributes: { access: '可见性', httpMethod: '请求方法' }, values: { access: { public: '开放', private: '内部' } } },
])).toEqual({
attributes: { access: '访问级别', httpMethod: '请求方法' },
values: { access: { public: '公共', private: '内部' } },
})
})
it('中文直译给通用属性和值起名,和属性表里的叫法一样', async () => {
const list = await views(ts, 'typescript', TS_SOURCE, typescriptZhTranslator)
const found = fileAttributes(list, typescriptZhTranslator.attributeNames)