Skip to content

Conversation

@rustopian
Copy link
Contributor

@rustopian rustopian commented Nov 19, 2025

Problem

A docs attribute (akin to Anchor's desc) is not handled by the rust attribute parsing, resulting in no account doc comments in generated JS clients.

Solution

Added support for an optional docs parameter in the #[codama(account(...))] directive. The parameter accepts a string that gets converted to the docs array field on InstructionAccountNode.

Example usage:

#[codama(account(name = "stake", writable, docs = "The stake account to operate on"))]

Alternatives considered

  • Calling the param desc was considered, since Anchor uses this in its IDLs. However, the codama codebase already expresses a preference for this to be an array of strings named docs.
  • Parsing directly from /// doc comments typically used for instruction definitions was considered, but this is brittle.

@rustopian
Copy link
Contributor Author

@lorisleiva have been using this tweak locally, open to the alternatives tho

@lorisleiva lorisleiva self-requested a review November 20, 2025 13:38
Copy link
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfection, thank you! I think we can do the same for the argument and field attributes now that we have Docs::from_meta. ☺️

@rustopian rustopian changed the title support parsing of docs parameter in account directive support parsing of docs parameter in account, argument, field directives Nov 20, 2025
@lorisleiva lorisleiva merged commit a390ac5 into codama-idl:main Nov 20, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants