提交 8ab9119c 编写于 作者: C coolreader18 提交者: Matt Bierner

Fix a double dash in the previewer if an @param jsdoc tag has a hyphen after...

Fix a double dash in the previewer if an @param jsdoc tag has a hyphen after the param name (#53365)

* Fix a double dash if the @param has a hyphen

* Moved into the other regex

* Add test for ignoring hypen after @param

* Fixed test and moved to previewer.test.ts
上级 9989abf5
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import 'mocha';
import { tagsMarkdownPreview } from '../utils/previewer';
suite('typescript.previewer', () => {
test('Should ignore hyphens after a param tag', async () => {
assert.strictEqual(
tagsMarkdownPreview([
{
name: 'param',
text: 'a - b'
}
]),
'*@param* `a` — b');
});
});
......@@ -27,7 +27,7 @@ function getTagBodyText(tag: Proto.JSDocTagInfo): string | undefined {
function getTagDocumentation(tag: Proto.JSDocTagInfo): string | undefined {
switch (tag.name) {
case 'param':
const body = (tag.text || '').split(/^([\w\.]+)\s*/);
const body = (tag.text || '').split(/^([\w\.]+)\s*-?\s*/);
if (body && body.length === 3) {
const param = body[1];
const doc = body[2];
......@@ -81,4 +81,4 @@ export function addMarkdownDocumentation(
out.appendMarkdown('\n\n' + tagsPreview);
}
return out;
}
\ No newline at end of file
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册