Skip to content

Commit 7457d68

Browse files
committed
cleanup
1 parent fa9607b commit 7457d68

File tree

9 files changed

+134
-14
lines changed

9 files changed

+134
-14
lines changed

CLAUDE.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ When writing documentation for Coda or generated clients:
314314

315315
## Documentation Site
316316

317-
The `docs/` folder contains the documentation site built with Fumadocs and Next.js 15. The structure follows the Fumadocs reference implementation in `vendor/fumadocs/apps/docs/`.
317+
The `apps/docs/` folder contains the documentation site built with Fumadocs and Next.js 15. The structure follows the Fumadocs reference implementation in `vendor/fumadocs/apps/docs/`.
318318

319319
### Tech Stack
320320
- **Framework**: Next.js 15 with App Router
@@ -326,23 +326,29 @@ The `docs/` folder contains the documentation site built with Fumadocs and Next.
326326

327327
### Development
328328
```bash
329-
cd docs
329+
cd apps/docs
330330
bun run dev # Start dev server on localhost:3000
331331
bun run build # Build for production
332332
```
333333

334334
### Adding Documentation
335-
1. Create MDX files in `docs/content/docs/`
335+
1. Create MDX files in `apps/docs/content/docs/`
336336
2. Update navigation in `meta.json` files if needed
337337
3. Code blocks automatically get syntax highlighting
338338
4. Use frontmatter for page metadata (title, description)
339+
5. **Important**: Do NOT include `# Title` headers in MDX files - the title is already specified in the YAML frontmatter and will be rendered automatically
339340

340341
### Key Files
341342
- `src/app/layout.config.tsx` - Site branding and navigation
342343
- `source.config.ts` - MDX and syntax highlighting config
343344
- `src/app/global.css` - Tailwind v4 imports with @source directives
344345
- `content/docs/` - Documentation content in MDX
345346

347+
### MDX Writing Guidelines
348+
- **No redundant headers**: Since the title is specified in YAML frontmatter, do NOT add `# Title` as the first line of content
349+
- Start documentation content directly with the introduction paragraph or first section (`##`)
350+
- The title from frontmatter will be automatically rendered by Fumadocs
351+
346352
## Troubleshooting
347353

348354
### Common Issues

apps/docs/content/docs/api.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ title: API Reference
33
description: Pre-built TypeScript client libraries for popular Solana programs
44
---
55

6-
# API Reference
7-
86
Coda provides pre-built TypeScript client libraries for popular Solana programs. These clients are generated using Coda and are ready to use in your projects.
97

108
## Available Clients

apps/docs/content/docs/configuration.mdx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ title: Configuration
33
description: Customize Coda generation with coda.config.mjs
44
---
55

6-
# Configuration
7-
86
Coda works zero-config out of the box, but you can customize its behavior with a `coda.config.mjs` file.
97

