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
This commit is contained in:
coolreader18
2018-07-06 14:53:44 -05:00
committed by Matt Bierner
parent 9989abf527
commit 8ab9119cf6
2 changed files with 24 additions and 2 deletions
@@ -0,0 +1,22 @@
/*---------------------------------------------------------------------------------------------
* 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];