Description
Search Terms
@params params named types function
Problem
When documenting functions, it happens that params use named types. If this type is used only once in the while code, it is fine, but if this type is reused multiple times, it would be handy to document it within the function using it:
/**
* Docs on the options Type
* @property a - Nice ! But there would be cases when it is not enough
* @property b - If the type is reused, then defaultValues would be wrong, for instance
*/
type MyOptions ={
a: number;
b: string;
};
/**
* A function using named options
* @param options Okay this comment is picked up
* @param options.a This is absent
* @param options.b This is absent too
*/
function fn1(options: MyOptions){
return options
}
/**
* A function using unnamed options
* @param options Okay this comment is picked up
* @param options.a With unnamed types it works
* @param options.b With unnamed types it works
*/
function fn2(options: {a: number, b: string}){
return options
}
export {fn1, fn2, MyOptions};
Here the comments for fn1
wont be picked up, nor in HTML or JSON output.
Suggested Solution
Include all the @params
tags within the function comments in the result JSON.
I did not try to clone the code yet and run it, but it seems to me that somewhere around here we look for comments which have @param paranName comment
with paramName
matching the name in the code. I guess we could return all comments which start by paranName.
. And then it would be for the users to implement their own way of dealing with it while processing the JSON output.
I have attached a little example project (with the same code I pasted up in the issue, and commands etc)
tsdoc-param-functions.zip
What do you think ?