-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for function prototype annotation #14
Conversation
This is very cool @davidgranstrom, thanks a lot for contributing ! Regarding to the actual implementation, would you mind add a comment on this PR with one or two c snippets for me to test if it's working well ? By the way (this is documentation related), do you have some remarks/insights for the |
Sure! Here's a quick test with annotations generated using the default doxygen template. test.h #include <stdlib.h>
/**
* @brief
*
* @param[in] dst
* @param[in] src
* @param[in] len
* @returns
*/
int func_with_retval(char *dst, char *src, size_t len);
/**
* @brief
*
* @param[in] s
* @param[in] len
*/
void func_with_no_retval(char *s, size_t len);
/**
* @brief
*
* @returns
*/
int func_with_no_args_and_retval(void); |
I'm not 100% sure its worth having the extra logic for checking Maybe it would be best to always generate the test.h /**
* @brief
*
* @param[in] size
*/
void *getmem(size_t size); test.c /**
* @brief
*
* @param[in] size
* @returns
*/
void *getmem(size_t size)
{
return malloc(size);
} |
I think it is the way to go in order for the function definition and the function prototype be consistent.
Maybe you did not see this part, don't you mind to share some insights ? |
By the way, the PR works well, thanks a lot! 🥳 |
cfbbd63
to
7320b90
Compare
@davidgranstrom Have you done some testings? I think we're good, but I want to hear your response |
@danymat I figured out a way to check for pointer return values. Maybe this is the most frictionless solution for function prototypes? The alternative, as mentioned earlier to always generate the With the latest push the following works: #include <stdlib.h>
/**
* @brief
*
* @param[in] size
* @returns
*/
void *getmem(size_t size);
/**
* @brief
*
* @param[in] s
*/
void to_upper(char *s); |
I could also give you some feedback on the "Adding Languages documentations" :) |
I just saw your last commit, and this is a simple way to check if the functions returns a pointer. You can keep it like that.
Feel free to open an issue, no need to keep in private ! I think I'm good to merge the PR, what do you think? |
Okay, great!
Alright, will do as soon as I get a chance.
Yes, I think it's ready now. 👍 |
Hi,
Thanks for publishing this plugin! I wanted to use it to annotate function prototypes in C header files so I added support for this. The original functionality for the C language type should still be preserved and I've tested some edge cases locally. Will do more extensive testing tomorrow, so I'll leave this as draft for now.