@skyux/docs-tools 9.0.0-alpha.0 → 9.0.0-alpha.2

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.
@@ -1479,9 +1479,7 @@ class SkyDocsTypeDefinitionsFormatService {
1479
1479
  escapeSpecialCharacters(value) {
1480
1480
  return value.replace(/</g, '&lt;').replace(/>/g, '&gt;');
1481
1481
  }
1482
- getFormattedCallSignature(callSignature, config = {
1483
- escapeSpecialCharacters: true,
1484
- }) {
1482
+ getFormattedCallSignature(callSignature, config) {
1485
1483
  const returnType = this.getFormattedType(callSignature.returnType, config);
1486
1484
  if (!callSignature.parameters) {
1487
1485
  return `() => ${returnType}`;
@@ -2197,6 +2195,40 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.8", ngImpor
2197
2195
  }]
2198
2196
  }], ctorParameters: function () { return [{ type: i1$4.Title }]; } });
2199
2197
 
2198
+ /**
2199
+ * This enum comes from:
2200
+ * https://github.com/TypeStrong/typedoc/blob/v0.24.8/src/lib/models/reflections/kind.ts
2201
+ * The enum is up to date as of version `0.24.8`.
2202
+ */
2203
+ var TypeDocKind;
2204
+ (function (TypeDocKind) {
2205
+ TypeDocKind[TypeDocKind["Project"] = 1] = "Project";
2206
+ TypeDocKind[TypeDocKind["Module"] = 2] = "Module";
2207
+ TypeDocKind[TypeDocKind["Namespace"] = 4] = "Namespace";
2208
+ TypeDocKind[TypeDocKind["Enum"] = 8] = "Enum";
2209
+ TypeDocKind[TypeDocKind["EnumMember"] = 16] = "EnumMember";
2210
+ TypeDocKind[TypeDocKind["Variable"] = 32] = "Variable";
2211
+ TypeDocKind[TypeDocKind["Function"] = 64] = "Function";
2212
+ TypeDocKind[TypeDocKind["Class"] = 128] = "Class";
2213
+ TypeDocKind[TypeDocKind["Interface"] = 256] = "Interface";
2214
+ TypeDocKind[TypeDocKind["Constructor"] = 512] = "Constructor";
2215
+ TypeDocKind[TypeDocKind["Property"] = 1024] = "Property";
2216
+ TypeDocKind[TypeDocKind["Method"] = 2048] = "Method";
2217
+ TypeDocKind[TypeDocKind["CallSignature"] = 4096] = "CallSignature";
2218
+ TypeDocKind[TypeDocKind["IndexSignature"] = 8192] = "IndexSignature";
2219
+ TypeDocKind[TypeDocKind["ConstructorSignature"] = 16384] = "ConstructorSignature";
2220
+ TypeDocKind[TypeDocKind["Parameter"] = 32768] = "Parameter";
2221
+ TypeDocKind[TypeDocKind["TypeLiteral"] = 65536] = "TypeLiteral";
2222
+ TypeDocKind[TypeDocKind["TypeParameter"] = 131072] = "TypeParameter";
2223
+ TypeDocKind[TypeDocKind["Accessor"] = 262144] = "Accessor";
2224
+ TypeDocKind[TypeDocKind["GetSignature"] = 524288] = "GetSignature";
2225
+ TypeDocKind[TypeDocKind["SetSignature"] = 1048576] = "SetSignature";
2226
+ /** @deprecated will be removed in v0.25, not used */
2227
+ TypeDocKind[TypeDocKind["ObjectLiteral"] = 2097152] = "ObjectLiteral";
2228
+ TypeDocKind[TypeDocKind["TypeAlias"] = 4194304] = "TypeAlias";
2229
+ TypeDocKind[TypeDocKind["Reference"] = 8388608] = "Reference";
2230
+ })(TypeDocKind || (TypeDocKind = {}));
2231
+
2200
2232
  /**
2201
2233
  * Converts TypeDoc types into SKY UX docs-tools types, to be supplied to the various definitions components.
2202
2234
  */
@@ -2311,7 +2343,15 @@ class SkyDocsTypeDocAdapterService {
2311
2343
  return [];
2312
2344
  }
2313
2345
  const definitions = entry.children
