anchor icon indicating copy to clipboard operation
anchor copied to clipboard

lang/syn: use rustdoc to search for IDL type definitions

Open lithdew opened this issue 3 years ago • 1 comments

A limitation right now is that IDL type definitions are only generated for structs that live in the top-level of a Solana program.

It is possible to circumvent this limitation by having the Anchor CLI 1) run 'cargo doc' on a Solana program, and 2) recursively walk through the generated HTML documentation to generate IDL type definitions off of structs that are referenced in the program's fields/declarations/instructions which derive BorshSerialize/BorshDeserialize.

The only workaround right now for this is to duplicate the definitions of structs from imported crates and transmute the memory of instantiated versions of the duplicate structs when they need to be passed to external functions.

There is an option for 'cargo doc' as well to output JSON, though it requires Rust nightly which would not be ideal.

lithdew avatar Sep 03 '21 22:09 lithdew

Think this is related: #1972

billythedummy avatar Jun 28 '23 02:06 billythedummy

Added in https://github.com/coral-xyz/anchor/pull/2824 (not with rustdoc).

acheroncrypto avatar Mar 10 '24 17:03 acheroncrypto