dfinity / vscode-motoko

Motoko language support for VS Code.
Apache License 2.0
42 stars 16 forks source link

Feature Request: Function Signature Args and Linking in "Motokodoc" #154

Closed atengberg closed 1 year ago

atengberg commented 1 year ago

Could someone could point me to the file that handles the "Motokodoc" formatting and logic (particularly for the tooltip popup on hover that shows up when a field as the Motokodoc comment header)?

In particular I'd like to add autogeneration/highlighting for argument and return signature, as well the ability to point the comment to another Motokodoc comment.

atengberg commented 1 year ago

Additionally if a header format could be specified for the did files, those two could be linked to avoid duplication of documentation.

rvanasa commented 1 year ago

Here is the relevant doc comment formatting logic:

https://github.com/dfinity/vscode-motoko/blob/72eb00b61917751e3dba9ab017409d3146d80d5e/src/server/server.ts#L1064-L1078

The "go-to-definition" logic (for pointing to other doc comments) is implemented here:

https://github.com/dfinity/vscode-motoko/blob/72eb00b61917751e3dba9ab017409d3146d80d5e/src/server/navigation.ts#L320

Because doc comments are currently discovered via AST traversal, the language server might need some refactoring to fully achieve what you're suggesting. Feel free to create a docs.ts file for any required helper functions, and I'll eventually move the rest of the onHover() logic into this file as well.

I would also recommend turning on "Debug Hover" in the extension settings, which shows some additional AST information in the hover tooltips.

Let me know if you run into any roadblocks, and I'll do my best to help out.

rvanasa commented 1 year ago

Closing as not currently planned (feel free to reopen individual requests with more details if needed).