2314
- .filter((child) => child.kindString === 'Property' || child.kindString === 'Accessor')
2346
+ .filter((child) =>
2347
+ // We only want properties (both with or without a getter/setter)
2348
+ child.kind === TypeDocKind.Property ||
2349
+ child.kind === TypeDocKind.Accessor)
2350
+ .filter((child) =>
2351
+ // We only want accessors that don't have a setter if they are not inputs
2352
+ child.kind !== TypeDocKind.Accessor ||
2353
+ child.setSignature ||
2354
+ this.getDecorator(child)?.name !== 'Input')
2315
2355
  .map((child) => {
2316
2356
  let definition = {
2317
2357
  isOptional: true,
@@ -2320,19 +2360,22 @@ class SkyDocsTypeDocAdapterService {
2320
2360
  };
2321
2361
  let defaultValue;
2322
2362
  /* Ensure we are properly capturing definitions which use a getter/setter. Final check is a sanity check */
2323
- if (child.kindString === 'Accessor' &&
2324
- !child.comment?.shortText &&
2325
- (child.setSignature?.length > 0 || child.getSignature.length > 0)) {
2363
+ if (child.kind === TypeDocKind.Accessor &&
2364
+ !child.comment?.summary
2365
+ ?.map((item) => item.text)
2366
+ .join('')
2367
+ .trim() &&
2368
+ (child.setSignature || child.getSignature)) {
2326
2369
  const mainTags = this.getCommentTags(child.comment);
2327
2370
  this.applyCommentTagValues(definition, mainTags);
2328
- if (child.getSignature?.length > 0) {
2329
- const getTags = this.getCommentTags(child.getSignature[0].comment);
2371
+ if (child.getSignature) {
2372
+ const getTags = this.getCommentTags(child.getSignature.comment);
2330
2373
  definition.isOptional = !getTags.extras.required;
2331
2374
  this.applyCommentTagValues(definition, getTags);
2332
2375
  defaultValue = this.getDefaultValue(child, getTags);
2333
2376
  }
2334
- if (child.setSignature?.length > 0) {
2335
- const setTags = this.getCommentTags(child.setSignature[0].comment);
2377
+ if (child.setSignature) {
2378
+ const setTags = this.getCommentTags(child.setSignature.comment);
2336
2379
  this.applyCommentTagValues(definition, setTags);
2337
2380
  definition.isOptional =
2338
2381
  definition.isOptional && !setTags.extras.required;
@@ -2345,8 +2388,11 @@ class SkyDocsTypeDocAdapterService {
2345
2388
  }
2346
2389
  else {
2347
2390
  let tags;
2348
- if (child.kindString === 'Property' &&
2349
- !child.comment?.shortText &&
2391
+ if (child.kind === TypeDocKind.Property &&
2392
+ !child.comment?.summary
2393
+ ?.map((item) => item.text)
2394
+ .join('')
2395
+ .trim() &&
2350
2396
  child.type.declaration?.signatures?.length > 0 &&
2351
2397
  child.type.declaration.signatures[0].comment) {
2352
2398
  tags = this.getCommentTags(child.type.declaration.signatures[0].comment);
@@ -2367,9 +2413,9 @@ class SkyDocsTypeDocAdapterService {
2367
2413
  definition.decorator = decorator;
2368
2414
  }
2369
2415
  if (!definition.description) {
2370
- const constructor = entry.children.find((child) => child.kindString === 'Constructor');
2416
+ const constructor = entry.children.find((child) => child.kind === TypeDocKind.Constructor);
2371
2417
  if (constructor) {
2372
- const signature = constructor.signatures.find((signature) => signature.kindString === 'Constructor signature');
2418
+ const signature = constructor.signatures.find((signature) => signature.kind === TypeDocKind.ConstructorSignature);
2373
2419
  /* Sanity check */
2374
2420
  /* istanbul ignore else */
2375
2421
  if (signature) {
@@ -2390,7 +2436,7 @@ class SkyDocsTypeDocAdapterService {
2390
2436
  return [];
2391
2437
  }
2392
2438
  const methods = entry.children
2393
- .filter((child) => child.kindString === 'Method' && /^ng/.test(child.name) === false)
2439
+ .filter((child) => child.kind === TypeDocKind.Method && /^ng/.test(child.name) === false)
2394
2440
  .map((child) => {
2395
2441
  const definition = {
2396
2442
  name: this.getPropertyName(child),
@@ -2416,9 +2462,13 @@ class SkyDocsTypeDocAdapterService {
2416
2462
  }
2417
2463
  const definitions = entry.children?.map((child) => {
2418
2464
  let tags;
2419
- if (child.kindString === 'Method' && child.signatures.length > 0) {
2465
+ if (child.kind === TypeDocKind.Method && child.signatures.length > 0) {
2420
2466
  tags = this.getCommentTags(child.signatures[0].comment);
2421
2467
  }
2468
+ else if (child.type.type === 'reflection' &&
2469
+ child.type?.declaration?.signatures?.length > 0) {
2470
+ tags = this.getCommentTags(child.type.declaration.signatures[0].comment);
2471
+ }
2422
2472
  else {
2423
2473
  tags = this.getCommentTags(child.comment);
2424
2474
  }
@@ -2462,14 +2512,14 @@ class SkyDocsTypeDocAdapterService {
2462
2512
  }
2463
2513
  getTypeDefinition(child) {
2464
2514
  let definition;
2465
- const kindString = child.kindString;
2466
- switch (kindString) {
2467
- case 'Accessor':
2515
+ const kind = child.kind;
2516
+ switch (kind) {
2517
+ case TypeDocKind.Accessor:
2468
2518
  if (child.setSignature) {
2469
- return this.getTypeDefinition(child.setSignature[0].parameters[0]);
2519
+ return this.getTypeDefinition(child.setSignature.parameters[0]);
2470
2520
  }
2471
- return this.getTypeDefinition(child.getSignature[0]);
2472
- case 'Method':
2521
+ return this.getTypeDefinition(child.getSignature);
2522
+ case TypeDocKind.Method:
2473
2523
  definition = {
2474
2524
  callSignature: this.getCallSignatureDefinition(child.signatures[0], this.getCommentTags(child.comment)),
2475
2525
  name: child.signatures[0].name,
@@ -2599,38 +2649,58 @@ class SkyDocsTypeDocAdapterService {
2599
2649
  let parameters;
2600
2650
  const extras = {};
2601
2651
  if (comment) {
2602
- if (comment.tags) {
2603
- comment.tags.forEach((tag) => {
2652
+ if (comment.blockTags) {
2653
+ comment.blockTags.forEach((tag) => {
2604
2654
  switch (tag.tag) {
2605
- case 'deprecated':
2606
- deprecationWarning = tag.text.trim();
2655
+ case '@deprecated':
2656
+ deprecationWarning = tag.content
2657
+ .map((item) => item.text)
2658
+ .join('')
2659
+ .trim();
2607
2660
  break;
2608
- case 'default':
2609
- case 'defaultValue':
2610
- defaultValue = tag.text.trim();
2661
+ case '@default':
2662
+ case '@defaultValue':
2663
+ defaultValue = tag.content
2664
+ .map((item) => item.text)
2665
+ .join('')
2666
+ .trim();
2611
2667
  break;
2612
- case 'example':
2613
- codeExample = tag.text.trim().split('```')[1].trim();
2668
+ case '@example':
2669
+ codeExample = tag.content
2670
+ .map((item) => item.text)
2671
+ .join('')
2672
+ .trim()
2673
+ .split('```')[1]
2674
+ .trim();
2614
2675
  const language = codeExample.split('\n')[0];
2615
2676
  if (language === 'markup' || language === 'typescript') {
2616
2677
  codeExample = codeExample.slice(language.length).trim();
2617
2678
  codeExampleLanguage = language;
2618
2679
  }
2619
2680
  break;
2620
- case 'param':
2681
+ case '@param':
2621
2682
  parameters = parameters || [];
2622
2683
  parameters.push({
2623
2684
  name: tag.param,
2624
- description: tag.text.trim(),
2685
+ description: tag.content
2686
+ .map((item) => item.text)
2687
+ .join('')
2688
+ .trim(),
2625
2689
  });
2626
2690
  break;
2691
+ case '@required':
2692
+ extras['required'] = true;
2693
+ break;
2694
+ /* istanbul ignore next */
2627
2695
  default:
2628
- extras[tag.tag] = tag.text;
2629
2696
  break;
2630
2697
  }
2631
2698
  });
2632
2699
  }
2633
- description = (comment.shortText || comment.text || '').trim();
2700
+ description = comment.summary
2701
+ ?.map((item) => item.text)
2702
+ .join('')
2703
+ .trim();
2634
2704
  }
2635
2705
  return {
2636
2706
  codeExample,
@@ -2769,8 +2839,8 @@ class SkyDocsTypeDefinitionsService {
2769
2839
  console.warn(`Type definitions were not found for location: ${requestedDir}`);
2770
2840
  }
2771
2841
  typeDefinitions.forEach((item) => {
2772
- const decorator = item.decorators && item.decorators[0].name;
2773
- const kindString = item.kindString;
2842
+ const decorator = item.decorators && item.decorators[0]?.name;
2843
+ const kind = item.kind;
2774
2844
  switch (decorator) {
2775
2845
  case 'Component':
2776
2846
  types.components.push(this.adapter.toDirectiveDefinition(item));
@@ -2789,17 +2859,17 @@ class SkyDocsTypeDefinitionsService {
2789
2859
  break;
2790
2860
  default:
2791
2861
  /*tslint:disable-next-line:switch-default*/
2792
- switch (kindString) {
2793
- case 'Class':
2862
+ switch (kind) {
2863
+ case TypeDocKind.Class:
2794
2864
  types.classes.push(this.adapter.toClassDefinition(item));
2795
2865
  break;
2796
- case 'Interface':
2866
+ case TypeDocKind.Interface:
2797
2867
  types.interfaces.push(this.adapter.toInterfaceDefinition(item));
2798
2868
  break;
2799
- case 'Enumeration':
2869
+ case TypeDocKind.Enum:
2800
2870
  types.enumerations.push(this.adapter.toEnumerationDefinition(item));
2801
2871
  break;
2802
- case 'Type alias':
2872
+ case TypeDocKind.TypeAlias:
2803
2873
  types.typeAliases.push(this.adapter.toTypeAliasDefinition(item));
2804
2874
  break;
2805
2875
  }