@cparra/apexdocs 3.24.0-beta.3 → 3.24.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.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var errorCollector = require('../error-collector-D5Q2hGFS.js');
4
+ var errorCollector = require('../error-collector-DagrtuR3.js');
5
5
  var cosmiconfig = require('cosmiconfig');
6
6
  var yargs = require('yargs');
7
7
  var E = require('fp-ts/Either');
@@ -140,6 +140,7 @@ const defaultTranslations = {
140
140
  author: "Author",
141
141
  date: "Date",
142
142
  see: "See",
143
+ deprecated: "Deprecated",
143
144
  possibleValues: "Possible values are",
144
145
  parameters: "Parameters",
145
146
  throws: "Throws",
@@ -236,7 +237,28 @@ function defaultGetEmailByReference(email) {
236
237
  function replaceInlineReferences(text, linkReplacer, emailReplacer = defaultGetEmailByReference) {
237
238
  const inlineLinks = apply(replaceInlineLinks, linkReplacer);
238
239
  const inlineEmails = apply(replaceInlineEmails, emailReplacer);
239
- return _function.pipe(inlineCode$1([text]), inlineLinks, inlineEmails);
240
+ return _function.pipe(inlineCodeTags([text]), inlineLiteralTags, inlineCode$1, inlineLinks, inlineEmails);
241
+ }
242
+ function inlineCodeTags(renderableContents) {
243
+ return renderableContents.flatMap((renderableContent) => {
244
+ if (typeof renderableContent !== "string") {
245
+ return [renderableContent];
246
+ }
247
+ const matches = match("{@code (.*?)}", renderableContent);
248
+ return createRenderableContents(matches, renderableContent, (content) => ({
249
+ __type: "inline-code",
250
+ content: content.trim()
251
+ }));
252
+ });
253
+ }
254
+ function inlineLiteralTags(renderableContents) {
255
+ return renderableContents.flatMap((renderableContent) => {
256
+ if (typeof renderableContent !== "string") {
257
+ return [renderableContent];
258
+ }
259
+ const matches = match("{@literal (.*?)}", renderableContent);
260
+ return createRenderableContents(matches, renderableContent, (content) => content.trim());
261
+ });
240
262
  }
241
263
  function inlineCode$1(renderableContents) {
242
264
  return renderableContents.flatMap((renderableContent) => inlineCodeContent(renderableContent));
@@ -394,7 +416,7 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
394
416
  var _a, _b, _c;
395
417
  function extractCustomTags(type) {
396
418
  var _a2, _b2;
397
- const baseTags = ["description", "group", "author", "date", "see", "example", "throws", "exception"];
419
+ const baseTags = ["description", "group", "author", "date", "see", "example", "throws", "exception", "deprecated"];
398
420
  return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase())).map((currentAnnotation) => __spreadProps$p(__spreadValues$r({}, adaptDescribable(currentAnnotation.bodyLines, linkGenerator)), {
399
421
  name: currentAnnotation.name
400
422
  }))) != null ? _b2 : [];
@@ -405,10 +427,23 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
405
427
  (currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName
406
428
  )) == null ? void 0 : _b2.body;
407
429
  }
408
- function extractSeeAnnotations(type) {
430
+ function extractAnnotationBodies(type, annotationName) {
409
431
  var _a2, _b2;
410
- return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === "see").map((currentAnnotation) => currentAnnotation.body)) != null ? _b2 : [];
432
+ return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName).map((currentAnnotation) => currentAnnotation.body)) != null ? _b2 : [];
433
+ }
434
+ function extractDeprecated(type) {
435
+ var _a2;
436
+ const deprecatedAnnotation = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.find(
437
+ (currentAnnotation) => currentAnnotation.name.toLowerCase() === "deprecated"
438
+ );
439
+ if (!deprecatedAnnotation) {
440
+ return void 0;
441
+ }
442
+ return {
443
+ description: describableToRenderableContent(deprecatedAnnotation.bodyLines, linkGenerator)
444
+ };
411
445
  }
