Skip to content

Commit e394935

Browse files
committed
feat: 增加函数注释配置
Co-authored-by: ygqygq2 <[email protected]>
1 parent 4dd3eb0 commit e394935

34 files changed

+431
-100
lines changed

.vscode/launch.json

-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
"--disable-extensions"
2828
],
2929
"env": {
30-
"mode": "debug",
3130
"TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json"
3231
},
3332
"preLaunchTask": "npm: test-compile",
@@ -45,7 +44,6 @@
4544
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
4645
],
4746
"env": {
48-
"NODE_ENV": "test",
4947
"TS_NODE_PROJECT": "${workspaceFolder}/tsconfig.json"
5048
},
5149
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to the "turbo-file-header" extension will be documented in this file.
44

5+
# [0.2.1]
6+
7+
## 新增功能 🌱
8+
9+
- feat: 增加函数注释配置
10+
511
# [0.2.0]
612

713
## 新增功能 🌱

README.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ Properties:
3434
| Disable fields in file header | The fields that you want to disable in file header | disableLabels | `[]` |
3535
| Custom variable | Support use other variable | customVariables | the below |
3636
| File header content | File header content, overwrite the default file header content | fileheader | the below |
37-
| Multiline regex pattern | Match the original file header using multiline regex pattern. | patternMultiline | `false` |
37+
| Multiline regex pattern | Match the original file header using multiline regex pattern | patternMultiline | `false` |
3838
| Only dirty file or not to support | Only dirty file to support update file header | updateHeaderForModifiedFilesOnly | `false` |
3939
| Extra languages support | To support new or unknown languages | languages | the below |
4040
| JSDoc style for js/ts | File header user JSDoc style comments | useJSDocStyle | `false` |
41+
| Function comment settings | Function comment settings for languages | functionComment | the below |
4142
| Multiline comment highlighter | Whether the multiline comment highlighter should be active | multilineComments | `true` |
4243
| plaintext comment highlighter | Whether the plaintext comment highlighter should be active | highlightPlainText | `false` |
4344
| Use tags to color the comments | Tags which are used to color the comments | tags | the below |
@@ -146,6 +147,21 @@ Properties:
146147
]
147148
```
148149

150+
`functionComment` default settings:
151+
152+
```
153+
{
154+
"languagesSettings": [
155+
{
156+
"languageId": "typescript",
157+
"defaultReturnName": "default",
158+
"defaultReturnType": "auto",
159+
"defaultParamType": "any"
160+
}
161+
]
162+
}
163+
```
164+
149165
`tags` default settings:
150166

151167
```

README.zh-CN.md

+16
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Properties:
3838
| 只支持脏文件 | 只有已更新但未保存文件支持插入/更新文件头 | updateHeaderForModifiedFilesOnly | `false` |
3939
| 额外语言支持 | 通过配置支持新/未知语言插入/更新文件头 | languages | the below |
4040
| JSDoc 注释风格支持 js/ts | js/ts 文件使用 JSDoc 注释风格 | useJSDocStyle | `false` |
41+
| 函数注释设置 | 针对不同语言的函数注释设置 | functionComment | the below |
4142
| 块注释高亮支持 | 块注释支持高亮功能 | multilineComments | `true` |
4243
| 纯文件高亮支持 | 纯文件支持高亮功能 | highlightPlainText | `false` |
4344
| 配置 `tags` | 使用 `tags` 配置注释高亮 | tags | the below |
@@ -146,6 +147,21 @@ Properties:
146147
]
147148
```
148149

150+
`functionComment` default settings:
151+
152+
```
153+
{
154+
"languagesSettings": [
155+
{
156+
"languageId": "typescript",
157+
"defaultReturnName": "default",
158+
"defaultReturnType": "auto",
159+
"defaultParamType": "any"
160+
}
161+
]
162+
}
163+
```
164+
149165
`tags` default settings:
150166

151167
```

package.json

