x/tools/gopls: show full comments for constant or variable declaration #48200
What version of Go are you using (
The text was updated successfully, but these errors were encountered:
Thanks for the request, and the analysis.
I think if there's a way of presenting all relevant doc comments such that no context is lost, we'd welcome it.
Considering the suggestion:
One problem I see with this is that the last sentence looks out of place: absent context it's not entirely clear what it's modifying. This isn't that egregious an example, but one can imagine other cases where the spec.Comment is even more out of place.
I wonder if we should format an abbreviated declaration. Perhaps something like this?
We're unlikely to have time to prioritize this soon, but we'd welcome a contribution. However, before contributing we should decide on an ideal presentation here.
Hi @findleyr, thanks for the reply. With respect to your suggestion, I think it's reasonable but there are some problems around:
const ( O_TRUNC int = 512 // truncate regular writable file when opened. ) os.O_TRUNC on pkg.go.dev Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.
As there seems no relevant documentation which explicitly defines commentary specification, I use this picture to explain the corresponding comment scope in my view:
Based on above, I think we can change the signature of the const/var declaration to make it's presentation more comprehensive.
It's unrealistic to restraint user's comment behaviour without mechanical check but currently gopls can try to make all context present.
9/23 update: The old deisgn is too miscellaneous and may not deserve too much work to implement. In order to unify the presentation style, make decl.Doc always(if has) at the position of documentation and the rest like findleyr suggested.
I will work on it next few days and paste the capture of hover result here.