runtypex 0.2.2 → 0.2.3
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.
|
@@ -30,14 +30,14 @@ function generateJSDocFromSpec(params) {
|
|
|
30
30
|
_pushJSDocText(lines, _escapeComment(description));
|
|
31
31
|
lines.push(" *");
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
_pushJSDocBulletField(lines, "DTO", _formatCodeSpan(`${dtoName}.${rule.from}`));
|
|
34
34
|
if (rule.dtoDescription) {
|
|
35
|
-
|
|
35
|
+
_pushJSDocBulletField(lines, "DTO description", _escapeComment(rule.dtoDescription));
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
_pushJSDocBulletField(lines, "DTO type", _formatCodeSpan(dtoPathType ? checker.typeToString(dtoPathType) : "unknown"));
|
|
38
38
|
if (rule.db)
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
_pushJSDocBulletField(lines, "Origin", _formatCodeSpan(rule.db));
|
|
40
|
+
_pushJSDocBulletField(lines, "Domain type", _formatCodeSpan(checker.typeToString(domainType)));
|
|
41
41
|
lines.push(" */");
|
|
42
42
|
lines.push(` ${_propertyName(prop.name)}${optional}: ${checker.typeToString(domainType)};`);
|
|
43
43
|
lines.push("");
|
|
@@ -75,8 +75,8 @@ function _getDomainDescription(checker, prop) {
|
|
|
75
75
|
const description = typescript_1.default.displayPartsToString(prop.getDocumentationComment(checker)).trim();
|
|
76
76
|
return description || null;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
_pushJSDocText(lines,
|
|
78
|
+
function _pushJSDocBulletField(lines, label, value) {
|
|
79
|
+
_pushJSDocText(lines, `- ${label}: ${value}`, "", " ");
|
|
80
80
|
}
|
|
81
81
|
function _pushJSDocText(lines, text, firstIndent = "", continuationIndent = firstIndent) {
|
|
82
82
|
for (const line of _wrapJSDocText(text, firstIndent, continuationIndent)) {
|
|
@@ -101,3 +101,9 @@ function _wrapJSDocText(text, firstIndent, continuationIndent) {
|
|
|
101
101
|
lines.push(current.trimEnd());
|
|
102
102
|
return lines;
|
|
103
103
|
}
|
|
104
|
+
function _formatCodeSpan(value) {
|
|
105
|
+
return `\`${_escapeMarkdownCode(_escapeComment(value))}\``;
|
|
106
|
+
}
|
|
107
|
+
function _escapeMarkdownCode(value) {
|
|
108
|
+
return value.replace(/`/g, "\\`");
|
|
109
|
+
}
|
|
@@ -24,14 +24,14 @@ export function generateJSDocFromSpec(params) {
|
|
|
24
24
|
_pushJSDocText(lines, _escapeComment(description));
|
|
25
25
|
lines.push(" *");
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
_pushJSDocBulletField(lines, "DTO", _formatCodeSpan(`${dtoName}.${rule.from}`));
|
|
28
28
|
if (rule.dtoDescription) {
|
|
29
|
-
|
|
29
|
+
_pushJSDocBulletField(lines, "DTO description", _escapeComment(rule.dtoDescription));
|
|
30
30
|
}
|
|
31
|
-
|
|
31
|
+
_pushJSDocBulletField(lines, "DTO type", _formatCodeSpan(dtoPathType ? checker.typeToString(dtoPathType) : "unknown"));
|
|
32
32
|
if (rule.db)
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
_pushJSDocBulletField(lines, "Origin", _formatCodeSpan(rule.db));
|
|
34
|
+
_pushJSDocBulletField(lines, "Domain type", _formatCodeSpan(checker.typeToString(domainType)));
|
|
35
35
|
lines.push(" */");
|
|
36
36
|
lines.push(` ${_propertyName(prop.name)}${optional}: ${checker.typeToString(domainType)};`);
|
|
37
37
|
lines.push("");
|
|
@@ -69,8 +69,8 @@ function _getDomainDescription(checker, prop) {
|
|
|
69
69
|
const description = ts.displayPartsToString(prop.getDocumentationComment(checker)).trim();
|
|
70
70
|
return description || null;
|
|
71
71
|
}
|
|
72
|
-
function
|
|
73
|
-
_pushJSDocText(lines,
|
|
72
|
+
function _pushJSDocBulletField(lines, label, value) {
|
|
73
|
+
_pushJSDocText(lines, `- ${label}: ${value}`, "", " ");
|
|
74
74
|
}
|
|
75
75
|
function _pushJSDocText(lines, text, firstIndent = "", continuationIndent = firstIndent) {
|
|
76
76
|
for (const line of _wrapJSDocText(text, firstIndent, continuationIndent)) {
|
|
@@ -95,3 +95,9 @@ function _wrapJSDocText(text, firstIndent, continuationIndent) {
|
|
|
95
95
|
lines.push(current.trimEnd());
|
|
96
96
|
return lines;
|
|
97
97
|
}
|
|
98
|
+
function _formatCodeSpan(value) {
|
|
99
|
+
return `\`${_escapeMarkdownCode(_escapeComment(value))}\``;
|
|
100
|
+
}
|
|
101
|
+
function _escapeMarkdownCode(value) {
|
|
102
|
+
return value.replace(/`/g, "\\`");
|
|
103
|
+
}
|
package/docs/jsdoc-generation.md
CHANGED
|
@@ -66,8 +66,8 @@ Field meanings:
|
|
|
66
66
|
| Field | Meaning |
|
|
67
67
|
| --- | --- |
|
|
68
68
|
| Domain property JSDoc | Domain field description. Usually used as the first JSDoc sentence. |
|
|
69
|
-
| `dtoDescription` | Optional explanation shown
|
|
70
|
-
| `db` | Optional
|
|
69
|
+
| `dtoDescription` | Optional explanation shown as the `DTO description` bullet. |
|
|
70
|
+
| `db` | Optional origin field shown as the `Origin` bullet. |
|
|
71
71
|
|
|
72
72
|
For older mapper specs, `description` is still read as a fallback when the
|
|
73
73
|
domain property has no JSDoc. New code should prefer domain property JSDoc so
|
|
@@ -95,11 +95,11 @@ the generated documentation can look like this:
|
|
|
95
95
|
/**
|
|
96
96
|
* User id
|
|
97
97
|
*
|
|
98
|
-
* DTO: UserDto.user_id
|
|
99
|
-
*
|
|
100
|
-
* DTO type: string
|
|
101
|
-
*
|
|
102
|
-
* Domain type: string
|
|
98
|
+
* - DTO: `UserDto.user_id`
|
|
99
|
+
* - DTO description: Identifier returned by the user API.
|
|
100
|
+
* - DTO type: `string`
|
|
101
|
+
* - Origin: `users.user_id`
|
|
102
|
+
* - Domain type: `string`
|
|
103
103
|
*/
|
|
104
104
|
id: string;
|
|
105
105
|
```
|