Skip to content

Commit 329de63

Browse files
authored
Merge pull request #4 from macalinao/igm/docs-v2
Add basic documentation site
2 parents 91d1e31 + 5d0f4f1 commit 329de63

File tree

357 files changed

+8067
-3476
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

357 files changed

+8067
-3476
lines changed

.changeset/deep-carrots-wink.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@macalinao/clients-token-metadata": patch
3+
"@macalinao/clients-quarry": patch
4+
"@macalinao/coda": patch
5+
"@macalinao/coda-docs": patch
6+
---
7+
8+
Add documentation site

.changeset/wicked-apples-stare.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@macalinao/clients-token-metadata": patch
3+
"@macalinao/clients-quarry": patch
4+
"@macalinao/coda": patch
5+
"@macalinao/coda-docs": patch
6+
---
7+
8+
Update all dependencies

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ node_modules/
77
dist/
88
build/
99
.turbo
10+
docs/.next/
11+
# docs/content/docs/api/clients/
1012

1113
# TypeScript
1214
*.tsbuildinfo

CLAUDE.md

Lines changed: 99 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ bun run build:watch:packages # Watch mode for packages only
3131

3232
# Code Generation
3333
bun 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
3838
bun 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
@@ -88,7 +89,7 @@ coda/
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
104114
import { defineConfig } from "@macalinao/coda";
105115
import { addPdasVisitor } from "codama";
106116

107117
export 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:
207267
Example usage:
208268
```typescript
209269
import { createTransferInstruction } from "./generated";
210-
import { createSolanaRpc } from "@solana/web3.js";
211270

212-
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
213271
const 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

biome.json renamed to biome.jsonc

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
"defaultBranch": "master"
88
},
99
"files": {
10-
"ignoreUnknown": false
10+
"ignoreUnknown": false,
11+
"includes": [
12+
"**",
13+
"!docs/.next",
14+
"!out",
15+
"!**/bun.lock",
16+
"!apps/example-dapp/src/routeTree.gen.ts"
17+
]
1118
},
1219
"formatter": {
1320
"enabled": true,
@@ -18,23 +25,19 @@
1825
"lineEnding": "lf",
1926
"lineWidth": 80,
2027
"attributePosition": "auto",
21-
"bracketSpacing": true,
22-
"includes": [
23-
"**",
24-
"!**/bun.lock",
25-
"!apps/example-dapp/src/routeTree.gen.ts"
26-
]
28+
"bracketSpacing": true
2729
},
2830
"linter": {
2931
"enabled": true,
30-
"domains": {
31-
"project": "recommended"
32-
},
32+
// "domains": {
33+
// "project": "recommended"
34+
// },
3335
"rules": {
3436
"recommended": true,
35-
"nursery": {
36-
"noFloatingPromises": "error"
37-
},
37+
// this thing lags super hard
38+
// "nursery": {
39+
// "noFloatingPromises": "error"
40+
// },
3841
"complexity": {
3942
"useSimplifiedLogicExpression": "error"
4043
},
@@ -69,24 +72,14 @@
6972
"noUnusedVariables": "warn",
7073
"noUnusedImports": "error"
7174
}
72-
},
73-
"includes": [
74-
"**",
75-
"!**/bun.lock",
76-
"!apps/example-dapp/src/routeTree.gen.ts"
77-
]
75+
}
7876
},
7977
"assist": {
8078
"actions": {
8179
"source": {
8280
"organizeImports": "on"
8381
}
84-
},
85-
"includes": [
86-
"**",
87-
"!**/bun.lock",
88-
"!apps/example-dapp/src/routeTree.gen.ts"
89-
]
82+
}
9083
},
9184
"javascript": {
9285
"formatter": {

0 commit comments

Comments
 (0)