@@ -31,8 +31,8 @@ bun run build:watch:packages # Watch mode for packages only
3131
3232# Code Generation
3333bun run codegen # Run code generation for all clients
34- bunx coda generate # Generate client with Coda CLI
35- bunx coda init # Initialize coda.config.mjs
34+ coda generate # Generate client with Coda CLI
35+ coda init # Initialize coda.config.mjs
3636
3737# Code Quality
3838bun run lint # Run biome check + eslint
@@ -69,10 +69,11 @@ coda/
6969## Core Packages
7070
7171### 1. ** @macalinao/coda ** - CLI for client generation
72- - Zero-config by default (looks for ` ./target/idl/program .json ` )
72+ - Zero-config by default (looks for ` ./idls/* .json ` )
7373 - Configurable via ` coda.config.mjs `
7474 - Generates TypeScript clients with full type safety
7575 - Built on Codama for extensibility
76+ - Supports glob patterns for IDL discovery
7677
7778### 2. ** @macalinao/codama-instruction-accounts-dedupe -visitor**
7879 - Flattens nested account structures from Anchor IDL
8889### 4. ** @macalinao/clients-token-metadata **
8990 - Pre-generated client for Metaplex Token Metadata program
9091 - Includes custom PDAs and type definitions
91- - Ready-to-use with ` @solana/web3.js `
92+ - Ready-to-use TypeScript client
9293
9394## How Coda Works
9495
@@ -100,12 +101,21 @@ coda/
100101
101102## Configuration (coda.config.mjs)
102103
104+ ### Default Configuration
105+ Coda automatically discovers IDLs without any configuration:
106+ - Looks for ` ./idls/*.json ` by default
107+ - Place your IDL files in the ` idls/ ` directory
108+ - No config file needed for basic usage!
109+
110+ ### Single IDL Configuration
111+ For projects with a single program (like [ token-metadata] ( https://github.com/macalinao/coda/tree/master/clients/token-metadata ) ):
112+
103113``` javascript
104114import { defineConfig } from " @macalinao/coda" ;
105115import { addPdasVisitor } from " codama" ;
106116
107117export default defineConfig ({
108- // Optional: Custom paths
118+ // Optional: Custom path for single IDL
109119 idlPath: " ./idls/my_program.json" ,
110120 outputDir: " ./src/generated" ,
111121
@@ -118,6 +128,56 @@ export default defineConfig({
118128});
119129```
120130
131+ ### Multiple IDL Configuration with Glob Pattern
132+ For projects with multiple programs (like [ quarry] ( https://github.com/macalinao/coda/tree/master/clients/quarry ) ):
133+
134+ ``` javascript
135+ import { defineConfig } from " @macalinao/coda" ;
136+
137+ export default defineConfig ({
138+ // Use glob pattern to match all IDLs
139+ idlPath: " ./idls/*.json" ,
140+ outputDir: " ./src/generated" ,
141+
142+ // Optional: Add PDAs and other visitors for each program
143+ visitors: [
144+ // Custom visitors for each program
145+ ]
146+ });
147+ ```
148+
149+ ### Multiple IDL Configuration with Array
150+ You can also explicitly list IDL files:
151+
152+ ``` javascript
153+ import { defineConfig } from " @macalinao/coda" ;
154+
155+ export default defineConfig ({
156+ // Array of specific IDL paths
157+ idlPath: [
158+ " ./idls/program1.json" ,
159+ " ./idls/program2.json" ,
160+ " ./custom/path/program3.json" ,
161+ ],
162+ outputDir: " ./src/generated" ,
163+ });
164+ ```
165+
166+ ### Advanced Glob Patterns
167+ Use specific patterns to match only certain IDLs:
168+
169+ ``` javascript
170+ import { defineConfig } from " @macalinao/coda" ;
171+
172+ export default defineConfig ({
173+ // Match only IDLs starting with "quarry_"
174+ idlPath: " ./idls/quarry_*.json" ,
175+ // Or combine multiple patterns
176+ // idlPath: ["./idls/quarry_*.json", "./extra/*.json"],
177+ outputDir: " ./src/generated" ,
178+ });
179+ ```
180+
121181## Code Style Guidelines
122182
123183### TypeScript
@@ -207,9 +267,7 @@ Generated clients provide:
207267Example usage:
208268``` typescript
209269import { createTransferInstruction } from " ./generated" ;
210- import { createSolanaRpc } from " @solana/web3.js" ;
211270
212- const rpc = createSolanaRpc (" https://api.mainnet-beta.solana.com" );
213271const instruction = createTransferInstruction ({
214272 source: sourceAddress ,
215273 destination: destAddress ,
@@ -218,6 +276,40 @@ const instruction = createTransferInstruction({
218276});
219277```
220278
279+ ## Documentation Guidelines
280+
281+ ### Writing Good Documentation
282+
283+ When writing documentation for Coda or generated clients:
284+
285+ 1 . ** Command Examples** :
286+ - Always show direct command usage: ` coda generate ` , not ` bunx coda generate ` or ` npx coda `
287+ - Assume users have installed the package globally or are using it directly
288+ - Show the simplest path to success
289+
290+ 2 . ** Code Examples** :
291+ - Provide complete, runnable examples
292+ - Show imports clearly at the top
293+ - Use TypeScript for all examples
294+ - Include types where helpful for clarity
295+
296+ 3 . ** Structure** :
297+ - Start with the most common use case
298+ - Progress from simple to complex
299+ - Link to relevant examples in the repository
300+ - Use clear headings and subheadings
301+
302+ 4 . ** Best Practices** :
303+ - Explain the "why" not just the "how"
304+ - Include error messages users might see
305+ - Provide solutions to common problems
306+ - Keep examples concise but complete
307+
308+ 5 . ** Links and References** :
309+ - Link to example repositories (e.g., token-metadata for single IDL, quarry for multiple IDLs)
310+ - Reference the official Codama documentation where appropriate
311+ - Include links to Anchor documentation for IDL-related topics
312+
221313## Troubleshooting
222314
223315### Common Issues
0 commit comments