446
+ const authors = extractAnnotationBodies(documentable, "author");
412
447
  return __spreadProps$p(__spreadValues$r({}, adaptDescribable((_a = documentable.docComment) == null ? void 0 : _a.descriptionLines, linkGenerator)), {
413
448
  annotations: documentable.annotations.map((annotation) => annotation.type.toUpperCase()),
414
449
  customTags: extractCustomTags(documentable),
@@ -418,9 +453,11 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
418
453
  value: describableToRenderableContent((_c = (_b = documentable.docComment) == null ? void 0 : _b.exampleAnnotation) == null ? void 0 : _c.bodyLines, linkGenerator)
419
454
  },
420
455
  group: extractAnnotationBody(documentable, "group"),
421
- author: extractAnnotationBody(documentable, "author"),
456
+ author: authors[0],
457
+ authors,
422
458
  date: extractAnnotationBody(documentable, "date"),
423
- sees: extractSeeAnnotations(documentable).map(linkGenerator)
459
+ sees: extractAnnotationBodies(documentable, "see").map(linkGenerator),
460
+ deprecated: extractDeprecated(documentable)
424
461
  });
425
462
  }
426
463
 
@@ -789,6 +826,10 @@ function classTypeToClassSource(classType, linkGenerator, baseHeadingLevel = 1,
789
826
  }
790
827
  });
791
828
  }