108
## Initialize Configuration
@@ -64,6 +62,39 @@ export default defineConfig({
6462
});
6563
```
6664

65+
### Important: Handling Naming Conflicts
66+
67+
When generating clients from multiple IDLs, be aware of potential naming conflicts:
68+
69+
- **Naming conflicts will NOT throw errors** during code generation
70+
- Conflicting names will be silently overwritten by the last processed IDL
71+
- This can lead to unexpected behavior and missing types/instructions
72+
73+
To avoid conflicts, use the `renameVisitor` from `@macalinao/codama-rename-visitor`:
74+
75+
```javascript
76+
import { renameVisitor } from "@macalinao/codama-rename-visitor";
77+
78+
export default defineConfig({
79+
visitors: [
80+
renameVisitor({
81+
// Rename conflicting instructions in specific programs
82+
programA: {
83+
instructions: {
84+
transfer: "transferA", // Rename transfer to transferA
85+
deposit: "depositA", // Rename deposit to depositA
86+
},
87+
definedTypes: {
88+
account: "accountA", // Rename account type to accountA
89+
},
90+
},
91+
}),
92+
],
93+
});
94+
```
95+
96+
See the [Quarry configuration](https://github.com/macalinao/coda/blob/master/clients/quarry/coda.config.mjs) for a real-world example where instructions like `claimRewards`, `initMiner`, and `withdrawTokens` were renamed to avoid conflicts between the `quarryMine` and `quarryMergeMine` programs.
97+
6798
## Custom PDAs
6899

69100
Define program-derived addresses with custom seeds:
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: Examples
3+
description: Real-world implementations of Coda for Solana client generation
4+
---
5+
6+
Learn from real-world implementations of Coda in production projects. These examples demonstrate different configuration approaches and use cases for generating TypeScript clients from Anchor IDLs.
7+
8+
## Official Examples
9+
10+
### Token Metadata Client
11+
12+
[![npm version](https://img.shields.io/npm/v/@macalinao/clients-token-metadata.svg?style=flat-square)](https://www.npmjs.com/package/@macalinao/clients-token-metadata)
13+
[![npm downloads](https://img.shields.io/npm/dm/@macalinao/clients-token-metadata.svg?style=flat-square)](https://www.npmjs.com/package/@macalinao/clients-token-metadata)
14+
15+
[View on GitHub →](https://github.com/macalinao/coda/tree/master/clients/token-metadata)
16+
17+
The Token Metadata client showcases Coda's capabilities for a **single program** setup:
18+
19+
- **Single IDL configuration** - Simple `coda.config.mjs` for one program
20+
- **Custom PDAs** - Adds program-derived addresses using Codama visitors
21+
- **Production-ready** - Pre-generated client for Metaplex Token Metadata
22+
- **Type-safe operations** - Full TypeScript support with proper typing
23+
24+
Perfect for projects that need to interact with a single Solana program or want to see how to configure custom PDAs and transformations.
25+
26+
### Quarry Client
27+
28+
[![npm version](https://img.shields.io/npm/v/@macalinao/clients-quarry.svg?style=flat-square)](https://www.npmjs.com/package/@macalinao/clients-quarry)
29+
[![npm downloads](https://img.shields.io/npm/dm/@macalinao/clients-quarry.svg?style=flat-square)](https://www.npmjs.com/package/@macalinao/clients-quarry)
30+
31+
[View on GitHub →](https://github.com/macalinao/coda/tree/master/clients/quarry)
32+
33+
The Quarry client demonstrates Coda's **multi-program** capabilities:
34+
35+
- **Multiple IDL handling** - Uses glob patterns to process multiple IDLs
36+
- **Workspace management** - Generates clients for an entire protocol suite
37+
- **Shared types** - Manages dependencies between related programs
38+
- **Modular structure** - Organized output for complex protocol interactions
39+
40+
Ideal for protocol developers managing multiple interconnected programs or anyone building comprehensive DeFi integrations.
41+
42+
## What Makes These Examples Unique
43+
44+
### Token Metadata
45+
- Shows how to extend generated code with custom PDAs
46+
- Demonstrates integration with existing Metaplex ecosystem
47+
- Includes practical patterns for NFT and metadata operations
48+
49+
### Quarry
50+
- Illustrates handling of protocol-wide client generation
51+
- Shows glob pattern configuration for discovering IDLs
52+
- Demonstrates organizing multiple programs in a single package
53+
54+
## Add Your Example
55+
56+
Using Coda in your project? We'd love to showcase it!
57+
58+
**[Submit a Pull Request →](https://github.com/macalinao/coda/pulls)** to add your project to this documentation.
59+
60+
### How to Add Your Example
61+
62+
1. Fork the [Coda repository](https://github.com/macalinao/coda)
63+
2. Edit this file at `docs/content/docs/examples.mdx`
64+
3. Add your project following this format:
65+
66+
```mdx
67+
### Your Project Name
68+
69+
[View on GitHub →](https://github.com/yourname/yourproject)
70+
71+
Brief description of what makes your implementation unique:
72+
73+
- **Key feature 1** - Description
74+
- **Key feature 2** - Description
75+
- **Key feature 3** - Description
76+
77+
What developers can learn from your example.
78+
```
79+
80+
4. Submit your PR with a clear description
81+
82+
We welcome examples that demonstrate:
83+
- Novel configuration approaches
84+
- Integration patterns
85+
- Complex visitor usage
86+
- Multi-program setups
87+
- Custom code generation workflows
88+
- Production deployment strategies
89+
90+
Help the Solana developer community by sharing your Coda implementation!

apps/docs/content/docs/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Introduction
33
description: TypeScript client generation for Solana programs
44
---
55

6-
# Welcome to Coda
6+
## Welcome to Coda
77

88
Coda automatically generates TypeScript clients for Solana programs using Anchor IDLs.
99

apps/docs/content/docs/installation.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ title: Installation
33
description: Install and configure Coda for your project
44
---
55

6-
# Installation
7-
86
Coda can be installed and used in several ways depending on your project needs.
97

108
## Quick Start (No Installation)

apps/docs/content/docs/meta.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"quick-start",
77
"why-coda",
88
"configuration",
9+
"examples",
910
"api"
1011
]
1112
}

apps/docs/content/docs/quick-start.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ title: Quick Start
33
description: Generate your first TypeScript client with Coda
44
---
55

6-
# Quick Start
7-
86
This guide walks you through generating your first TypeScript client from an Anchor IDL.
97

108
## Step 1: Build Your Program

apps/docs/content/docs/why-coda.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ title: Why Coda?
33
description: Understanding the advantages of Coda over Anchor's built-in TypeScript client
44
---
55

6-
# Why Coda?
7-
86
While Anchor provides a built-in TypeScript client via [@coral-xyz/anchor](https://www.anchor-lang.com/docs/clients/typescript), Coda offers a modern alternative that addresses several limitations and provides additional features critical for production Solana applications.
97

108
## The Limitations of Anchor's TypeScript Client

0 commit comments

Comments
 (0)