Skip to content

Commit a6dd3bc

Browse files
authored
dev docs writing skill - first draft (#120)
1 parent 99fbf9c commit a6dd3bc

File tree

1 file changed

+206
-0
lines changed

1 file changed

+206
-0
lines changed
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
---
2+
name: sdk-docs-writing
3+
description: Write JSDoc comments in the Base44 JavaScript SDK that produce good Mintlify reference docs. Use when adding or editing JSDoc on public types, interfaces, or methods in the SDK source, or when working on the doc generation pipeline.
4+
---
5+
6+
# Base44 SDK documentation guidelines
7+
8+
Docs in this repo are **auto-generated** from JSDoc comments in TypeScript source files. The pipeline is:
9+
10+
```
11+
.types.ts JSDoc → TypeDoc → custom Mintlify plugin → post-processing → Mintlify MDX
12+
```
13+
14+
You write JSDoc. The tooling produces the final pages. This skill covers how to write JSDoc that generates clear, useful reference docs.
15+
16+
## Where docs come from
17+
18+
| File pattern | Role |
19+
|---|---|
20+
| `src/modules/*.types.ts` | **Public API surface** — JSDoc here becomes the published docs |
21+
| `src/modules/*.ts` | Implementation — mark with `@internal` to hide from docs |
22+
| `src/client.types.ts` | Client factory types |
23+
| `src/types.ts` | Shared types |
24+
25+
Only types and functions **not** marked `@internal` appear in the generated docs. Implementation files should mark their exports `@internal`.
26+
27+
## JSDoc structure for interfaces and types
28+
29+
### Module interface (top-level)
30+
31+
Module interfaces like `EntitiesModule`, `AuthModule`, and `IntegrationsModule` are the entry points. Their JSDoc becomes the module's intro page. Write a thorough description:
32+
33+
```typescript
34+
/**
35+
* Authentication module for managing user authentication and authorization.
36+
*
37+
* This module provides comprehensive authentication functionality including:
38+
* - Email/password login and registration
39+
* - Token management
40+
* - User profile access and updates
41+
*
42+
* The auth module is only available in user authentication mode (`base44.auth`).
43+
*/
44+
export interface AuthModule {
45+
```
46+
47+
Rules for module descriptions:
48+
- First sentence: one-line summary of what the module does.
49+
- Follow with a list of key capabilities using markdown bullet points.
50+
- State which authentication modes the module supports (anonymous, user, service role).
51+
- Use `{@link ModuleName | display text}` to cross-reference other modules.
52+
53+
### Method documentation
54+
55+
Every public method needs: description, `@param` tags, `@returns`, and at least one `@example`.
56+
57+
```typescript
58+
/**
59+
* Lists records with optional pagination and sorting.
60+
*
61+
* Retrieves all records of this type with support for sorting,
62+
* pagination, and field selection.
63+
*
64+
* **Note:** The maximum limit is 5,000 items per request.
65+
*
66+
* @param sort - Sort parameter, such as `'-created_date'` for descending. Defaults to `'-created_date'`.
67+
* @param limit - Maximum number of results to return. Defaults to `50`.
68+
* @param skip - Number of results to skip for pagination. Defaults to `0`.
69+
* @param fields - Array of field names to include in the response. Defaults to all fields.
70+
* @returns Promise resolving to an array of records with selected fields.
71+
*
72+
* @example
73+
* ```typescript
74+
* // Get all records
75+
* const records = await base44.entities.MyEntity.list();
76+
* ```
77+
*
78+
* @example
79+
* ```typescript
80+
* // Get first 10 records sorted by date
81+
* const recentRecords = await base44.entities.MyEntity.list('-created_date', 10);
82+
* ```
83+
*/
84+
```
85+
86+
### Interface properties
87+
88+
Use inline JSDoc comments. One line per property:
89+
90+
```typescript
91+
export interface DeleteManyResult {
92+
/** Whether the deletion was successful */
93+
success: boolean;
94+
/** Number of entities that were deleted */
95+
deleted: number;
96+
}
97+
```
98+
99+
For properties with defaults or special behavior, use `@default`:
100+
101+
```typescript
102+
/** If set to `true`, the LLM will use Google Search to gather context.
103+
* @default false
104+
*/
105+
add_context_from_internet?: boolean;
106+
```
107+
108+
## Tag reference
109+
110+
| Tag | When to use | Notes |
111+
|---|---|---|
112+
| `@param name - Description.` | Every function/method parameter | Include default value in prose: "Defaults to `50`." |
113+
| `@returns` | Every function/method | Start with "Promise resolving to..." for async methods |
114+
| `@example` | Every public method (at least one) | Each `@example` block becomes a tab in `<CodeGroup>` |
115+
| `@typeParam T` | Generic type parameters | Explain what the type represents and its default |
116+
| `@throws {Error}` | Methods that throw on known conditions | Describe the condition |
117+
| `@internal` | Implementation details hidden from docs | Use on factory functions, config interfaces, helpers |
118+
| `@default value` | Properties with default values | The plugin renders this in the output |
119+
| `{@link Type \| display}` | Cross-reference another type or module | Use for "see also" references |
120+
| `{@linkcode method \| display()}` | Link to a method with code formatting | Use when saying "use X() first" |
121+
122+
## Writing examples
123+
124+
Examples are the most impactful part of the docs. The TypeDoc plugin converts each `@example` block into a `<CodeGroup>` tab.
125+
126+
### Format
127+
128+
Always use TypeScript fenced code blocks. The first comment line becomes the tab title:
129+
130+
```typescript
131+
@example
132+
```typescript
133+
// Basic usage
134+
const records = await base44.entities.MyEntity.list();
135+
```
136+
```
137+
138+
### Guidelines
139+
140+
- **Start simple.** First example should be the most basic call with minimal parameters.
141+
- **Show real patterns.** Use realistic entity names (`Task`, `User`), not abstract ones.
142+
- **Build complexity.** Progress from basic → with options → with error handling.
143+
- **Use `base44.` prefix.** All examples should show the call path from the SDK client: `base44.entities.X`, `base44.auth.X`, `base44.integrations.Core.X`.
144+
- **Include error handling** for methods that can fail (auth, network calls):
145+
```typescript
146+
@example
147+
```typescript
148+
// With error handling
149+
try {
150+
const result = await base44.auth.loginViaEmailPassword(email, password);
151+
} catch (error) {
152+
console.error('Login failed:', error);
153+
}
154+
```
155+
```
156+
- **Show cleanup** for subscriptions and resources:
157+
```typescript
158+
@example
159+
```typescript
160+
// Subscribe and clean up
161+
const unsubscribe = base44.entities.Task.subscribe((event) => {
162+
console.log(event);
163+
});
164+
// Later:
165+
unsubscribe();
166+
```
167+
```
168+
169+
## Writing style
170+
171+
- **Developer audience.** These are SDK reference docs for JavaScript/TypeScript developers.
172+
- **Concise descriptions.** First sentence is a verb phrase: "Lists records...", "Creates a new...", "Sends an invitation...".
173+
- **Sentence case** for free-text headings in JSDoc (e.g., `## Built-in User Entity`).
174+
- **Avoid gerunds** in section headings within JSDoc. Prefer imperatives or noun phrases.
175+
- **State environment constraints** when a method is browser-only: "Requires a browser environment and can't be used in the backend."
176+
- **Document side effects** explicitly (e.g., "automatically sets the token for subsequent requests").
177+
178+
## Doc generation pipeline
179+
180+
After editing JSDoc, regenerate and review:
181+
182+
```bash
183+
npm run create-docs
184+
cd docs
185+
mint dev
186+
```
187+
188+
### Pipeline configuration files
189+
190+
| File | Purpose |
191+
|---|---|
192+
| `scripts/mintlify-post-processing/category-map.json` | Maps TypeDoc output folders to nav group names |
193+
| `scripts/mintlify-post-processing/types-to-expose.json` | Whitelist of types included in generated docs |
194+
| `scripts/mintlify-post-processing/appended-articles.json` | Stitches helper types into host pages |
195+
| `scripts/mintlify-post-processing/file-processing/docs-json-template.json` | Template for generated `docs.json` |
196+
197+
When adding a new public type, add it to `types-to-expose.json`. When a helper type should live inside another page, add it to `appended-articles.json`.
198+
199+
## Checklist before submitting a PR
200+
201+
1. **JSDoc completeness:** Every public method has description, `@param`, `@returns`, and `@example`.
202+
2. **`@internal` on implementation:** Factory functions, config interfaces, and helpers are marked `@internal`.
203+
3. **Examples work:** Code examples are syntactically valid TypeScript and use the `base44.` call path.
204+
4. **Pipeline config:** New public types are in `types-to-expose.json`. Helper types that belong on another page are in `appended-articles.json`.
205+
5. **Generate and review:** Run `npm run create-docs` and check the output renders correctly.
206+
6. **README:** If adding a new module or major feature, update `README.md`.

0 commit comments

Comments
 (0)