+45-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "turbo-file-header",
33
"displayName": "Turbo File Header",
44
"description": "Sets file header information globally or for a project.",
5-
"version": "0.2.0",
5+
"version": "0.2.1",
66
"icon": "resources/icons/icon.png",
77
"repository": {
88
"type": "git",
@@ -309,6 +309,49 @@
309309
"description": "%turboFileHeader.useJSDocStyle.description%",
310310
"default": false
311311
},
312+
"turboFileHeader.functionComment": {
313+
"type": "object",
314+
"description": "%turboFileHeader.functionComment.description%",
315+
"properties": {
316+
"languagesSettings": {
317+
"type": "array",
318+
"description": "%turboFileHeader.functionComment.languagesSettings.description%",
319+
"items": {
320+
"type": "object",
321+
"properties": {
322+
"languageId": {
323+
"type": "string"
324+
},
325+
"defaultReturnName": {
326+
"type": "string",
327+
"default": "default",
328+
"description": "%turboFileHeader.functionComment.languagesSettings.javascript.defaultReturnName.description%"
329+
},
330+
"defaultReturnType": {
331+
"type": "string",
332+
"default": "auto",
333+
"description": "%turboFileHeader.functionComment.languagesSettings.javascript.defaultReturnType.description%"
334+
},
335+
"defaultParamType": {
336+
"type": "string",
337+
"default": "any",
338+
"description": "%turboFileHeader.functionComment.languagesSettings.javascript.defaultParamType.description%"
339+
}
340+
}
341+
}
342+
}
343+
},
344+
"default": {
345+
"languagesSettings": [
346+
{
347+
"languageId": "typescript",
348+
"defaultReturnName": "default",
349+
"defaultReturnType": "auto",
350+
"defaultParamType": "any"
351+
}
352+
]
353+
}
354+
},
312355
"turboFileHeader.multilineComments": {
313356
"type": "boolean",
314357
"description": "%turboFileHeader.multilineComments.description%",
@@ -534,6 +577,7 @@
534577
"clean": "rimraf out/",
535578
"test-compile": "npm run clean && tsc -p ./ && npm run compile",
536579
"test": "npm run test-compile && vscode-test",
580+
"test-grep": "npm run test-compile && vscode-test -g",
537581
"test:suite:mocha": "npm run test-compile && node out/test/runTests.js",
538582
"test:suite": "node out/test/runTests.js",
539583
"test:unit": "vitest unit --watch=false",

package.nls.json

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"turboFileHeader.languages.items.properties.configuration.description": "Language configuration.",
3535
"turboFileHeader.languages.items.properties.configuration.properties.description": "Language comments.",
3636
"turboFileHeader.useJSDocStyle.description": "File header user JSDoc style comments for js/ts.",
37+
"turboFileHeader.functionComment.description": "function comment settings.",
38+
"turboFileHeader.functionComment.languagesSettings.description": "Language settings for function comment.",
39+
"turboFileHeader.functionComment.languagesSettings.javascript.defaultReturnName.description": "Javascript function default return name.",
40+
"turboFileHeader.functionComment.languagesSettings.javascript.defaultReturnType.description": "Javascript function default return type.",
41+
"turboFileHeader.functionComment.languagesSettings.javascript.defaultParamType.description": "Javascript function default param type.",
3742
"turboFileHeader.multilineComments.description": "Whether the multiline comment highlighter should be active.",
3843
"turboFileHeader.highlightPlainText.description": "Whether the plaintext comment highlighter should be active.",
3944
"turboFileHeader.tags.description": "Tags which are used to color the comments.",

package.nls.zh-cn.json

+5
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
"turboFileHeader.languages.items.properties.configuration.description": "语言配置",
3535
"turboFileHeader.languages.items.properties.configuration.properties.description": "语言注释",
3636
"turboFileHeader.useJSDocStyle.description": "js/ts 文件的文件头是否使用 JSDoc 风格注释",
37+
"turboFileHeader.functionComment.description": "函数注释设置",
38+
"turboFileHeader.functionComment.languagesSettings.description": "针对函数注释的语言设置",
39+
"turboFileHeader.functionComment.languagesSettings.javascript.defaultReturnName.description": "Javascript 默认函数返回名",
40+
"turboFileHeader.functionComment.languagesSettings.javascript.defaultReturnType.description": "Javascript 默认函数返回类型",
41+
"turboFileHeader.functionComment.languagesSettings.javascript.defaultParamType.description": "Javascript 默认函数参数返回类型",
3742
"turboFileHeader.multilineComments.description": "是否启用多行注释高亮",
3843
"turboFileHeader.highlightPlainText.description": "是否启用纯文本注释高亮",
3944
"turboFileHeader.tags.description": "哪些标签将被用于着色注释",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* @file sampleWorkspace/file-header/
3+
* @description test
4+
* @author ygqygq2 <[email protected]>
5+
* @createTime 2024-04-15 18:06:30
6+
* @lastModified 2024-04-15 18:10:28
7+
* Copyright ©ygqygq2 All rights reserved
8+
*/
9+
10+
a := 'a'
11+
fmt.Println("🚀 ~ file: no-fileheader.go:2 ~ a:", a)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* @file sampleWorkspace/file-header/
3+
* @description test
4+
* @author ygqygq2 <[email protected]>
5+
* @createTime 2024-04-11 16:37:11
6+
* @lastModified 2024-04-15 18:12:31
7+
* Copyright ©ygqygq2 All rights reserved
8+
*/
9+
10+
const testString = 'this is a string';
11+
console.log('🚀 ~ file: to-test-command-addFileheader.ts:2 ~ testString:', testString);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* @file sampleWorkspace/file-header/fileheader-update.result.go
3+
* @description
4+
* @author ygqygq2 <[email protected]>
5+
* @createTime 2024-04-15 18:06:30
6+
* @lastModified 2024-04-15 18:10:28
7+
* Copyright ©ygqygq2 All rights reserved
8+
*/
9+
10+
a := 'a'
11+
fmt.Println("🚀 ~ file: no-fileheader.go:2 ~ a:", a)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* @file sampleWorkspace/file-header/no-fileheader.ts
3+
* @description
4+
* @author ygqygq2 <[email protected]>
5+
* @createTime 2024-04-11 16:37:11
6+
* @lastModified 2024-04-11 16:37:59
7+
* Copyright ©ygqygq2 All rights reserved
8+
*/
9+
10+
const testString = 'this is a string';
11+
console.log('🚀 ~ file: to-test-command-addFileheader.ts:2 ~ testString:', testString);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
# * @file sampleWorkspace/file-header/no-fileheader.sh
4+
# * @description
5+
# * @author ygqygq2 <[email protected]>
6+
# * @createTime 2024-04-15 18:01:45
7+
# * @lastModified 2024-04-15 18:01:45
8+
# * Copyright ©ygqygq2 All rights reserved
9+
#
10+
11+
a='a'
12+
echo "🚀 ~ file: no-fileheader.sh:2 ~ a:" ${a}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* @file sampleWorkspace/file-header/no-fileheader.ts
3+
* @description test file header
4+
* @author ygqygq2 <[email protected]>
5+
* @createTime 2024-04-11 16:37:11
6+
* @lastModified 2024-04-11 16:37:59
7+
* Copyright ©ygqygq2 All rights reserved
8+
*/
9+
10+
const testString = 'this is a string';
11+
console.log('🚀 ~ file: to-test-command-addFileheader.ts:2 ~ testString:', testString);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
# * @file sampleWorkspace/file-header/
4+
# * @description test
5+
# * @author ygqygq2 <[email protected]>
6+
# * @createTime 2024-04-15 18:01:45
7+
# * @lastModified 2024-04-15 18:01:45
8+
# * Copyright ©ygqygq2 All rights reserved
9+
#
10+
11+
a='a'
12+
echo "🚀 ~ file: no-fileheader.sh:2 ~ a:" ${a}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* @file sampleWorkspace/file-header/
3+
* @description test
4+
* @author ygqygq2 <[email protected]>
5+
* @createTime 2024-04-11 16:37:11
6+
* @lastModified 2024-04-11 16:37:59
7+
* Copyright ©ygqygq2 All rights reserved
8+
*/
9+
10+
const testString = 'this is a string';
11+
console.log('🚀 ~ file: to-test-command-addFileheader.ts:2 ~ testString:', testString);

sampleWorkspace/file-header/no-fileheader.result.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* @file sampleWorkspace/file-header/no-fileheader.ts
3-
* @description test file header
3+
* @description
44
* @author ygqygq2 <[email protected]>
55
* @createTime 2024-04-11 16:37:11
66
* @lastModified 2024-04-11 16:37:59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env bash
2+
#
3+
# * @file sampleWorkspace/file-header/no-fileheader.sh
4+
# * @description
5+
# * @author ygqygq2 <[email protected]>
6+
# * @createTime 2024-04-15 18:01:45
7+
# * @lastModified 2024-04-15 18:01:45
8+
# * Copyright ©ygqygq2 All rights reserved
9+
#
10+
11+
a='a'
12+
echo "🚀 ~ file: no-fileheader.sh:2 ~ a:" ${a}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
3+
a='a'
4+
echo "🚀 ~ file: no-fileheader.sh:2 ~ a:" ${a}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
* @description
3+
* @return default {auto}
4+
* @param a {any}
5+
* @param b {any}
6+
*/
7+
(a, b) => {
8+
console.log(a + b);
9+
return a + b;
10+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(a, b) => {
2+
console.log(a + b);
3+
return a + b;
4+
};

sampleWorkspace/function-comment/variable-arrow-function-without-params-type.result.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @description
3-
* @return default {void}
3+
* @return default {auto}
44
* @param a {any}
55
* @param b {any}
66
*/

sampleWorkspace/function-comment/variable-arrow-function-without-params-type.result.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* @description
3-
* @return default {void}
3+
* @return default {auto}
44
* @param a {any}
55
* @param b {any}
66
*/

src/extension.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const fileheaderProviderLoader = new FileheaderProviderLoader(
4242
);
4343
const fileHashMemento = new FileHashManager();
4444
const fileheaderVariableBuilder = new FileheaderVariableBuilder(configManager);
45-
const functionParserLoader = new FunctionParserLoader();
45+
const functionParserLoader = new FunctionParserLoader(configManager);
4646
export const fileheaderManager = new FileheaderManager(
4747
configManager,
4848
fileMatcher,

0 commit comments

Comments
 (0)