Commit 6ab568a6 authored by VectorW's avatar VectorW

Add inner types handling

parent 3e95c1d9
......@@ -125,6 +125,17 @@ function jsdocParser(text, parsers, options) {
if (tag.type.expression) {
tag.type.name = tag.type.expression.name
tag.type.elements = tag.type.expression.elements
if (tag.type.applications) {
let { type: { applications: [{ type, name, elements }] }} = tag
tag.type.name += '.<'
if (name) tag.type.name += Object.keys(typeNameMap).includes(type) ? typeNameMap[type] : name
if (elements) tag.type.name += elements
.map(({ type: t, name: n }) => Object.keys(typeNameMap).includes(t) ? typeNameMap[t] : n)
.join('|')
tag.type.name += '>'
}
}
if (tag.type.elements) {
tag.type.name = tag.type.elements.map(e => {
......
......@@ -158,7 +158,53 @@ test('Should not add TODO for return desc if it has undefined|null|void type', (
expect(Result3).toEqual(Expected3)
})
test('Should keep defined inner types', () => {
const Result1 = subject(`/**
* @param {String[]} test test param
*/`)
const Expected1 = `/**
* @param {Array.<String>} test Test param
*/
`
const Result2 = subject(`/**
* @param {Array.<String>} test Test param
*/`)
const Expected2 = `/**
* @param {Array.<String>} test Test param
*/
`
const Result3 = subject(`/**
* @param {Array.<String|Object>} test Test param
*/`)
const Expected3 = `/**
* @param {Array.<String|Object>} test Test param
*/
`
const Result4 = subject(`/**
* @return {Promise.<Number|String|undefined>} test promise
*/`)
const Expected4 = `/**
* @return {Promise.<Number|String|undefined>} Test promise
*/
`
const Result5 = subject(`/**
* @return {Object.<Number|String|undefined>} test object
*/`)
const Expected5 = `/**
* @return {Object.<Number|String|undefined>} Test object
*/
`
expect(Result1).toEqual(Expected1)
expect(Result2).toEqual(Expected2)
expect(Result3).toEqual(Expected3)
expect(Result4).toEqual(Expected4)
expect(Result5).toEqual(Expected5)
})
test('Should align vertically param|property|return|yields|throws if option set to true', () => {
const options = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment