Skip to content
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 annotation information #308

Open
tdroxler opened this issue Oct 3, 2024 · 1 comment
Open

Add annotation information #308

tdroxler opened this issue Oct 3, 2024 · 1 comment

Comments

@tdroxler
Copy link
Member

tdroxler commented Oct 3, 2024

For new comers, it would be nice if they could get more information about annotations. for example in:

Contract MyContract() {
  @using(checkExternalCaller = false)
  pub fn function_a(boolean: Bool) -> () {
  }
}

They should be able to jump to definiton of @using or checkExternalCaller (latter having the hover) to see more doc.

Currently the annotations are defined in Parser file in the full node, but we only have the keys as String.
We could have something similar to BuiltIn, where doc comes alongside the types.

I experimented a bit by first extracting RalphAnnotation in a separate file and then adding some doc field to the annotation.

I also show in ralph-lsp that we can find the corresponding annotation and doc when requesting definition of checkExternalCaller.

So I think we could have something similar to the built-in function and std-interface. We could store in the dependencies annotation file so user can jump there to see more info.

We need to check how we choose to represent those annotations, but we could do something similar to scala nowarn annotation

Interface FunctionUsingAnnotation {
  // doc for using annotation
  fn using(
      // doc for preapprovedAssets
      preapprovedAssets: Bool,
      // doc for assetsInContract
      assetsInContract: Bool,
      // doc for payToContractOnly
      payToContractOnly: Bool,
      // doc for checkExternalCaller
      checkExternalCaller: Bool,
      // doc for updateFields
      updateFields: Bool,
      // doc for methodIndex
      methodIndex: U256
    ) -> ()
}

It has to compile otherwise ralph-lsp will complain.

@tdroxler
Copy link
Member Author

tdroxler commented Oct 3, 2024

Another proposition is to send a message to the user when querying those info to go to our current document website: https://docs.alephium.org/ralph/functions/#annotations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant