-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Feature request: doc for unnamed parameters #6926
Comments
Based on the question from: https://stackoverflow.com/questions/55421894/how-do-i-doxygen-document-unnamed-parameters-of-a-function |
Just found this issue because I searched for a way to document an unnamed parameter. My use case is "tag dispatching", where one or several parameters are used just to increase the number of overloaded functions without using the value of these "tag parameters". |
So, I asked the StackOverflow question, and just noticed this bug. I'm still hoping this feature could be implemented... +1. |
The current syntax for the
and the I've had some thoughts about the possibilities:
My preference is certainly the third possibility. |
Given that I would say the number should be the i-th parameter (starting with 1), not just the i-th unnamed parameter. Checks that can be done:
|
I agree with @doxygen that an option-1-like approach is sound. For languages like C and C++, I also like the suggestion for the number to refer to the overall parameter index. But what about languages which have both named and extra positional parameters? ... if, in that case, the numbers refer only to positional parameters, then I support that as well. |
@eyalroz Can you give an example of "languages which have both named and extra positional parameters"? |
@albert-github : I'm not sure, but perhaps Python? |
I can see in python something like positional arguments see:
So I think we are talking here about parameters and I have not yet found something like "positional parameters". |
A point not taken into account yet is how to show the "unnamed" parameter in the output. Regarding the check:
this would give, possibly, extra warnings, at the moment "unnamed" parameters are silently ignored or is the intention that when one numbered parameter is documented all numbered parameters should be documented? |
There is a nice corner case where doxygen has some problems:
which results in:
as far as I know the "type0" and "type1" are identical, though I don't think this is is a problem for this issue but should be solved separately but it will lead in this case when documenting the functions as:
to some warnings as doxygen sees in the parameter list an Do we seen any solutions for this problem? |
@albert-github : So, the behavior you describe seems to be a bug. If it's resolved, I don't see why you identify a problem. As for the question of "what if a parameter name is specified, but the doxygen comments documents by parameter index?" - My answer would be that the documentation will not mention the parameter name again, e.g. something like
|
@eyalroz this is, also in my opinion, a bug, but I don't see an easy solution for it so I mentioned it here as a potential problem. Regarding the
Maybe we need something like
|
Oh, you mean saying "parameter N:" instead of just "const int:" - fine by me. I don't mind. Plus, remember - if the initial implementation is not aesthetic enough / annoying to users, it can always be tweaked later. No need to "bikeshed" this too much. |
An attempt at resuscitating this issue. Imo any of the last proposals above sounds great. |
Reiterating this sentiment, with detail. I found this issue after writing a pair of constructors of the following form. The effect is to enable exactly one of the constructors; which one ultimately depends on external parameters. I'm not using C++20, where I simply would have written
The constructors are to be called without explicit template arguments. The second argument is only present allow a substitution to succeed or fail. Neither argument is used in the code, yet if the second argument is named it generates a warning, and our CI fails on warnings. Thus documenting this requires specifying an unnamed argument.
It's only slightly verbose, but not redundant. Expressing intent clearly is worth paying the price of a few characters. From the C++ Core Guidelines: P.1: Express ideas directly in code. If |
I had the same problem. In my case a parameter is unused (non-pure virtual function in the base class), but needs to be documented.
The rest is straightforward. This has the additional advantage, that the doc then contains descriptive parameter names instead of pure numbers. |
That seems visually noisy, and pretty ugly IMHO. Standardese just supports |
Standardese also supports an |
Some times in C/C++, function parameters that are not used are not named, to avoid compiler warnings. This happens typically when a prototype can not change, for binary compatibility reasons.
To document this function:
or with even less comments:
the suggestion is to support:
Numbers refer to parameters by ordinal position.
Very low priority, just documenting the idea.
The text was updated successfully, but these errors were encountered: