@rxap/plugin-llm 20.0.0 → 20.0.1-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +61 -6
- package/package.json +2 -2
- package/src/generators/documentation/generator.js +20 -16
- package/src/generators/documentation/generator.js.map +1 -1
- package/src/generators/documentation/system-prompts/context.txt +38 -0
- package/src/generators/documentation/system-prompts/default-block-tag.txt +127 -0
- package/src/generators/documentation/system-prompts/example-block-tag.txt +23 -0
- package/src/generators/documentation/system-prompts/example-output.txt +21 -0
- package/src/generators/documentation/system-prompts/full-example.txt +100 -0
- package/src/generators/documentation/system-prompts/generic.txt +1 -236
- package/src/generators/documentation/system-prompts/instructions.txt +3 -0
- package/src/generators/documentation/system-prompts/param-block-tag.txt +93 -0
- package/src/generators/documentation/system-prompts/prompt.handlebars +5 -0
- package/src/generators/documentation/system-prompts/property-block-tag.txt +26 -0
- package/src/generators/documentation/system-prompts/remember.txt +5 -0
- package/src/generators/documentation/system-prompts/returns-block-tag.txt +12 -0
- package/src/generators/documentation/system-prompts/summary-block-tag.txt +11 -0
- package/src/generators/documentation/system-prompts/throws-block-tag.txt +25 -0
- package/src/generators/documentation/system-prompts/type-param-block-tag.txt +22 -0
- package/src/lib/clear-all-js-docs.d.ts +2 -2
- package/src/lib/clear-all-js-docs.js +30 -1
- package/src/lib/clear-all-js-docs.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [20.0.1-dev.0](https://gitlab.com/rxap/packages/compare/@rxap/plugin-llm@20.0.0...@rxap/plugin-llm@20.0.1-dev.0) (2025-02-17)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @rxap/plugin-llm
|
|
9
|
+
|
|
6
10
|
# [20.0.0](https://gitlab.com/rxap/packages/compare/@rxap/plugin-llm@20.0.0-dev.2...@rxap/plugin-llm@20.0.0) (2025-02-13)
|
|
7
11
|
|
|
8
12
|
**Note:** Version bump only for package @rxap/plugin-llm
|
package/README.md
CHANGED
|
@@ -1,11 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
This npm package provides tools for generating documentation and package descriptions using large language models (LLMs). It includes functionality for cleaning JSDoc comments, counting tokens, composing context for LLM prompts, and integrating with services like OpenAI. The package also offers generators for automatically adding documentation to TypeScript code and creating package descriptions based on project source code.
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@rxap/plugin-llm)
|
|
4
|
+
[](https://commitizen.github.io/cz-cli/)
|
|
5
|
+
[](https://github.com/prettier/prettier)
|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Generators](#generators)
|
|
12
|
+
- [init](#init)
|
|
13
|
+
- [documentation](#documentation)
|
|
14
|
+
- [package-description](#package-description)
|
|
6
15
|
|
|
7
|
-
|
|
16
|
+
# Installation
|
|
8
17
|
|
|
9
|
-
|
|
18
|
+
**Add the package to your workspace:**
|
|
19
|
+
```bash
|
|
20
|
+
yarn add @rxap/plugin-llm
|
|
21
|
+
```
|
|
22
|
+
**Execute the init generator:**
|
|
23
|
+
```bash
|
|
24
|
+
yarn nx g @rxap/plugin-llm:init
|
|
25
|
+
```
|
|
26
|
+
# Generators
|
|
10
27
|
|
|
11
|
-
|
|
28
|
+
## init
|
|
29
|
+
> Initialize the package in the workspace
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
nx g @rxap/plugin-llm:init
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## documentation
|
|
36
|
+
> Automatically generate the documenation for all exported typescript symboles
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
nx g @rxap/plugin-llm:documentation
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Option | Type | Default | Description
|
|
43
|
+
--- | --- | --- | ---
|
|
44
|
+
path | string | |
|
|
45
|
+
apiKey | string | | The openai api key
|
|
46
|
+
orgId | string | | The openai organization id
|
|
47
|
+
projectId | string | | The openai project id
|
|
48
|
+
baseUrl | string | | The openai base url
|
|
49
|
+
model | string | anthropic/claude-3-5-sonnet | Set the LLM model to be used
|
|
50
|
+
|
|
51
|
+
## package-description
|
|
52
|
+
> Generates a package description based on the source code
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
nx g @rxap/plugin-llm:package-description
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Option | Type | Default | Description
|
|
59
|
+
--- | --- | --- | ---
|
|
60
|
+
project | string | |
|
|
61
|
+
apiKey | string | | The openai api key
|
|
62
|
+
orgId | string | | The openai organization id
|
|
63
|
+
projectId | string | | The openai project id
|
|
64
|
+
baseUrl | string | | The openai base url
|
|
65
|
+
model | string | gemini/2.0-flash | Set the LLM model to be used
|
|
66
|
+
overwrite | boolean | | Replaces the existing description files
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "20.0.0",
|
|
2
|
+
"version": "20.0.1-dev.0",
|
|
3
3
|
"name": "@rxap/plugin-llm",
|
|
4
4
|
"description": "This npm package provides tools for generating documentation and package descriptions using large language models (LLMs). It includes functionality for cleaning JSDoc comments, counting tokens, composing context for LLM prompts, and integrating with services like OpenAI. The package also offers generators for automatically adding documentation to TypeScript code and creating package descriptions based on project source code.\n",
|
|
5
5
|
"license": "GPL-3.0-or-later",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"schematics": "./generators.json",
|
|
46
46
|
"type": "commonjs",
|
|
47
47
|
"types": "./src/index.d.ts",
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "9c6b5087587f25e790ac3eb934055381506e1f08"
|
|
49
49
|
}
|
|
@@ -7,21 +7,17 @@ const node_fs_1 = require("node:fs");
|
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const ts_morph_1 = require("ts-morph");
|
|
10
|
-
const add_js_doc_1 = require("../../lib/add-js-doc");
|
|
11
|
-
const cleanup_js_doc_1 = require("../../lib/cleanup-js-doc");
|
|
12
10
|
const clear_all_js_docs_1 = require("../../lib/clear-all-js-docs");
|
|
13
|
-
const clear_js_doc_1 = require("../../lib/clear-js-doc");
|
|
14
|
-
const completion_1 = require("../../lib/completion");
|
|
15
11
|
const compose_context_1 = require("../../lib/compose-context");
|
|
16
12
|
const model_1 = require("../../lib/model");
|
|
17
13
|
function generateTsDoc(_a) {
|
|
18
14
|
return tslib_1.__awaiter(this, arguments, void 0, function* ({ context, target, question, node, systemPrompt, options }) {
|
|
19
|
-
|
|
15
|
+
console.log(`${question}`.blue);
|
|
20
16
|
try {
|
|
21
|
-
const jsDoc =
|
|
17
|
+
// const jsDoc = await completion(systemPrompt, [ context, target, question ].join('\n\n'), options);
|
|
22
18
|
// console.log(jsDoc.grey);
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
// clearJsDoc(node);
|
|
20
|
+
// addJsDoc(node, cleanupJsDoc(jsDoc));
|
|
25
21
|
}
|
|
26
22
|
catch (e) {
|
|
27
23
|
console.log(`${e.message}`.red, e.stack);
|
|
@@ -56,7 +52,8 @@ function documentationGenerator(tree, options) {
|
|
|
56
52
|
// console.log('TARGET'.bgGreen + '\n' + `${target}`.grey);
|
|
57
53
|
for (const functionDeclaration of sourceFile.getFunctions()) {
|
|
58
54
|
console.log(`PROCESS`.grey + ' ' + `function ${functionDeclaration.getName()}`.green);
|
|
59
|
-
|
|
55
|
+
let question = `TASK: create the TSDoc documentation for the function \`${functionDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\`\n\n`;
|
|
56
|
+
question += functionDeclaration.getText({ includeJsDocComments: false, trimLeadingIndentation: true });
|
|
60
57
|
const success = yield generateTsDoc({
|
|
61
58
|
systemPrompt,
|
|
62
59
|
question,
|
|
@@ -71,7 +68,8 @@ function documentationGenerator(tree, options) {
|
|
|
71
68
|
}
|
|
72
69
|
for (const interfaceDeclaration of sourceFile.getInterfaces()) {
|
|
73
70
|
console.log(`PROCESS`.grey + ' ' + `interface ${interfaceDeclaration.getName()}`.green);
|
|
74
|
-
let question = `TASK: create the TSDoc documentation for the interface \`${interfaceDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}
|
|
71
|
+
let question = `TASK: create the TSDoc documentation for the interface \`${interfaceDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\`\n\n`;
|
|
72
|
+
question += (0, clear_all_js_docs_1.clearAllJsDocs)(interfaceDeclaration).getText({ includeJsDocComments: false, trimLeadingIndentation: true });
|
|
75
73
|
const success = yield generateTsDoc({
|
|
76
74
|
systemPrompt,
|
|
77
75
|
question,
|
|
@@ -85,7 +83,8 @@ function documentationGenerator(tree, options) {
|
|
|
85
83
|
}
|
|
86
84
|
for (const method of interfaceDeclaration.getMethods()) {
|
|
87
85
|
console.log(`PROCESS`.grey + ' ' + `method ${interfaceDeclaration.getName()}::${method.getName()}`.green);
|
|
88
|
-
question = `TASK: create the TSDoc documentation for the method \`${method.getName()}\` of interface \`${interfaceDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}
|
|
86
|
+
question = `TASK: create the TSDoc documentation for the method \`${method.getName()}\` of interface \`${interfaceDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\`\n\n`;
|
|
87
|
+
question += method.getText({ includeJsDocComments: false, trimLeadingIndentation: true });
|
|
89
88
|
const success = yield generateTsDoc({
|
|
90
89
|
systemPrompt,
|
|
91
90
|
question,
|
|
@@ -100,7 +99,8 @@ function documentationGenerator(tree, options) {
|
|
|
100
99
|
}
|
|
101
100
|
for (const property of interfaceDeclaration.getProperties()) {
|
|
102
101
|
console.log(`PROCESS`.grey + ' ' + `interface ${interfaceDeclaration.getName()}::${property.getName()}`.green);
|
|
103
|
-
question = `TASK: create the TSDoc documentation for the method \`${property.getName()}\` of interface \`${interfaceDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}
|
|
102
|
+
question = `TASK: create the TSDoc documentation for the method \`${property.getName()}\` of interface \`${interfaceDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\`\n\n`;
|
|
103
|
+
question += property.getText({ includeJsDocComments: false, trimLeadingIndentation: true });
|
|
104
104
|
const success = yield generateTsDoc({
|
|
105
105
|
systemPrompt,
|
|
106
106
|
question,
|
|
@@ -116,7 +116,8 @@ function documentationGenerator(tree, options) {
|
|
|
116
116
|
}
|
|
117
117
|
for (const typeDeclaration of sourceFile.getTypeAliases()) {
|
|
118
118
|
console.log(`PROCESS`.grey + ' ' + `type ${typeDeclaration.getName()}`.green);
|
|
119
|
-
|
|
119
|
+
let question = `TASK: create the TSDoc documentation for the type \`${typeDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\`\n\n`;
|
|
120
|
+
question += typeDeclaration.getText({ includeJsDocComments: false, trimLeadingIndentation: true });
|
|
120
121
|
const success = yield generateTsDoc({
|
|
121
122
|
systemPrompt,
|
|
122
123
|
question,
|
|
@@ -131,7 +132,8 @@ function documentationGenerator(tree, options) {
|
|
|
131
132
|
}
|
|
132
133
|
for (const classDeclaration of sourceFile.getClasses()) {
|
|
133
134
|
console.log(`PROCESS`.grey + ' ' + `class ${classDeclaration.getName()}`.green);
|
|
134
|
-
let question = `TASK: create the TSDoc documentation for the class \`${classDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}
|
|
135
|
+
let question = `TASK: create the TSDoc documentation for the class \`${classDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\`\n\n`;
|
|
136
|
+
question += (0, clear_all_js_docs_1.clearAllJsDocs)(classDeclaration).getText({ includeJsDocComments: false, trimLeadingIndentation: true });
|
|
135
137
|
const success = yield generateTsDoc({
|
|
136
138
|
systemPrompt,
|
|
137
139
|
question,
|
|
@@ -145,7 +147,8 @@ function documentationGenerator(tree, options) {
|
|
|
145
147
|
}
|
|
146
148
|
for (const method of classDeclaration.getMethods().filter(method => !method.getScope() || method.getScope() === ts_morph_1.Scope.Public)) {
|
|
147
149
|
console.log(`PROCESS`.grey + ' ' + `method ${classDeclaration.getName()}::${method.getName()}`.green);
|
|
148
|
-
question = `TASK: create the TSDoc documentation for the method \`${method.getName()}\` of class \`${classDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}
|
|
150
|
+
question = `TASK: create the TSDoc documentation for the method \`${method.getName()}\` of class \`${classDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\`\n\n`;
|
|
151
|
+
question += method.getText({ includeJsDocComments: false, trimLeadingIndentation: true });
|
|
149
152
|
const success = yield generateTsDoc({
|
|
150
153
|
systemPrompt,
|
|
151
154
|
question,
|
|
@@ -160,7 +163,8 @@ function documentationGenerator(tree, options) {
|
|
|
160
163
|
}
|
|
161
164
|
for (const property of classDeclaration.getProperties().filter(property => !property.getScope() || property.getScope() === ts_morph_1.Scope.Public)) {
|
|
162
165
|
console.log(`PROCESS`.grey + ' ' + `method ${classDeclaration.getName()}::${property.getName()}`.green);
|
|
163
|
-
question = `TASK: create the TSDoc documentation for the property \`${property.getName()}\` of class \`${classDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}
|
|
166
|
+
question = `TASK: create the TSDoc documentation for the property \`${property.getName()}\` of class \`${classDeclaration.getName()}\` from the file \`${sourceFile.getFilePath()}\`\n\n`;
|
|
167
|
+
question += property.getText({ includeJsDocComments: false, trimLeadingIndentation: true });
|
|
164
168
|
const success = yield generateTsDoc({
|
|
165
169
|
systemPrompt,
|
|
166
170
|
question,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/llm/src/generators/documentation/generator.ts"],"names":[],"mappings":";;AAyDA,
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/plugin/llm/src/generators/documentation/generator.ts"],"names":[],"mappings":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S,CAAC,CAAC;IAEhD,CAAC;CAAA;AAED,kBAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
-------------------- context.xsd --------------------
|
|
2
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
3
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
4
|
+
elementFormDefault="qualified">
|
|
5
|
+
|
|
6
|
+
<!-- Definition of the sourceFileType to capture the 'path' attribute -->
|
|
7
|
+
<xsd:complexType name="sourceFileType">
|
|
8
|
+
<xsd:attribute name="path" type="xsd:string" use="required"/>
|
|
9
|
+
</xsd:complexType>
|
|
10
|
+
|
|
11
|
+
<!-- Root element 'context' -->
|
|
12
|
+
<xsd:element name="context">
|
|
13
|
+
<xsd:complexType>
|
|
14
|
+
<xsd:sequence>
|
|
15
|
+
<!-- 'referenced' element with multiple 'sourceFile' elements -->
|
|
16
|
+
<xsd:element name="referenced" minOccurs="0" maxOccurs="1">
|
|
17
|
+
<xsd:complexType>
|
|
18
|
+
<xsd:sequence>
|
|
19
|
+
<xsd:element name="sourceFile" type="sourceFileType" minOccurs="0" maxOccurs="unbounded"/>
|
|
20
|
+
</xsd:sequence>
|
|
21
|
+
</xsd:complexType>
|
|
22
|
+
</xsd:element>
|
|
23
|
+
|
|
24
|
+
<!-- 'used' element with multiple 'sourceFile' elements -->
|
|
25
|
+
<xsd:element name="used" minOccurs="0" maxOccurs="1">
|
|
26
|
+
<xsd:complexType>
|
|
27
|
+
<xsd:sequence>
|
|
28
|
+
<xsd:element name="sourceFile" type="sourceFileType" minOccurs="0" maxOccurs="unbounded"/>
|
|
29
|
+
</xsd:sequence>
|
|
30
|
+
</xsd:complexType>
|
|
31
|
+
</xsd:element>
|
|
32
|
+
|
|
33
|
+
</xsd:sequence>
|
|
34
|
+
</xsd:complexType>
|
|
35
|
+
</xsd:element>
|
|
36
|
+
|
|
37
|
+
</xsd:schema>
|
|
38
|
+
------------------------------------------------------------
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# @default Tag Documentation
|
|
2
|
+
|
|
3
|
+
The `@default` (or `@defaultValue`) tag is used to document the default value of a property, parameter, or accessor in TypeScript.
|
|
4
|
+
|
|
5
|
+
## How to Use
|
|
6
|
+
|
|
7
|
+
The syntax for the `@default` tag is:
|
|
8
|
+
```typescript
|
|
9
|
+
/** @default <value> */
|
|
10
|
+
```
|
|
11
|
+
or
|
|
12
|
+
```typescript
|
|
13
|
+
/** @defaultValue <value> */
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Both `@default` and `@defaultValue` are interchangeable and serve the same purpose.
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
Use the `@default` tag in the following scenarios:
|
|
21
|
+
1. When documenting optional properties in interfaces or classes
|
|
22
|
+
2. When documenting parameters with default values in functions or methods
|
|
23
|
+
3. When documenting configuration objects where properties have implicit default values
|
|
24
|
+
4. When documenting class properties that have initial values
|
|
25
|
+
|
|
26
|
+
### Examples:
|
|
27
|
+
|
|
28
|
+
1. **Interface Properties:**
|
|
29
|
+
```typescript
|
|
30
|
+
interface Configuration {
|
|
31
|
+
/**
|
|
32
|
+
* The port number for the server
|
|
33
|
+
* @default 3000
|
|
34
|
+
*/
|
|
35
|
+
port?: number;
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
2. **Class Properties:**
|
|
40
|
+
```typescript
|
|
41
|
+
class Timer {
|
|
42
|
+
/**
|
|
43
|
+
* The interval duration in milliseconds
|
|
44
|
+
* @default 1000
|
|
45
|
+
*/
|
|
46
|
+
private interval: number = 1000;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
3. **Function Parameters:**
|
|
51
|
+
```typescript
|
|
52
|
+
/**
|
|
53
|
+
* Creates a new user
|
|
54
|
+
* @param name The user's name
|
|
55
|
+
* @param age The user's age
|
|
56
|
+
* @param isActive User's active status
|
|
57
|
+
* @default isActive true
|
|
58
|
+
*/
|
|
59
|
+
function createUser(name: string, age: number, isActive = true) {
|
|
60
|
+
// ...
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
4. **Conditional Defaults:**
|
|
65
|
+
```typescript
|
|
66
|
+
interface DatabaseConfig {
|
|
67
|
+
/**
|
|
68
|
+
* @default 'localhost' in development, 'db.production.com' in production
|
|
69
|
+
*/
|
|
70
|
+
host?: string;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## When NOT to Use
|
|
75
|
+
|
|
76
|
+
Avoid using the `@default` tag in these situations:
|
|
77
|
+
|
|
78
|
+
1. **For Required Properties:**
|
|
79
|
+
```typescript
|
|
80
|
+
// DON'T DO THIS
|
|
81
|
+
interface User {
|
|
82
|
+
/**
|
|
83
|
+
* @default "John"
|
|
84
|
+
*/
|
|
85
|
+
name: string; // Required property shouldn't have a default
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
2. **For Constant Values:**
|
|
90
|
+
```typescript
|
|
91
|
+
// DON'T DO THIS
|
|
92
|
+
const MAX_RETRIES = 3;
|
|
93
|
+
/**
|
|
94
|
+
* @default 3
|
|
95
|
+
*/
|
|
96
|
+
export { MAX_RETRIES };
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
3. **For Runtime-Determined Values:**
|
|
100
|
+
```typescript
|
|
101
|
+
// DON'T DO THIS
|
|
102
|
+
class Application {
|
|
103
|
+
/**
|
|
104
|
+
* @default process.env.NODE_ENV
|
|
105
|
+
*/
|
|
106
|
+
environment: string;
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
4. **For Complex Objects Without Clear Default Values:**
|
|
111
|
+
```typescript
|
|
112
|
+
// DON'T DO THIS
|
|
113
|
+
interface ComplexConfig {
|
|
114
|
+
/**
|
|
115
|
+
* @default {}
|
|
116
|
+
*/
|
|
117
|
+
settings: Record<string, unknown>;
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Best Practices
|
|
122
|
+
|
|
123
|
+
1. Be explicit about conditional defaults
|
|
124
|
+
2. Use backticks (\`) for code expressions
|
|
125
|
+
3. Keep default values simple and readable
|
|
126
|
+
4. Document the conditions that affect the default value
|
|
127
|
+
5. Use with optional properties (marked with ?) when possible
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# @example
|
|
2
|
+
|
|
3
|
+
The example tag indicates that the following text is an example of how to use the function.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
/**
|
|
7
|
+
* Takes the factorial of `n`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* // If there are no code blocks, TypeDoc assumes the whole tag
|
|
11
|
+
* // should be a code block. This is not valid TSDoc, but is recognized
|
|
12
|
+
* // by VSCode and enables better TSDoc support.
|
|
13
|
+
* factorial(1)
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* If there is a code block, then both TypeDoc and VSCode will treat
|
|
17
|
+
* text outside of the code block as regular text.
|
|
18
|
+
* ```ts
|
|
19
|
+
* factorial(1)
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function factorial(n: number): number;
|
|
23
|
+
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Deletes all properties from an object that are either null or undefined.
|
|
2
|
+
|
|
3
|
+
@template T - The type of the object. It must be an object type.
|
|
4
|
+
|
|
5
|
+
@param obj - The object from which to delete the properties. This object is not modified.
|
|
6
|
+
|
|
7
|
+
@param recursive - Optional. If true, the function will recursively delete null and undefined properties from all nested objects and arrays within the object. If false or omitted, the function will only delete null and undefined properties from the top level of the object.
|
|
8
|
+
|
|
9
|
+
@returns A new object of the same type as the input object, but with all null and undefined properties removed. If the recursive option is true, all nested objects and arrays within the object will also have their null and undefined properties removed.
|
|
10
|
+
|
|
11
|
+
@example
|
|
12
|
+
```typescript
|
|
13
|
+
// returns { a: 1, c: { d: 4 } }
|
|
14
|
+
DeleteEmptyProperties({ a: 1, b: null, c: { d: 4, e: undefined } }, true);
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
@example
|
|
18
|
+
```typescript
|
|
19
|
+
// returns { a: 1, c: { d: 4, e: undefined } }
|
|
20
|
+
DeleteEmptyProperties({ a: 1, b: null, c: { d: 4, e: undefined } });
|
|
21
|
+
```
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Injectable, BadRequestException } from '@nest/core';
|
|
2
|
+
import { UserEntity } from './user.entity';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Checks if the given username is valid
|
|
6
|
+
*
|
|
7
|
+
* @param username - the username that should be validated
|
|
8
|
+
*
|
|
9
|
+
* @throws {BadRequestException} if the username is an empty string
|
|
10
|
+
* @throws if the username contains numbers
|
|
11
|
+
*
|
|
12
|
+
* @returns A boolean indicating if the username is valid
|
|
13
|
+
*
|
|
14
|
+
* @exmaple
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const isValid = checkForValidUsername('my-username');
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function checkForValidUsername(username: string): boolean {
|
|
20
|
+
if (!username) throw new BadRequestException('The given user name is empty');
|
|
21
|
+
if (username.match(/\d/)) throw new Error('The username contains numbers');
|
|
22
|
+
|
|
23
|
+
return username.length > 5 && username.startsWith('nice');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The base interface for the User object that is used in the UserService
|
|
28
|
+
*/
|
|
29
|
+
export interface User {
|
|
30
|
+
username: string;
|
|
31
|
+
password: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
*
|
|
36
|
+
* The UserService is used to access user entiteis and write them to the database
|
|
37
|
+
*
|
|
38
|
+
* @typeParam T - The of the user object that must extend the User interface
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const user: User = { username: "my-name", password: "pass" };
|
|
43
|
+
* const isValid = this.userService.validUsername(user.username);
|
|
44
|
+
* if (isValid) {
|
|
45
|
+
* await this.userService.create(user);
|
|
46
|
+
* }
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
@Injectable()
|
|
50
|
+
export class UserService<T extends User> extends DatabaseService<T, UserEntity> {
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Intdicated if this instance is currently processing user objects
|
|
54
|
+
*/
|
|
55
|
+
public readonly processing = new Subject<boolean>();
|
|
56
|
+
|
|
57
|
+
@Inject(UserRepository)
|
|
58
|
+
private readonly repositry: UserRepository;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Validates the given username
|
|
62
|
+
*
|
|
63
|
+
* @param username - the username that should be validated
|
|
64
|
+
*
|
|
65
|
+
* @throws {BadRequestException} if the username is an empty string
|
|
66
|
+
* @throws if the username contains numbers
|
|
67
|
+
* @throws {ConflictException} if a user with this username already exists
|
|
68
|
+
*
|
|
69
|
+
* @returns A boolean indicating if the username is valid
|
|
70
|
+
*/
|
|
71
|
+
validUsername(username: string) {
|
|
72
|
+
if (this.exists(username)) {
|
|
73
|
+
throw new ConflictException('The user alrady exists')
|
|
74
|
+
}
|
|
75
|
+
return checkForValidUsername(username);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Checks if a user with the given username alrady exists
|
|
80
|
+
*
|
|
81
|
+
* @param username - the username that should be check for
|
|
82
|
+
*
|
|
83
|
+
* @returns A boolean indicating if the user with the given username exists
|
|
84
|
+
*/
|
|
85
|
+
exists(username: string) {
|
|
86
|
+
return !!this.repositry.findUserByUsername(username);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Creates a new user from the given user object
|
|
91
|
+
*
|
|
92
|
+
* @param user - the user object for the new user
|
|
93
|
+
*
|
|
94
|
+
* @returns The created user entry instance
|
|
95
|
+
*/
|
|
96
|
+
async create(user: T): UserEntity {
|
|
97
|
+
return this.repositry.create({ username: user.username, password: user.password })
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
}
|
|
@@ -1,242 +1,7 @@
|
|
|
1
|
-
Your task is to generate complete TSDoc documentation for the provided TypeScript
|
|
1
|
+
Your task is to generate complete TSDoc documentation for the provided TypeScript `{{}}`. The context supplied consists of two parts:
|
|
2
2
|
|
|
3
3
|
1. The source code and all related files (both files referenced by the source code and files that use the source code) are provided as context formatted according to the schema in the context.xsd file below.
|
|
4
4
|
|
|
5
5
|
2. An overview of the available TSDoc block tags is provided in the block-tags.txt file below. You must use these tags in your documentation.
|
|
6
6
|
|
|
7
7
|
Use the following file contents as reference:
|
|
8
|
-
|
|
9
|
-
-------------------- block-tags.txt --------------------
|
|
10
|
-
# @default
|
|
11
|
-
|
|
12
|
-
The @default tag can be used to document the default value for an accessor or property.
|
|
13
|
-
```typescript
|
|
14
|
-
export interface CompilerOptions {
|
|
15
|
-
strict?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* @defaultValue `true` if `strict` is `true`, otherwise `false`
|
|
18
|
-
*/
|
|
19
|
-
strictNullChecks?: boolean;
|
|
20
|
-
}
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
# @example
|
|
24
|
-
|
|
25
|
-
The example tag indicates that the following text is an example of how to use the function.
|
|
26
|
-
|
|
27
|
-
```typescript
|
|
28
|
-
/**
|
|
29
|
-
* Takes the factorial of `n`.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* // If there are no code blocks, TypeDoc assumes the whole tag
|
|
33
|
-
* // should be a code block. This is not valid TSDoc, but is recognized
|
|
34
|
-
* // by VSCode and enables better TSDoc support.
|
|
35
|
-
* factorial(1)
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* If there is a code block, then both TypeDoc and VSCode will treat
|
|
39
|
-
* text outside of the code block as regular text.
|
|
40
|
-
* ```ts
|
|
41
|
-
* factorial(1)
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
export function factorial(n: number): number;
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
# @returns
|
|
48
|
-
|
|
49
|
-
The @returns tag can be used to document the return value of a function. At most one @returns tag should be present in a comment.
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
/**
|
|
53
|
-
* @param a - the first number
|
|
54
|
-
* @param b - the second number
|
|
55
|
-
* @returns The sum of `a` and `b`
|
|
56
|
-
*/
|
|
57
|
-
export function sum(a: number, b: number): number;
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
# @summary
|
|
61
|
-
|
|
62
|
-
The @summary tag should be used to give a short summary of the commented code. Is only sutable for functions, classes anc class methods
|
|
63
|
-
|
|
64
|
-
```typescript
|
|
65
|
-
/**
|
|
66
|
-
* @summary
|
|
67
|
-
* This description will be used on the **module** page
|
|
68
|
-
*/
|
|
69
|
-
export function forkProcess(): void;
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
# @typeParam
|
|
73
|
-
|
|
74
|
-
The @typeParam tag is used to document a type parameter of a function, method, class, interface or type alias.
|
|
75
|
-
The TSDoc standard requires that the @typeParam tag not include types and that the parameter name must be followed by a hyphen to separate it from the description.
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
/**
|
|
79
|
-
* @typeParam T - the identity type
|
|
80
|
-
*/
|
|
81
|
-
export function identity<T>(x: T): T {
|
|
82
|
-
return x;
|
|
83
|
-
}
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
# @throws
|
|
87
|
-
|
|
88
|
-
The @throws tag can be used to document an exception that can be thrown by a function or method.
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
/**
|
|
92
|
-
* @throws {@link UserError} if `max < min`
|
|
93
|
-
*/
|
|
94
|
-
export function rand(min: number, max: number): number;
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
# @property
|
|
98
|
-
|
|
99
|
-
The @property tag can be used to add a comment to a child of the current reflection. It is intended for use with the @namespace and @interface tags which might not have convenient places to include comments for each member.
|
|
100
|
-
|
|
101
|
-
```typescript
|
|
102
|
-
/**
|
|
103
|
-
* This will be displayed as an interface
|
|
104
|
-
* @property a comment for a
|
|
105
|
-
* @property b comment for b
|
|
106
|
-
* @interface
|
|
107
|
-
*/
|
|
108
|
-
export type Resolved = Record<"a" | "b" | "c", string>;
|
|
109
|
-
|
|
110
|
-
// will be documented as if you wrote
|
|
111
|
-
|
|
112
|
-
/** This will be displayed as an interface */
|
|
113
|
-
export interface Resolved {
|
|
114
|
-
/** comment for a */
|
|
115
|
-
a: string;
|
|
116
|
-
/** comment for b */
|
|
117
|
-
b: string;
|
|
118
|
-
c: string;
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
# @param
|
|
123
|
-
|
|
124
|
-
The @param tag is used to document a parameter of a function or method.
|
|
125
|
-
|
|
126
|
-
The TSDoc standard requires that the @param tag not include types and that the parameter name must be followed by a hyphen to separate it from the description.
|
|
127
|
-
|
|
128
|
-
```typescript
|
|
129
|
-
/**
|
|
130
|
-
* @param a - the first number
|
|
131
|
-
* @param b - the second number
|
|
132
|
-
*/
|
|
133
|
-
export function sum(a: number, b: number) {
|
|
134
|
-
return a + b;
|
|
135
|
-
}
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
## Object Literals
|
|
139
|
-
|
|
140
|
-
If the type of a parameter is an object literal type, a union containing an object literal type, or an intersection containing an object literal type, property names may be separated by `.` to add a comment to a single level of a nested property.
|
|
141
|
-
|
|
142
|
-
```typescript
|
|
143
|
-
/**
|
|
144
|
-
* @param options - documentation for the whole parameter
|
|
145
|
-
* @param options.value - documentation for the `value` property
|
|
146
|
-
* @param options.nested.value - NOT supported
|
|
147
|
-
*/
|
|
148
|
-
export function configure(
|
|
149
|
-
options: { value: string; nested: { value: string } } | undefined,
|
|
150
|
-
) {}
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
## Destructured Parameters
|
|
154
|
-
|
|
155
|
-
If your function uses destructured parameters, TypeDoc will attempt to infer the parameter name from your usage of the @param tag. For it to be successful, all parameters must be documented. If TypeDoc fails to infer the name of the destructured parameter, it will be documented as __namedParameters.
|
|
156
|
-
|
|
157
|
-
```typescript
|
|
158
|
-
/**
|
|
159
|
-
* @param options - docs
|
|
160
|
-
*/
|
|
161
|
-
export function configure({ value }: { value: string }) {}
|
|
162
|
-
|
|
163
|
-
// will be documented as if written as
|
|
164
|
-
export function configure(options: { value: string }) {}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
------------------------------------------------------------
|
|
169
|
-
|
|
170
|
-
-------------------- context.xsd --------------------
|
|
171
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
172
|
-
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
|
173
|
-
elementFormDefault="qualified">
|
|
174
|
-
|
|
175
|
-
<!-- Definition of the sourceFileType to capture the 'path' attribute -->
|
|
176
|
-
<xsd:complexType name="sourceFileType">
|
|
177
|
-
<xsd:attribute name="path" type="xsd:string" use="required"/>
|
|
178
|
-
</xsd:complexType>
|
|
179
|
-
|
|
180
|
-
<!-- Root element 'context' -->
|
|
181
|
-
<xsd:element name="context">
|
|
182
|
-
<xsd:complexType>
|
|
183
|
-
<xsd:sequence>
|
|
184
|
-
<!-- 'referenced' element with multiple 'sourceFile' elements -->
|
|
185
|
-
<xsd:element name="referenced" minOccurs="0" maxOccurs="1">
|
|
186
|
-
<xsd:complexType>
|
|
187
|
-
<xsd:sequence>
|
|
188
|
-
<xsd:element name="sourceFile" type="sourceFileType" minOccurs="0" maxOccurs="unbounded"/>
|
|
189
|
-
</xsd:sequence>
|
|
190
|
-
</xsd:complexType>
|
|
191
|
-
</xsd:element>
|
|
192
|
-
|
|
193
|
-
<!-- 'used' element with multiple 'sourceFile' elements -->
|
|
194
|
-
<xsd:element name="used" minOccurs="0" maxOccurs="1">
|
|
195
|
-
<xsd:complexType>
|
|
196
|
-
<xsd:sequence>
|
|
197
|
-
<xsd:element name="sourceFile" type="sourceFileType" minOccurs="0" maxOccurs="unbounded"/>
|
|
198
|
-
</xsd:sequence>
|
|
199
|
-
</xsd:complexType>
|
|
200
|
-
</xsd:element>
|
|
201
|
-
|
|
202
|
-
</xsd:sequence>
|
|
203
|
-
</xsd:complexType>
|
|
204
|
-
</xsd:element>
|
|
205
|
-
|
|
206
|
-
</xsd:schema>
|
|
207
|
-
------------------------------------------------------------
|
|
208
|
-
|
|
209
|
-
Instructions:
|
|
210
|
-
- Read the provided source code along with its related files (referenced and using) as structured by the context.xsd.
|
|
211
|
-
- Create the complete TSDoc documentation using only the TSDoc block tags listed above.
|
|
212
|
-
- Output ONLY the TSDoc content, without any additional text or any TypeScript comment syntax (omit /*, */, etc.).
|
|
213
|
-
|
|
214
|
-
Example Output:
|
|
215
|
-
------------------------------------------------------------
|
|
216
|
-
Deletes all properties from an object that are either null or undefined.
|
|
217
|
-
|
|
218
|
-
@template T - The type of the object. It must be an object type.
|
|
219
|
-
|
|
220
|
-
@param obj - The object from which to delete the properties. This object is not modified.
|
|
221
|
-
|
|
222
|
-
@param recursive - Optional. If true, the function will recursively delete null and undefined properties from all nested objects and arrays within the object. If false or omitted, the function will only delete null and undefined properties from the top level of the object.
|
|
223
|
-
|
|
224
|
-
@returns A new object of the same type as the input object, but with all null and undefined properties removed. If the recursive option is true, all nested objects and arrays within the object will also have their null and undefined properties removed.
|
|
225
|
-
|
|
226
|
-
@example
|
|
227
|
-
```typescript
|
|
228
|
-
// returns { a: 1, c: { d: 4 } }
|
|
229
|
-
DeleteEmptyProperties({ a: 1, b: null, c: { d: 4, e: undefined } }, true);
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
@example
|
|
233
|
-
```typescript
|
|
234
|
-
// returns { a: 1, c: { d: 4, e: undefined } }
|
|
235
|
-
DeleteEmptyProperties({ a: 1, b: null, c: { d: 4, e: undefined } });
|
|
236
|
-
```
|
|
237
|
-
------------------------------------------------------------
|
|
238
|
-
|
|
239
|
-
Remember:
|
|
240
|
-
- Your output must include only the TSDoc documentation content as shown in the example output, with no surrounding comment syntax.
|
|
241
|
-
- Ensure if a code example is given the code is inclosed in "```typescript" and "```"
|
|
242
|
-
- ONLY OUTPUT THE COMMENT TEXT WITHOUT ANY OTHER RESPONSE LIKE "Based on the source code" etc.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
## @param Tag Documentation
|
|
2
|
+
|
|
3
|
+
The `@param` tag is used to document a parameter of a function, method, or constructor. It provides a description for each parameter, enhancing the readability and understanding of your code's API.
|
|
4
|
+
|
|
5
|
+
### How to Use the @param Tag
|
|
6
|
+
|
|
7
|
+
The basic syntax for the `@param` tag is as follows:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
/**
|
|
11
|
+
* @param parameterName - Description of the parameter.
|
|
12
|
+
*/
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Key points:**
|
|
16
|
+
|
|
17
|
+
* `parameterName` refers to the name of the parameter as defined in the function/method signature.
|
|
18
|
+
* A hyphen (`-`) **must** separate the parameter name from its description.
|
|
19
|
+
* Parameter types are **not** included in the `@param` tag. Type information is inferred from the code.
|
|
20
|
+
|
|
21
|
+
**Example:**
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
/**
|
|
25
|
+
* Adds two numbers together.
|
|
26
|
+
* @param a - The first number to add.
|
|
27
|
+
* @param b - The second number to add.
|
|
28
|
+
* @returns The sum of a and b.
|
|
29
|
+
*/
|
|
30
|
+
export function add(a: number, b: number): number {
|
|
31
|
+
return a + b;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### When to Use the @param Tag
|
|
36
|
+
|
|
37
|
+
* **Always use** the `@param` tag for every parameter of a function, method, or constructor that is part of your public API. This ensures that users of your code understand the purpose and meaning of each parameter.
|
|
38
|
+
* Use the `@param` tag to clarify the expected input values, units, or any specific constraints on the parameter.
|
|
39
|
+
* When documenting functions or methods with complex parameter types or behaviors.
|
|
40
|
+
|
|
41
|
+
### When NOT to Use the @param Tag
|
|
42
|
+
|
|
43
|
+
* Do not include type information within the `@param` tag. TypeScript already handles type declarations.
|
|
44
|
+
* Avoid using the `@param` tag for private or internal functions/methods unless you need to generate documentation for internal use.
|
|
45
|
+
* Omit the `@param` tag for parameters with very obvious names and trivial functionality, unless you want to add extra clarity.
|
|
46
|
+
|
|
47
|
+
### Advanced Usage
|
|
48
|
+
|
|
49
|
+
#### Object Literals
|
|
50
|
+
|
|
51
|
+
When a parameter is an object literal type, you can document individual properties using a dot-separated notation:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
/**
|
|
55
|
+
* Configures the component with the given options.
|
|
56
|
+
* @param options - Configuration options for the component.
|
|
57
|
+
* @param options.width - The width of the component in pixels.
|
|
58
|
+
* @param options.height - The height of the component in pixels.
|
|
59
|
+
*/
|
|
60
|
+
function configureComponent(options: { width: number; height: number }) {
|
|
61
|
+
// ...
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
**Important Considerations for Object Literals:**
|
|
66
|
+
|
|
67
|
+
* This dot-separated notation works for a single level of nested properties. Deeper nesting is not directly supported. Document the entire object if you need to describe nested properties.
|
|
68
|
+
* This feature is most effective when documenting a public API where the structure of the object literal is important for users to understand.
|
|
69
|
+
|
|
70
|
+
#### Destructured Parameters
|
|
71
|
+
|
|
72
|
+
TypeDoc can often infer the parameter names from destructured parameters, but it requires that all parameters are documented.
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
/**
|
|
76
|
+
* Processes user data.
|
|
77
|
+
* @param id - The unique identifier of the user.
|
|
78
|
+
* @param name - The name of the user.
|
|
79
|
+
* @param email - The email address of the user.
|
|
80
|
+
*/
|
|
81
|
+
function processUser({ id, name, email }: { id: number; name: string; email: string }) {
|
|
82
|
+
// ...
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If TypeDoc fails to infer the parameter names, the destructured parameter will be documented as `__namedParameters`. To avoid this, ensure all destructured parameters are explicitly documented.
|
|
87
|
+
|
|
88
|
+
### Best Practices
|
|
89
|
+
|
|
90
|
+
* Be concise and clear in your descriptions. Avoid jargon or overly technical language.
|
|
91
|
+
* Use consistent terminology throughout your documentation.
|
|
92
|
+
* Keep your documentation up-to-date with your code.
|
|
93
|
+
* Consider using a documentation generator like TypeDoc to automate the process of creating documentation from your TSDoc comments.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Your a Software Developer tasks with writing TSDoc documentation for a TypeScript `{{target}}`.
|
|
2
|
+
You will be given the SourceFile that contains the TypeScript `{{target}}` and all SourceFiles that import the TypeScript `{{target}}` and all SourceFiles that are imported by the given SourceFile.
|
|
3
|
+
You will be given a list of allowed TSDoc block tags. Ensure the you only use the given TSDoc block tags in the given order.
|
|
4
|
+
|
|
5
|
+
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# @property
|
|
2
|
+
|
|
3
|
+
The @property tag can be used to add a comment to a child of the current reflection. It is intended for use with the @namespace and @interface tags which might not have convenient places to include comments for each member.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
/**
|
|
7
|
+
* This will be displayed as an interface
|
|
8
|
+
* @property a comment for a
|
|
9
|
+
* @property b comment for b
|
|
10
|
+
* @interface
|
|
11
|
+
*/
|
|
12
|
+
export type Resolved = Record<"a" | "b" | "c", string>;
|
|
13
|
+
|
|
14
|
+
// will be documented as if you wrote
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This will be displayed as an interface
|
|
18
|
+
*/
|
|
19
|
+
export interface Resolved {
|
|
20
|
+
/** comment for a */
|
|
21
|
+
a: string;
|
|
22
|
+
/** comment for b */
|
|
23
|
+
b: string;
|
|
24
|
+
c: string;
|
|
25
|
+
}
|
|
26
|
+
```
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
Remember:
|
|
2
|
+
- Your output must include only the TSDoc block tags listed above
|
|
3
|
+
- Ensure if a code example is given the code is inclosed in "```typescript" and "```"
|
|
4
|
+
- Output ONLY the TSDoc content, without any additional text or any TypeScript comment syntax (omit /*, */, etc.).
|
|
5
|
+
- ONLY OUTPUT THE COMMENT TEXT WITHOUT ANY OTHER RESPONSE LIKE "Based on the source code" etc.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @returns
|
|
2
|
+
|
|
3
|
+
The @returns tag can be used to document the return value of a function. At most one @returns tag should be present in a comment.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
/**
|
|
7
|
+
* @param a - the first number
|
|
8
|
+
* @param b - the second number
|
|
9
|
+
* @returns The sum of `a` and `b`
|
|
10
|
+
*/
|
|
11
|
+
export function sum(a: number, b: number): number;
|
|
12
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# @summary
|
|
2
|
+
|
|
3
|
+
The @summary tag should be used to give a short summary of the commented code. Is only sutable for functions, classes anc class methods
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
/**
|
|
7
|
+
* @summary
|
|
8
|
+
* This description will be used on the **module** page
|
|
9
|
+
*/
|
|
10
|
+
export function forkProcess(): void;
|
|
11
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @throws
|
|
2
|
+
|
|
3
|
+
The @throws tag can be used to document an exception that can be thrown by a function or method.
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
/**
|
|
7
|
+
* @throws {BadRequestException} if `max < min`
|
|
8
|
+
*/
|
|
9
|
+
export function rand(min: number, max: number): number {
|
|
10
|
+
if (max < min) {
|
|
11
|
+
throw new BadRequestException('Max is less then min')
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
/**
|
|
18
|
+
* @throws if `max < min`
|
|
19
|
+
*/
|
|
20
|
+
export function rand(min: number, max: number): number {
|
|
21
|
+
if (max < min) {
|
|
22
|
+
throw new Error('Max is less then min')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @typeParam
|
|
2
|
+
|
|
3
|
+
The @typeParam tag is used to document a type parameter of a function, method, class, interface or type alias.
|
|
4
|
+
The TSDoc standard requires that the @typeParam tag not include types and that the parameter name must be followed by a hyphen to separate it from the description.
|
|
5
|
+
|
|
6
|
+
```typescript
|
|
7
|
+
/**
|
|
8
|
+
* @typeParam T - the identity type
|
|
9
|
+
*/
|
|
10
|
+
export function identity<T>(x: T): T {
|
|
11
|
+
return x;
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
/**
|
|
17
|
+
* @typeParam T - a user object
|
|
18
|
+
*/
|
|
19
|
+
export class UserService<T> {
|
|
20
|
+
getUser(): T | null { return null; }
|
|
21
|
+
}
|
|
22
|
+
```
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SourceFile } from 'ts-morph';
|
|
2
|
-
export declare function clearAllJsDocs(
|
|
1
|
+
import { ClassDeclaration, InterfaceDeclaration, SourceFile } from 'ts-morph';
|
|
2
|
+
export declare function clearAllJsDocs<T extends SourceFile | ClassDeclaration | InterfaceDeclaration>(input: T, inplace?: boolean): T;
|
|
@@ -3,7 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.clearAllJsDocs = clearAllJsDocs;
|
|
4
4
|
const ts_morph_1 = require("ts-morph");
|
|
5
5
|
const clear_js_doc_1 = require("./clear-js-doc");
|
|
6
|
-
function clearAllJsDocs(
|
|
6
|
+
function clearAllJsDocs(input, inplace = false) {
|
|
7
|
+
switch (input.getKind()) {
|
|
8
|
+
case ts_morph_1.SyntaxKind.SourceFile:
|
|
9
|
+
return clearAllJsDocsInSourceFile(input, inplace);
|
|
10
|
+
case ts_morph_1.SyntaxKind.ClassDeclaration:
|
|
11
|
+
return clearAllJsDocsInClass(input, inplace);
|
|
12
|
+
case ts_morph_1.SyntaxKind.InterfaceDeclaration:
|
|
13
|
+
return clearAllJsDocsInInterface(input, inplace);
|
|
14
|
+
}
|
|
15
|
+
throw new Error('Unrecognized source file');
|
|
16
|
+
}
|
|
17
|
+
function clearAllJsDocsInSourceFile(sourceFile, inplace = false) {
|
|
7
18
|
const p = new ts_morph_1.Project({ useInMemoryFileSystem: true });
|
|
8
19
|
const clone = inplace ? sourceFile : p.createSourceFile('clean.ts', sourceFile.getFullText());
|
|
9
20
|
clone.getClasses().forEach(classD => {
|
|
@@ -20,4 +31,22 @@ function clearAllJsDocs(sourceFile, inplace = false) {
|
|
|
20
31
|
clone.getFunctions().forEach(funcD => (0, clear_js_doc_1.clearJsDoc)(funcD));
|
|
21
32
|
return clone;
|
|
22
33
|
}
|
|
34
|
+
function clearAllJsDocsInClass(classDeclaration, inplace = false) {
|
|
35
|
+
const p = new ts_morph_1.Project({ useInMemoryFileSystem: true });
|
|
36
|
+
const clone = inplace ? classDeclaration :
|
|
37
|
+
p.createSourceFile('clean.ts', classDeclaration.getFullText()).getClassOrThrow(classDeclaration.getName());
|
|
38
|
+
(0, clear_js_doc_1.clearJsDoc)(clone);
|
|
39
|
+
clone.getProperties().filter(property => !property.getScope() || property.getScope() === ts_morph_1.Scope.Public).forEach(prop => (0, clear_js_doc_1.clearJsDoc)(prop));
|
|
40
|
+
clone.getMethods().filter(method => !method.getScope() || method.getScope() === ts_morph_1.Scope.Public).forEach(method => (0, clear_js_doc_1.clearJsDoc)(method));
|
|
41
|
+
return clone;
|
|
42
|
+
}
|
|
43
|
+
function clearAllJsDocsInInterface(interfaceDeclaration, inplace = false) {
|
|
44
|
+
const p = new ts_morph_1.Project({ useInMemoryFileSystem: true });
|
|
45
|
+
const clone = inplace ? interfaceDeclaration :
|
|
46
|
+
p.createSourceFile('clean.ts', interfaceDeclaration.getFullText()).getInterfaceOrThrow(interfaceDeclaration.getName());
|
|
47
|
+
(0, clear_js_doc_1.clearJsDoc)(clone);
|
|
48
|
+
clone.getProperties().forEach(prop => (0, clear_js_doc_1.clearJsDoc)(prop));
|
|
49
|
+
clone.getMethods().forEach(method => (0, clear_js_doc_1.clearJsDoc)(method));
|
|
50
|
+
return clone;
|
|
51
|
+
}
|
|
23
52
|
//# sourceMappingURL=clear-all-js-docs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear-all-js-docs.js","sourceRoot":"","sources":["../../../../../../packages/plugin/llm/src/lib/clear-all-js-docs.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"clear-all-js-docs.js","sourceRoot":"","sources":["../../../../../../packages/plugin/llm/src/lib/clear-all-js-docs.ts"],"names":[],"mappings":";;AAUA,wCAcC;AAxBD,uCAOkB;AAClB,iDAA4C;AAE5C,SAAgB,cAAc,CAAiE,KAAQ,EAAE,OAAO,GAAG,KAAK;IACtH,QAAQ,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAExB,KAAK,qBAAU,CAAC,UAAU;YACxB,OAAO,0BAA0B,CAAC,KAAmB,EAAE,OAAO,CAAM,CAAC;QAEvE,KAAK,qBAAU,CAAC,gBAAgB;YAC9B,OAAO,qBAAqB,CAAC,KAAyB,EAAE,OAAO,CAAM,CAAC;QAExE,KAAK,qBAAU,CAAC,oBAAoB;YAClC,OAAO,yBAAyB,CAAC,KAA6B,EAAE,OAAO,CAAM,CAAC;IAElF,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAC9C,CAAC;AAED,SAAS,0BAA0B,CAAC,UAAsB,EAAE,OAAO,GAAG,KAAK;IACzE,MAAM,CAAC,GAAG,IAAI,kBAAO,CAAC,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9F,KAAK,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,MAA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