@travetto/transformer 8.0.0-alpha.10 → 8.0.0-alpha.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/transformer",
3
- "version": "8.0.0-alpha.10",
3
+ "version": "8.0.0-alpha.12",
4
4
  "type": "module",
5
5
  "description": "Functionality for AST transformations, with transformer registration, and general utils",
6
6
  "keywords": [
@@ -25,7 +25,7 @@
25
25
  "directory": "module/transformer"
26
26
  },
27
27
  "dependencies": {
28
- "@travetto/manifest": "^8.0.0-alpha.7",
28
+ "@travetto/manifest": "^8.0.0-alpha.9",
29
29
  "tslib": "^2.8.1",
30
30
  "typescript": "^6.0.3"
31
31
  },
@@ -148,7 +148,7 @@ export class SimpleResolver implements TransformResolver {
148
148
  result.templateTypeName = context?.templateTypeName;
149
149
 
150
150
  try {
151
- result.comment = DocUtil.describeDocs(type).description;
151
+ result.description = DocUtil.describeDocs(type).description;
152
152
  } catch { }
153
153
 
154
154
  if ('tsTypeArguments' in result) {
@@ -18,7 +18,11 @@ export interface Type<K extends string> {
18
18
  /**
19
19
  * JS Doc comment
20
20
  */
21
- comment?: string;
21
+ description?: string;
22
+ /**
23
+ * JS Doc examples
24
+ */
25
+ examples?: string[];
22
26
  /**
23
27
  * Can be undefined
24
28
  */
@@ -14,6 +14,7 @@ export interface ParamDocumentation {
14
14
  export interface DeclDocumentation {
15
15
  return?: string;
16
16
  description?: string;
17
+ examples?: string[];
17
18
  params?: ParamDocumentation[];
18
19
  }
19
20
 
package/src/util/doc.ts CHANGED
@@ -32,15 +32,17 @@ export class DocUtil {
32
32
  const out: DeclDocumentation = {
33
33
  description: undefined,
34
34
  return: undefined,
35
+ examples: undefined,
35
36
  params: []
36
37
  };
37
38
 
38
39
  if (toDescribe) {
39
- const tags = ts.getJSDocTags(toDescribe);
40
40
  while (!this.hasJSDoc(toDescribe) && CoreUtil.hasOriginal(toDescribe)) {
41
41
  toDescribe = transformCast<ts.Declaration>(toDescribe.original);
42
42
  }
43
43
 
44
+ const tags = ts.getJSDocTags(toDescribe);
45
+
44
46
  const docs = this.hasJSDoc(toDescribe) ? toDescribe.jsDoc : undefined;
45
47
 
46
48
  if (docs) {
@@ -59,6 +61,8 @@ export class DocUtil {
59
61
  name: tag.name && tag.name.getText(),
60
62
  description: this.getDocComment(tag, '')!
61
63
  });
64
+ } else if (tag.tagName.getText() === 'example') {
65
+ (out.examples ??= []).push(this.getDocComment(tag, '')!);
62
66
  }
63
67
  }
64
68
  }