Skip to content

Commit c384db1

Browse files
committed
ai-readme
1 parent 89164a2 commit c384db1

File tree

3 files changed

+657
-143
lines changed

3 files changed

+657
-143
lines changed

apps/developer-hub/README.md

Lines changed: 83 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,92 @@ Update the `meta.json` file in each section to control navigation. Example:
120120
- Use proper heading hierarchy (h2, h3, etc.)
121121
- Link to related documentation when relevant
122122

123+
## API Reference Generation
124+
125+
The API reference documentation is automatically generated from OpenAPI specifications using the `scripts/generate-docs.ts` script. This script converts OpenAPI specs (from services like Hermes and Fortuna) into MDX documentation files.
126+
127+
### What It Does
128+
129+
The script performs the following steps:
130+
131+
1. **File Generation**: Uses `fumadocs-openapi` to convert OpenAPI specs into MDX files
132+
- Each API endpoint becomes a separate MDX file
133+
- Files are organized by product (e.g., `pyth-core`, `entropy`) and service (e.g., `hermes`, `fortuna`)
134+
135+
2. **Meta File Generation**: Creates `meta.json` files for navigation
136+
- Root `meta.json` for the API reference section
137+
- Product-level `meta.json` files (e.g., `pyth-core/meta.json`)
138+
- Service-level `meta.json` files (e.g., `pyth-core/hermes/meta.json`)
139+
140+
3. **Post-Processing**: Customizes generated files to match our documentation structure
141+
- Updates MDX frontmatter titles to use endpoint paths instead of operation IDs
142+
- Rewrites `index.mdx` files to use `APICard` components with proper formatting
143+
144+
### When to Run
145+
146+
The script runs automatically during the build process (`pnpm turbo run build`). You typically don't need to run it manually unless:
147+
148+
- You've updated an OpenAPI specification URL
149+
- You've added a new service to the configuration
150+
- You want to regenerate docs without doing a full build
151+
152+
### Manual Execution
153+
154+
To run the script manually:
155+
156+
```bash
157+
pnpm generate:docs
158+
```
159+
160+
This will:
161+
- Fetch OpenAPI specs from the configured URLs
162+
- Generate MDX files in `content/docs/api-reference/`
163+
- Create/update all `meta.json` navigation files
164+
- Post-process files to customize titles and index pages
165+
166+
### Configuration
167+
168+
To add a new API service, edit `src/lib/openapi.ts` and add an entry to the `products` object:
169+
170+
```typescript
171+
export const products = {
172+
// ... existing services ...
173+
newService: {
174+
name: "newService",
175+
product: "product-category", // e.g., "pyth-core" or "entropy"
176+
openApiUrl: "https://api.example.com/docs/openapi.json",
177+
},
178+
};
179+
```
180+
181+
After adding a new service:
182+
1. Run `pnpm generate:docs` to generate the documentation
183+
2. The new service will appear in the API reference navigation
184+
185+
### Generated Files
186+
187+
All generated files are written to `content/docs/api-reference/`:
188+
189+
```
190+
content/docs/api-reference/
191+
├── meta.json # Root navigation
192+
├── pyth-core/
193+
│ ├── meta.json # Product navigation
194+
│ └── hermes/
195+
│ ├── meta.json # Service navigation
196+
│ ├── index.mdx # Service overview page
197+
│ └── *.mdx # Individual endpoint pages
198+
└── entropy/
199+
└── ...
200+
```
201+
202+
**Important**: Generated files should not be edited manually. Any changes will be overwritten the next time the script runs. If you need to customize the documentation, modify the OpenAPI specification or the generation script itself.
203+
123204
## Available Commands
124205

125206
- `pnpm turbo run start:dev` - Start development server
126-
- `pnpm turbo run build` - Build the project
207+
- `pnpm turbo run build` - Build the project (includes API reference generation)
208+
- `pnpm generate:docs` - Generate API reference documentation manually
127209
- `pnpm turbo run fix:format` - Format code with Prettier
128210
- `pnpm turbo run fix:lint:eslint` - Fix ESLint issues
129211
- `pnpm turbo run test:format` - Check formatting

0 commit comments

Comments
 (0)