Skip to content

Add documentation for the abi keyword for LSP #7148

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

Merged
merged 1 commit into from
May 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions sway-lsp/src/utils/keyword_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,36 @@ impl KeywordDocs {
mod continue_keyword {}
};

let abi_keyword: ItemMod = parse_quote! {
/// Defines an Application Binary Interface (ABI).
///
/// An `abi` block defines a set of methods that a contract exposes externally. It acts as the
/// public interface for interacting with a smart contract. Only one `abi` block is allowed per
/// contract.
///
/// The methods defined within an `abi` block must be implemented in an associated [`impl`] block
/// for the contract.
///
/// ```sway
/// contract;
///
/// abi MyContract {
/// #[storage(read, write)]
/// fn update_counter(amount: u64) -> u64;
/// }
///
/// impl MyContract for Contract {
/// #[storage(read, write)]
/// fn update_counter(amount: u64) -> u64 {
/// let current = storage.counter;
/// storage.counter = current + amount;
/// storage.counter
/// }
/// }
/// ```
mod abi_keyword {}
};

// TODO
let str_keyword: ItemMod = parse_quote! {
mod str_keyword {}
Expand Down Expand Up @@ -725,11 +755,6 @@ impl KeywordDocs {
mod mod_keyword {}
};

// TODO
let abi_keyword: ItemMod = parse_quote! {
mod abi_keyword {}
};

// TODO
let storage_keyword: ItemMod = parse_quote! {
mod storage_keyword {}
Expand Down
Loading