Skip to content

Commit 503726e

Browse files
committed
Add documentation and implementation example for the abi keyword in keyword_docs.rs.
1 parent 556b95a commit 503726e

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

sway-lsp/src/utils/keyword_docs.rs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,36 @@ impl KeywordDocs {
680680
mod continue_keyword {}
681681
};
682682

683+
let abi_keyword: ItemMod = parse_quote! {
684+
/// Defines an Application Binary Interface (ABI).
685+
///
686+
/// An `abi` block defines a set of methods that a contract exposes externally. It acts as the
687+
/// public interface for interacting with a smart contract. Only one `abi` block is allowed per
688+
/// contract.
689+
///
690+
/// The methods defined within an `abi` block must be implemented in an associated [`impl`] block
691+
/// for the contract.
692+
///
693+
/// ```sway
694+
/// contract;
695+
///
696+
/// abi MyContract {
697+
/// #[storage(read, write)]
698+
/// fn update_counter(amount: u64) -> u64;
699+
/// }
700+
///
701+
/// impl MyContract for Contract {
702+
/// #[storage(read, write)]
703+
/// fn update_counter(amount: u64) -> u64 {
704+
/// let current = storage.counter;
705+
/// storage.counter = current + amount;
706+
/// storage.counter
707+
/// }
708+
/// }
709+
/// ```
710+
mod abi_keyword {}
711+
};
712+
683713
// TODO
684714
let str_keyword: ItemMod = parse_quote! {
685715
mod str_keyword {}
@@ -725,11 +755,6 @@ impl KeywordDocs {
725755
mod mod_keyword {}
726756
};
727757

728-
// TODO
729-
let abi_keyword: ItemMod = parse_quote! {
730-
mod abi_keyword {}
731-
};
732-
733758
// TODO
734759
let storage_keyword: ItemMod = parse_quote! {
735760
mod storage_keyword {}

0 commit comments

Comments
 (0)