tsdoc icon indicating copy to clipboard operation
tsdoc copied to clipboard

Document inline parameters

Open GuillaumedesPommareSAP opened this issue 5 years ago • 2 comments

Hello,

I would like to know if there is currently a defined way to document such a function: function error(message: string, mOptions?: { onClose?: () => void, title?: string})

I tried for example this approach:

       /**
         * Error ! 
         * @param {string} message - a message
         * @param {any=} mOptions - some options
         * @param {any=} mOptions.onClose - a callback function
         * @param {string=} mOptions.title - a title, as string
         * @returns {void}
         */

Of course in "pure" TypeScript an interface would be created and documented. That would be the way to go. But here The function exists and already has such a signature. I only need to add some documentation to help using it.

Do you know if I am filling a feature request here, or if this is already supported by tsdoc ? I can't find it :(

Thanks !

GuillaumedesPommareSAP avatar Apr 23 '19 11:04 GuillaumedesPommareSAP

@GuillaumedesPommareSAP I think it would be reasonable for TSDoc to allow a . in the parameter name, like this:

       /**
         * @param  message - a message
         * @param  mOptions - some options
         * @param  mOptions.onClose - a callback function
         * @param  mOptions.title - a title, as string
         * @returns the result
         */

I'm not sure we'd want to get involved with type annotations, since the grammar for that will be complicated (especially in TypeScript source code). In your example, that information is already captured by the type annotation anyway.

Does that make sense?

octogonz avatar Apr 25 '19 15:04 octogonz

Hello @octogonz !

Sure ! My bad ! My question was focusing on the dot notation, and I kept the type information which is not useful here. The function itself is already typed.

I had in mind a dot notation like in jsdoc for the parameters with properties. So your example would be the target, in my case.

GuillaumedesPommareSAP avatar Apr 25 '19 16:04 GuillaumedesPommareSAP