829
+ function getGroupName(member) {
830
+ var _a, _b, _c;
831
+ return (_c = member.group) != null ? _c : (_b = (_a = member.docComment) == null ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === "group")) == null ? void 0 : _b.body;
832
+ }
792
833
  function adaptMembers(heading, members, adapter, linkFromTypeNameGenerator, headingLevel, translations) {
793
834
  return {
794
835
  headingLevel,
@@ -798,7 +839,7 @@ function adaptMembers(heading, members, adapter, linkFromTypeNameGenerator, head
798
839
  };
799
840
  }
800
841
  function hasGroup(members) {
801
- return members.some((member) => member.group);
842
+ return members.some((member) => getGroupName(member));
802
843
  }
803
844
  function toFlat(members, adapter, linkGenerator, baseHeadingLevel, translations) {
804
845
  return members.map((member) => adapter(member, linkGenerator, baseHeadingLevel, translations));
@@ -813,7 +854,7 @@ function groupByGroupName(members) {
813
854
  return members.reduce(
814
855
  (acc, member) => {
815
856
  var _a, _b;
816
- const groupName = (_a = member.group) != null ? _a : "Other";
857
+ const groupName = (_a = getGroupName(member)) != null ? _a : "Other";
817
858
  acc[groupName] = (_b = acc[groupName]) != null ? _b : [];
818
859
  acc[groupName].push(member);
819
860
  return acc;
@@ -1002,6 +1043,10 @@ function renderInlineHelpText(inlineHelpText, config) {
1002
1043
  }
1003
1044
 
1004
1045
  const generateLink = (strategy) => {
1046
+ const resolveTypeName = getStrategyFn(strategy);
1047
+ return (references, from, referenceName) => resolveReference(resolveTypeName, references, from, referenceName);
1048
+ };
1049
+ const getStrategyFn = (strategy) => {
1005
1050
  switch (strategy) {
1006
1051
  case "relative":
1007
1052
  return generateRelativeLink;
@@ -1011,6 +1056,43 @@ const generateLink = (strategy) => {
1011
1056
  return returnReferenceAsIs;
1012
1057
  }
1013
1058
  };
1059
+ function resolveReference(resolveTypeName, references, from, referenceName) {
1060
+ const reference = referenceName.trim();
1061
+ const quotedText = reference.match(/^"([\s\S]*)"$/);
1062
+ if (quotedText) {
1063
+ return quotedText[1];
1064
+ }
1065
+ const htmlAnchor = reference.match(/^<a\s+href="([^"]*)"[^>]*>([\s\S]*?)<\/a>$/i);
1066
+ if (htmlAnchor) {
1067
+ return {
1068
+ __type: "link",
1069
+ title: htmlAnchor[2].trim(),
1070
+ url: htmlAnchor[1]
1071
+ };
1072
+ }
1073
+ const memberReference = reference.match(/^([\w.]*)#([\w.]+(?:\([^)]*\))?)$/);
1074
+ if (memberReference) {
1075
+ const [, typeName, member] = memberReference;
1076
+ const anchor = member.toLowerCase().replace(/[^a-z0-9_-]/g, "");
1077
+ if (!typeName) {
1078
+ return {
1079
+ __type: "link",
1080
+ title: member,
1081
+ url: `#${anchor}`
1082
+ };
1083
+ }
1084
+ const resolvedType = resolveTypeName(references, from, typeName);
1085
+ if (typeof resolvedType === "string") {
1086
+ return reference;
1087
+ }
1088
+ return {
1089
+ __type: "link",
1090
+ title: `${resolvedType.title}.${member}`,
1091
+ url: `${resolvedType.url}#${anchor}`
1092
+ };
1093
+ }
1094
+ return resolveTypeName(references, from, reference);
1095
+ }
1014
1096
  const generateRelativeLink = (references, from, referenceName) => {
1015
1097
  function getRelativePath(fromPath, toPath) {
1016
1098
  return path.relative(path.parse(path.join("/", fromPath)).dir, path.join("/", toPath));
@@ -1775,10 +1857,21 @@ const typeDocPartial = `
1775
1857
  **{{@root.translations.markdown.details.group}}** {{doc.group}}
1776
1858
  {{/if}}
1777
1859
 
1778
- {{#if doc.author}}
1779
- **{{@root.translations.markdown.details.author}}** {{doc.author}}
1860
+ {{> docDetailsPartial}}
1861
+
1862
+ {{#if namespace}}
1863
+ ## {{@root.translations.markdown.sections.namespace}}
1864
+ {{namespace}}
1780
1865
  {{/if}}
1781
1866
 
1867
+ {{/documentablePartialTemplate}}
1868
+ `.trim();
1869
+
1870
+ const docDetailsPartial = `
1871
+ {{#each doc.authors}}
1872
+ **{{@root.translations.markdown.details.author}}** {{this}}
1873
+
1874
+ {{/each}}
1782
1875
  {{#if doc.date}}
1783
1876
  **{{@root.translations.markdown.details.date}}** {{doc.date}}
1784
1877
  {{/if}}
@@ -1787,13 +1880,6 @@ const typeDocPartial = `
1787
1880
  **{{@root.translations.markdown.details.see}}** {{link this}}
1788
1881
 
1789
1882
  {{/each}}
1790
-
1791
- {{#if namespace}}
1792
- ## {{@root.translations.markdown.sections.namespace}}
1793
- {{namespace}}
1794
- {{/if}}
1795
-
1796
- {{/documentablePartialTemplate}}
1797
1883
  `.trim();
1798
1884
 
1799
1885
  const documentablePartialTemplate = `
@@ -1801,6 +1887,10 @@ const documentablePartialTemplate = `
1801
1887
  \`{{this}}\`
1802
1888
  {{/each}}
1803
1889
 
1890
+ {{#if doc.deprecated}}
1891
+ > **{{@root.translations.markdown.details.deprecated}}** {{{renderContent doc.deprecated.description}}}
1892
+ {{/if}}
1893
+
1804
1894
  {{{renderContent doc.description}}}
1805
1895
 
1806
1896
  {{#each doc.customTags}}
@@ -1850,16 +1940,18 @@ const methodsPartialTemplate = `
1850
1940
  **{{link returnType.value.type}}**
1851
1941
 
1852
1942
  {{#if returnType.value.description}}
1853
- {{returnType.value.description}}
1943
+ {{{renderContent returnType.value.description}}}
1854
1944
  {{/if}}
1855
1945
 
1856
1946
  {{#if throws.value}}
1857
1947
  {{ heading throws.headingLevel throws.heading }}
1858
1948
  {{#each throws.value}}
1859
- {{link this.type}}: {{this.description}}
1949
+ {{link this.type}}: {{{renderContent this.description}}}
1860
1950
 
1861
1951
  {{/each}}
1862
1952
  {{/if}}
1953
+
1954
+ {{> docDetailsPartial}}
1863
1955
  {{/documentablePartialTemplate}}
1864
1956
 
1865
1957
  {{#unless @last}}---{{/unless}}
@@ -1889,17 +1981,19 @@ const constructorsPartialTemplate = `
1889
1981
  | Name | Type | Description |
1890
1982
  |------|------|-------------|
1891
1983
  {{#each parameters.value}}
1892
- | {{name}} | {{link type}} | {{description}} |
1984
+ | {{name}} | {{link type}} | {{{renderContent description}}} |
1893
1985
  {{/each}}
1894
1986
  {{/if}}
1895
1987
 
1896
1988
  {{#if throws.value}}
1897
1989
  {{ heading throws.headingLevel throws.heading }}
1898
1990
  {{#each throws.value}}
1899
- {{link this.type}}: {{this.description}}
1991
+ {{link this.type}}: {{{renderContent this.description}}}
1900
1992
 
1901
1993
  {{/each}}
1902
1994
  {{/if}}
1995
+
1996
+ {{> docDetailsPartial}}
1903
1997
  {{/documentablePartialTemplate}}
1904
1998
 
1905
1999
  {{#unless @last}}---{{/unless}}
@@ -1924,6 +2018,7 @@ const fieldsPartialTemplate = `
1924
2018
  {{ heading type.headingLevel type.heading }}
1925
2019
  {{link type.value}}
1926
2020
 
2021
+ {{> docDetailsPartial}}
1927
2022
  {{/documentablePartialTemplate}}
1928
2023
 
1929
2024
  {{#unless @last}}---{{/unless}}
@@ -2136,6 +2231,7 @@ const templateHelpers = {
2136
2231
  class Template {
2137
2232
  constructor() {
2138
2233
  Handlebars.registerPartial("typeDocumentation", typeDocPartial);
2234
+ Handlebars.registerPartial("docDetailsPartial", docDetailsPartial);
2139
2235
  Handlebars.registerPartial("documentablePartialTemplate", documentablePartialTemplate);
2140
2236
  Handlebars.registerPartial("methodsPartialTemplate", methodsPartialTemplate);
2141
2237
  Handlebars.registerPartial("constructorsPartialTemplate", constructorsPartialTemplate);
@@ -2622,11 +2718,9 @@ class Manifest {
2622
2718
  return accessAndDocAware.filter((type) => this.shouldFilterType(type, modifiers));
2623
2719
  }
2624
2720
  static shouldFilterType(accessAndDocAware, modifiers) {
2625
- var _a;
2626
- const hasIgnoreDocAnnotation = (_a = accessAndDocAware.docComment) == null ? void 0 : _a.annotations.some(
2627
- (annotation) => annotation.name.toLowerCase() === "ignore"
2628
- );
2629
- if (hasIgnoreDocAnnotation) {
2721
+ const docComment = accessAndDocAware.docComment;
2722
+ const isExcluded = (docComment == null ? void 0 : docComment.hidden) === true || (docComment == null ? void 0 : docComment.annotations.some((annotation) => annotation.name.toLowerCase() === "ignore"));
2723
+ if (isExcluded) {
2630
2724
  return false;
2631
2725
  }
2632
2726
  return modifiers.includes(accessAndDocAware.access_modifier) || accessAndDocAware.annotations.some((annotation) => modifiers.includes(annotation.type.toLowerCase()));
package/dist/index.d.ts CHANGED
@@ -87,6 +87,7 @@ type Translations = {
87
87
  author: string;
88
88
  date: string;
89
89
  see: string;
90
+ deprecated: string;
90
91
  possibleValues: string;
91
92
  parameters: string;
92
93
  throws: string;
@@ -198,9 +199,12 @@ type RenderableDocumentation = {
198
199
  customTags?: CustomTag[];
199
200
  example?: RenderableSection<RenderableContent[] | undefined>;
200
201
  group?: string;
202
+ /** The first author. Kept for backwards compatibility with custom templates; prefer `authors`. */
201
203
  author?: string;
204
+ authors?: string[];
202
205
  date?: string;
203
206
  sees?: StringOrLink[];
207
+ deprecated?: { description?: RenderableContent[] };
204
208
  };
205
209
 
206
210
  type RenderableType = {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  'use strict';
3
3
 
4
- var errorCollector = require('./error-collector-D5Q2hGFS.js');
4
+ var errorCollector = require('./error-collector-DagrtuR3.js');
5
5
  var E = require('fp-ts/Either');
6
6
  require('fp-ts/function');
7
7
  require('fp-ts/TaskEither');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cparra/apexdocs",
3
- "version": "3.24.0-beta.3",
3
+ "version": "3.24.0",
4
4
  "description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
5
5
  "engines": {
6
6
  "node": ">=22.12.0"
@@ -96,7 +96,7 @@
96
96
  ]
97
97
  },
98
98
  "dependencies": {
99
- "@cparra/apex-reflection": "4.0.0-beta.3",
99
+ "@cparra/apex-reflection": "4.0.0",
100
100
  "@salesforce/source-deploy-retrieve": "^12.20.1",
101
101
  "@types/js-yaml": "^4.0.9",
102
102
  "@types/yargs": "^17.0.32",