CMakePP / CMinx

Generates API documentation for CMake functions and macros
https://cmakepp.github.io/CMinx/
Apache License 2.0
14 stars 5 forks source link

Argument list does not contain arguments parsed by `cmake_parse_arguments` #112

Closed peanutfun closed 1 year ago

peanutfun commented 2 years ago

Is your feature request related to a problem? Please describe. CMinx documents the parameter list of a CMake function. However, by CMake's nature, additional unnamed arguments can always be passed to a function. Usually, these are then parsed by cmake_parse_arguments. However, it's confusing to read the documentation of a function with named arguments that accepts additional parameters. Take this example (excerpt from the docs):

.. function:: advanced_say_hi_to(me)

   :param me: The name of the person saying hi.
   :keyword PERSONS: The person or persons to say hi to.

Describe the solution you'd like I realize this is a stretch but it would be really great if CMinx could detect the call to cmake_parse_arguments in the function body and then automatically add an indicator that the function may take additional arguments. I would like the result to look something like

.. function:: advanced_say_hi_to(me *args)

   :param me: The name of the person saying hi.
   :keyword PERSONS: The person or persons to say hi to.

Notice the *args (or something similar) as new indicator.

Describe alternatives you've considered Alternatively, the *args could simply be added if a keyword/parameter specified in the comment block does not appear in the function signature.

Additional context None

ryanmrichard commented 2 years ago

I really like this suggestion. I think I'd vote for **kwargs over *args though since ithe additional arguments are associated with keywords as opposed to simply being additional positional arguments.

As for how to do this, I think we should try to detect both cmake_parse_args and :keyword xxxx:. If either is found we then add *args/**kwargs to the signature. If we look for both we then are able to handle scenarios where:

AutonomicPerfectionist commented 2 years ago

CMinx already has most of the code to support this so hopefully it shouldn't be too difficult. I'll get working on that