doxdocgen icon indicating copy to clipboard operation
doxdocgen copied to clipboard

Different @param templates for pointer and non-pointer types

Open TjazVracko opened this issue 3 years ago • 4 comments

Is your feature request related to a problem? Please describe. This is mostly related to the [in/out] direction specifiers for parameters in c/c++. I usually specify all non-pointer parameters with @param xxx, since their direction is implicitly in, and pointer parameters with @param[dir] xxx, to make their direction obvious.

Since there is currently only one paramTemplate configuration, I have two options. 1. "doxdocgen.generic.paramTemplate": "@param {param} " and add [dir] for all pointer parameters manually 2. "doxdocgen.generic.paramTemplate": "@param[??] {param} " and remove [dir] for all non-pointer parameters manually

Describe the solution you'd like A separate paramTemplate for pointer types, so that less manual editing will be required.

Example of current behaviour: Settings: "doxdocgen.generic.paramTemplate": "@param {param}

What is generated:

/**
 * @brief 
 * 
 * @param buff 
 * @param len 
 * @return int 
 */
int send_buffer(uint8_t *buff, uint16_t len);

Example of suggested behaviour: Settings: "doxdocgen.generic.paramTemplate": "@param {param} "doxdocgen.generic.pointerParamTemplate": "@param[??] {param}

What is generated:

/**
 * @brief 
 * 
 * @param[??] buff 
 * @param len 
 * @return int 
 */
int send_buffer(uint8_t *buff, uint16_t len);

Is something like this possible?

TjazVracko avatar Mar 04 '22 12:03 TjazVracko

hope to increase this demand

Linux-yzy avatar Mar 05 '22 10:03 Linux-yzy

Hi @TjazVracko ,

great detailed feature suggestion!

Is something like this possible?

I think this should be possible but for implementing it I wouldn't limit the scope to pointers but also include references.

In addition I would prefer to make this a configuration template like this:

"doxdocgen.generic.paramTemplate": "@param{direction} {param}",
"doxdocgen.generic.paramDirectionInTemplate": "[{in}]",
"doxdocgen.generic.paramDirectionOutTemplate": "[{out}]"

as it doesn't break existing code if {direction} isn't specified.

This is more complicated but it also handles the usecase from #122 where non-const parameters are treated without any direction specifier.

cschlosser avatar Mar 06 '22 19:03 cschlosser

@cschlosser great!

If one were to attempt to implement this themselves, how might they go about it? any pointers?

TjazVracko avatar Mar 07 '22 07:03 TjazVracko

Hi @TjazVracko ,

Sorry for keeping you waiting so long. I think first one should extend this class: https://github.com/cschlosser/doxdocgen/blob/master/src/Lang/Cpp/CppArgument.ts With an In/Out field.

The arguments are extracted from the tree here: https://github.com/cschlosser/doxdocgen/blob/66816501cae9f60d0f363b4476cffd8b7c896505/src/Lang/Cpp/CppParser.ts#L545

and finally one has to read the field here and use the correct templated string then: https://github.com/cschlosser/doxdocgen/blob/66816501cae9f60d0f363b4476cffd8b7c896505/src/Lang/Cpp/CppDocGen.ts#L407

cschlosser avatar Mar 23 '22 00:03 cschlosser