-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.inspatialdocrules
350 lines (329 loc) · 12.8 KB
/
.inspatialdocrules
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
MUST ALWAYS use js doc documentation where every instance of a generated code snippet assumes the user doesn't know anything about anything, and therefore explains everything like a beginner.
IMPORTANT: MUST NOT complicate itself with buzzwords or tech jargon and MUST read naturally.
IMPORTANT: MUST include correct indentations, markdown elements for visual cohesion like reading a blog, where the core function MUST ALWAYS be highlighted by the biggest heading, followed by a succinct descriptive one-line summary as a subheading, before getting to the main explanation.
IMPORTANT: The documentation must be consistent and well-formatted.
IMPORTANT: If a kind of symbol e.g (class, constant, event, external, file, function, memeber, mixin, module, namespace, typedef etc...) or code warrants an explanation not inclusive of the base or core definition then highlight that explanation on `NOTE:...`, also if there's a buzzword or word that deviates from the path of simplicity (if for any reason has to) e.g an industry term or something along those lines then highlight the word or words in `Terminology: ...` explaining and breaking the term from first principles like a beginner.
IMPORTANT: When the documentation refers to another symbol within/outside the package, library or project then make it easy for users to navigate throughout the docs, by linking using appropraite linking tags e.g @link, @linkcode, @linkplain and @tutorial.
IMPORTANT: Use tags like @param, @returns, @throws and @typeParam to provide more information about specific parts of the symbol.
IMPORTANT: Provide good type information
IMPORTANT: ALWAYS document every symbol in the package, library or project exports, i.e class, constant, event, external, file, function, memeber, mixin, module, namespace, typedef etc.... For classes and interfaces for example, you should document the symbol itself, each method or property on it, including constructors
**InSpatial Core Packages**
- @inspatial/util
- @inspatial/xr
- @inspatial/kit
- @inspatial/run
- @inspatial/cache
- @inspatial/env
- @inspatial/router
- @inspatial/server
- @inspatial/ecs
- @inspatial/iss
- @inspatial/tw
- @inspatial/theme
- @inspatial/cli
- @inspatial/test
- @inspatial/vfx
- @inspatial/icon
- @inspatial/inmoji
- @inspatial/kv
- @inspatial/db
- @inspatial/cms
- @inspatial/orm
- @inspatial/auth
- @inspatial/vault
- @inspatial/ratelimit
- @inspatial/infetch
- @inspatial/cron
- @inspatial/live
- @inspatial/deploy
**Heading Section**
- MUST be the symbol name
- MUST always start with a capital letter
- MUST start with a demonstrative pronoun or determiner or definite article e.g (This or the) and then followed by an appropriate or optional verb followed by the name (symbol name)
**Subheading Section**
- MUST be a one-line summary of what the symbol does
- MUST be a clear, concise and descriptive summary of what the symbol does
**Explanation Section**
- MUST explain the symbol's purpose and functionality
- MUST use everyday language and real-world comparisons
- MUST follow a logical progression from simple to complex concepts
- MUST avoid technical jargon unless necessary (use Terminology section for technical terms)
- Prefer 50 - 100 words for basic operations (e.g., simple calculations, single transformations)
- Structure:
1. One-sentence summary
2. Real-world analogy
3. Basic usage explanation
4. Common use case
- Prefer 150 - 300 words for operations with multiple steps or configurations
- Structure:
1. Summary paragraph
2. Extended analogy
3. Key features explanation
4. Common scenarios
5. Basic considerations
- Prefer 400 - 1000 words for advanced operations, algorithms, or systems
- Structure:
1. Executive summary
2. Detailed analogy
3. Core concept breakdown
4. Feature explanations
5. Usage scenarios
6. Important considerations
7. Common pitfalls
8. Best practices
**Category Name - @category (required)**
- The category name is the name of the InSpatial core package, library or project that the symbol belongs to e.g if @inspatial/util category name will be InSpatial Util.
**Access - @access (required)**
- Defaults to public
**When the feature was added - @since (required)**
- check the current working directory where the symbol is defined for a deno.json or package.json to the current version of the package and apply the correct version.
- Use the version checker utility {@linkcode getPackageVersion} from @inspatial/util/getPackageVersion to fetch the version from your project files.
**Examples Section**
- MUST include minimum 2 examples for every symbol
- For moderately complex symbols: up to 5 examples
- For complex symbols: up to 10 examples
- Complexity is determined by:
- Number of parameters
- Different possible configurations
- Edge cases to cover
- Common usage patterns
- MUST be relatable, concise and demonstrate the most common use cases
- MUST have a clear purpose, use real-life analogies and scenarios
- MUST use TypeScript by default for better type safety
**Import Pattern Requirement**
- MUST use direct file imports for better tree shaking
```typescript
// ✅ Recommended: Direct file import
import { functionName } from '@inspatial/package/function.ts';
// ❌ Avoid: Package-level import
import { functionName } from '@inspatial/package';
```
**Performance Section**
- Add a performance section if the symbol is performance critical
- Focuse on practical optimizations
IMPORTANT: Prefer this visual hierarchy and template whenever possible.
/**
* # FunctionName (preferably a verb starts with a capital letter)
* @summary #### clear, one-line description of what this does
*
* The `FunctionName`. Think of it like [insert real-world analogy].
* The explanation continues with natural, conversational language that anyone can understand.
*
* @since ${await getPackageVersion()} // Automatically detected from deno.json/package.json
* @category CategoryName
* @module ModuleName
* @kind <kindName>
* @access <package|private|protected|public>
*
* ### 💡 Core Concepts
* - Explain the main ideas behind this function
* - Break down complex ideas into simple terms
* - Use everyday analogies where possible
*
* {@tutorial core-concepts-deep-dive} // Deep dive into the core concepts
*
* ### 🎯 Prerequisites
* Before you start:
* - What you need to know
* - What should be set up
* - Any dependencies required
*
* ### 📚 Terminology
* > **Term1**: Here's what this means in simple words...
* > **Term2**: Another technical term explained simply...
*
* ### ⚠️ Important Notes
* <details>
* <summary>Click to learn more about edge cases</summary>
*
* > [!NOTE]
* > Important information about specific scenarios
*
* > [!NOTE]
* > Additional considerations to keep in mind
* </details>
*
* ### 📝 Type Definitions
* ```typescript
* interface TypeName {
* property: string; // Explain what this property is for
* optional?: number; // Explain when this might be needed
* }
* ```
* {@tutorial working-with-types} // Guide to using types effectively
*
* @param {Type} paramName - Start with a verb (e.g., "Stores", "Calculates", "Finds")
* Continued explanation with real-world examples.
* Can span multiple lines for clarity.
*
* @typeParam T - If using generics, explain like teaching a newcomer
*
* ### 🎮 Usage
* #### Installation
* ```bash
* # Deno
* deno add jsr:@inspatial/package-name
* ```
* {@tutorial installation-and-setup} // Complete setup guide
*
* #### Examples
* Here's how you might use this in real life:
*
* @example
* ### Example 1: Your First Shopping Cart
* ```typescript
* // Let's create a simple shopping list, just like you would at a grocery store
* const groceries = [
* { name: "Bread", price: 3 }, // A loaf of bread
* { name: "Milk", price: 4 } // A carton of milk
* ];
*
* // Now, let's calculate how much you need to pay
* const totalCost = functionName(groceries);
*
* // The function adds it up for you: $3 + $4 = $7
* console.log(`Your total is: ${totalCost}`); // Output: Your total is: $7
*
* // Want to know the total with tax included? Just like at a real store!
* const totalWithTax = functionName(groceries, { includeTax: true });
* console.log(`Total with tax: ${totalWithTax}`); // Output: Total with tax: $7.70
* ```
*
* @example
* ### Example 2: Handling Special Cases
* ```typescript
* // Sometimes your shopping cart might be empty
* // (like when you realize you forgot your shopping list at home!)
* const emptyCart = [];
* const emptyTotal = functionName(emptyCart);
* console.log(emptyTotal); // Output: 0 (No items = no cost)
*
* // Or maybe some items have pricing errors
* // (like when the price tag is missing or damaged)
* const itemsWithProblems = [
* { name: "Apple", price: 1 }, // This price is fine
* { name: "Orange", price: null }, // Oops, missing price tag!
* { name: "Banana", price: -2 } // Wait, negative price? That's not right!
* ];
*
* // Don't worry! The function handles these problems gracefully
* const validTotal = functionName(itemsWithProblems);
* console.log(`Total for valid items: ${validTotal}`); // Output: Total for valid items: $1
* ```
*
* @example
* ### Example 3: Planning a Birthday Party 🎉
* ```typescript
* // Let's calculate party supplies with some special discounts
* const partySupplies = [
* { name: "Birthday Cake", price: 30 }, // Every party needs a cake!
* { name: "Balloons", price: 10 }, // A bunch of colorful balloons
* { name: "Party Hats", price: 15 } // Fun party hats for everyone
* ];
*
* // Let's make it a special deal with:
* // - 20% birthday discount
* // - Prices rounded to make it easier to handle cash
* // - Show prices in your local currency
* const partyOptions = {
* currency: "USD", // Using US dollars
* discount: 0.2, // 20% birthday discount
* roundToNearest: 1 // Round to nearest dollar
* };
*
* const partyTotal = functionName(partySupplies, partyOptions);
*
* // The function does all the math for you:
* // 1. Adds up all items: $30 + $10 + $15 = $55
* // 2. Applies 20% discount: $55 - (55 × 20%) = $44
* console.log(`Party total with birthday discount: ${partyTotal}`);
* // Output: Party total with birthday discount: $44
* ```
*
* ### ⚡ Performance Tips (if applicable)
* <details>
* <summary>Click to learn about performance</summary>
*
* - Best practices for optimal performance
* - When to use alternatives
* - Resource usage considerations
* </details>
*
* {@tutorial performance-optimization} // Comprehensive performance guide
*
* ### ❌ Common Mistakes
* <details>
* <summary>Click to see what to avoid</summary>
*
* - Mistake 1: What not to do and why
* - Mistake 2: Common pitfall and how to avoid it
* </details>
*
* {@tutorial troubleshooting} // Common problems and solutions
*
* @throws {ErrorType}
* Explains when and why errors might occur in plain language.
* For example: "This will show an error if you try to check out with an empty cart"
*
* @returns {ReturnType}
* Explains what you get back, using real-world analogies.
* For example: "You'll get back a receipt with all your items and the total"
*
* ### 🔧 Runtime Support
* - ✅ Node.js
* - ✅ Deno
* - ✅ Bun
*
* {@tutorial understanding-runtime} // Runtime guides
*
* ### ♿ Accessibility (if applicable)
* <details>
* <summary>Click to see accessibility features</summary>
*
* - Considerations for screen readers
* - Keyboard navigation support
* - ARIA attributes (if applicable)
* - Color contrast guidelines
* </details>
*
* {@tutorial accessibility-best-practices} // Complete accessibility guide
*
* ### 🔄 Migration Guide (if applicable)
* <details>
* <summary>Click to see version changes</summary>
*
* If you're upgrading from an older version:
* - What's changed
* - How to update your code
* - Breaking changes
* </details>
*
* {@tutorial migration-walkthrough} // Step-by-step migration guide
*
* ### 🔗 Related Resources (if applicable)
*
* #### Internal References
* - {@link OtherFunction} - Here's how this relates to what you're looking at
* - {@linkcode RelatedClass} - Another helpful tool you might want to use
*
* #### External Resources
*
* @external GitHub
* {@link https://github.com/inspatiallabs/inspatial-core GitHub Repository}
* Source code and issue tracking
*
* #### Community Resources
* @external Discord
* {@link https://discord.gg/inspatiallabs Discord Community}
* Join our community for support and discussions
*
* @external Twitter
* {@link https://x.com/inspatiallabs Twitter}
* Follow us for updates and announcements
*
* @external LinkedIn
* {@link https://www.linkedin.com/company/inspatiallabs LinkedIn}
* Follow us for updates and announcements
*/
// The actual implementation would go here
<kindName> name ...