@cparra/apexdocs 2.25.0-alpha.6 → 2.25.0-alpha.9

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.
Files changed (53) hide show
  1. package/dist/cli/generate.js +192 -225
  2. package/dist/index.d.ts +51 -13
  3. package/examples/plain-markdown/docs/index.md +25 -33
  4. package/examples/plain-markdown/docs/{Miscellaneous/ns.BaseClass.md → miscellaneous/BaseClass.md} +1 -1
  5. package/examples/plain-markdown/docs/{Miscellaneous/ns.MultiInheritanceClass.md → miscellaneous/MultiInheritanceClass.md} +5 -6
  6. package/examples/plain-markdown/docs/{Miscellaneous/ns.SampleException.md → miscellaneous/SampleException.md} +3 -4
  7. package/examples/plain-markdown/docs/{Miscellaneous/ns.SampleInterface.md → miscellaneous/SampleInterface.md} +22 -29
  8. package/examples/plain-markdown/docs/{Miscellaneous/ns.Url.md → miscellaneous/Url.md} +32 -43
  9. package/examples/plain-markdown/docs/sample-enums/SampleEnum.md +36 -0
  10. package/examples/plain-markdown/docs/{SampleGroup/ns.SampleClass.md → samplegroup/SampleClass.md} +8 -11
  11. package/examples/vitepress/apexdocs.config.ts +1 -3
  12. package/examples/vitepress/docs/.vitepress/sidebar.json +18 -18
  13. package/examples/vitepress/docs/index.md +11 -82
  14. package/examples/vitepress/docs/{Miscellaneous/apexdocs.BaseClass.md → miscellaneous/BaseClass.md} +1 -1
  15. package/examples/vitepress/docs/{Miscellaneous/apexdocs.MultiInheritanceClass.md → miscellaneous/MultiInheritanceClass.md} +4 -6
  16. package/examples/vitepress/docs/{Miscellaneous/apexdocs.SampleException.md → miscellaneous/SampleException.md} +1 -1
  17. package/examples/vitepress/docs/{Miscellaneous/apexdocs.SampleInterface.md → miscellaneous/SampleInterface.md} +22 -28
  18. package/examples/vitepress/docs/{Miscellaneous/apexdocs.Url.md → miscellaneous/Url.md} +31 -32
  19. package/examples/vitepress/docs/sample-enums/SampleEnum.md +40 -0
  20. package/examples/vitepress/docs/{SampleGroup/apexdocs.SampleClass.md → samplegroup/SampleClass.md} +6 -10
  21. package/examples/vitepress/force-app/main/default/classes/Url.cls +7 -4
  22. package/package.json +1 -1
  23. package/src/application/apex-file-reader.ts +3 -3
  24. package/src/application/file-writer.ts +5 -9
  25. package/src/application/generators/markdown.ts +9 -4
  26. package/src/application/generators/openapi.ts +4 -4
  27. package/src/core/markdown/__test__/generating-class-docs.spec.ts +11 -3
  28. package/src/core/markdown/__test__/generating-enum-docs.spec.ts +7 -3
  29. package/src/core/markdown/__test__/generating-interface-docs.spec.ts +11 -3
  30. package/src/core/markdown/__test__/generating-reference-guide.spec.ts +3 -7
  31. package/src/core/markdown/__test__/test-helpers.ts +3 -3
  32. package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +40 -5
  33. package/src/core/markdown/adapters/apex-types.ts +3 -2
  34. package/src/core/markdown/adapters/documentables.ts +49 -68
  35. package/src/core/markdown/adapters/reference-guide.ts +35 -0
  36. package/src/core/markdown/adapters/renderable-bundle.ts +43 -119
  37. package/src/core/markdown/adapters/renderable-to-page-data.ts +12 -15
  38. package/src/core/markdown/adapters/types.d.ts +5 -8
  39. package/src/core/markdown/generate-docs.ts +99 -42
  40. package/src/core/markdown/reflection/inheritance-chain-expanion.ts +1 -1
  41. package/src/core/markdown/reflection/reflect-source.ts +8 -4
  42. package/src/core/markdown/templates/documentable-partial-template.ts +1 -1
  43. package/src/core/openapi/manifest-factory.ts +2 -2
  44. package/src/core/openapi/openapi-type-file.ts +1 -3
  45. package/src/core/openapi/parser.ts +4 -4
  46. package/src/core/shared/types.d.ts +52 -14
  47. package/src/index.ts +2 -1
  48. package/examples/plain-markdown/docs/Sample-Enums/ns.SampleEnum.md +0 -38
  49. package/examples/vitepress/docs/Sample-Enums/apexdocs.SampleEnum.md +0 -41
  50. /package/examples/plain-markdown/docs/{Miscellaneous/ns.ParentInterface.md → miscellaneous/ParentInterface.md} +0 -0
  51. /package/examples/plain-markdown/docs/{Miscellaneous/ns.ReferencedEnum.md → miscellaneous/ReferencedEnum.md} +0 -0
  52. /package/examples/vitepress/docs/{Miscellaneous/apexdocs.ParentInterface.md → miscellaneous/ParentInterface.md} +0 -0
  53. /package/examples/vitepress/docs/{Miscellaneous/apexdocs.ReferencedEnum.md → miscellaneous/ReferencedEnum.md} +0 -0
@@ -9,6 +9,7 @@ var apexReflection = require('@cparra/apex-reflection');
9
9
  var O = require('fp-ts/Option');
10
10
  var fastXmlParser = require('fast-xml-parser');
11
11
  var Handlebars = require('handlebars');
12
+ var defaults = require('../defaults-DUwru49Q.js');
12
13
  var fs = require('fs');
13
14
  var path = require('path');
14
15
  var chalk = require('chalk');
@@ -16,7 +17,6 @@ var logUpdate = require('log-update');
16
17
  var cosmiconfig = require('cosmiconfig');
17
18
  var yargs = require('yargs');
18
19
  var cosmiconfigTypescriptLoader = require('cosmiconfig-typescript-loader');
19
- var defaults = require('../defaults-DUwru49Q.js');
20
20
 
21
21
  function _interopNamespaceDefault(e) {
22
22
  var n = Object.create(null);
@@ -166,66 +166,60 @@ var __spreadValues$f = (a, b) => {
166
166
  };
167
167
  var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
168
168
  function adaptDescribable(describable, linkGenerator) {
169
- function describableToRenderableContent(describable2) {
170
- if (!describable2) {
171
- return;
172
- }
173
- let content = [];
174
- for (let i = 0; i < describable2.length; i++) {
175
- const line = describable2[i];
176
- const codeBlockMatch = line.match(/^```([a-zA-Z]*)$/);
177
- if (codeBlockMatch) {
178
- const language = codeBlockMatch[1] || "apex";
179
- const codeBlockLines = [];
180
- i++;
181
- while (i < describable2.length) {
182
- const currentLine = describable2[i];
183
- if (currentLine.trim() === "```") {
184
- break;
185
- }
186
- codeBlockLines.push(currentLine);
187
- i++;
169
+ return {
170
+ description: describableToRenderableContent(describable, linkGenerator)
171
+ };
172
+ }
173
+ function describableToRenderableContent(describable, linkGenerator) {
174
+ if (!describable) {
175
+ return;
176
+ }
177
+ let content = [];
178
+ for (let i = 0; i < describable.length; i++) {
179
+ const line = describable[i];
180
+ const codeBlockMatch = line.match(/^```([a-zA-Z]*)$/);
181
+ if (codeBlockMatch) {
182
+ const language = codeBlockMatch[1] || "apex";
183
+ const codeBlockLines = [];
184
+ i++;
185
+ while (i < describable.length) {
186
+ const currentLine = describable[i];
187
+ if (currentLine.trim() === "```") {
188
+ break;
188
189
  }
189
- content = [
190
- ...content,
191
- {
192
- __type: "code-block",
193
- language,
194
- content: codeBlockLines
195
- },
196
- { __type: "empty-line" }
197
- ];
198
- continue;
190
+ codeBlockLines.push(currentLine);
191
+ i++;
199
192
  }
200
193
  content = [
201
194
  ...content,
202
- ...replaceInlineReferences(line, linkGenerator),
203
195
  {
204
- __type: "empty-line"
205
- }
196
+ __type: "code-block",
197
+ language,
198
+ content: codeBlockLines
199
+ },
200
+ { __type: "empty-line" }
206
201
  ];
202
+ continue;
207
203
  }
208
- return content.filter((line, index, lines) => !(isEmptyLine(line) && index === lines.length - 1));
204
+ content = [
205
+ ...content,
206
+ ...replaceInlineReferences(line, linkGenerator),
207
+ {
208
+ __type: "empty-line"
209
+ }
210
+ ];
209
211
  }
210
- return {
211
- description: describableToRenderableContent(describable)
212
- };
212
+ return content.filter((line, index, lines) => !(isEmptyLine(line) && index === lines.length - 1));
213
213
  }
214
214
  function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
215
215
  var _a, _b, _c;
216
216
  function extractCustomTags(type) {
217
217
  var _a2, _b2;
218
- const baseTags = ["description", "group", "author", "date", "see", "example", "mermaid", "throws", "exception"];
218
+ const baseTags = ["description", "group", "author", "date", "see", "example", "throws", "exception"];
219
219
  return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase())).map((currentAnnotation) => __spreadProps$f(__spreadValues$f({}, adaptDescribable(currentAnnotation.bodyLines, linkGenerator)), {
220
220
  name: currentAnnotation.name
221
221
  }))) != null ? _b2 : [];
222
222
  }
223
- function extractAnnotationBodyLines(type, annotationName) {
224
- var _a2, _b2;
225
- return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.find(
226
- (currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName
227
- )) == null ? void 0 : _b2.bodyLines;
228
- }
229
223
  function extractAnnotationBody(type, annotationName) {
230
224
  var _a2, _b2;
231
225
  return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.find(
@@ -236,28 +230,13 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
236
230
  var _a2, _b2;
237
231
  return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === "see").map((currentAnnotation) => currentAnnotation.body)) != null ? _b2 : [];
238
232
  }
239
- function bodyLinesToCodeBlock(language, bodyLines) {
240
- if (!bodyLines) {
241
- return;
242
- }
243
- return {
244
- __type: "code-block",
245
- language,
246
- content: bodyLines
247
- };
248
- }
249
233
  return __spreadProps$f(__spreadValues$f({}, adaptDescribable((_a = documentable.docComment) == null ? void 0 : _a.descriptionLines, linkGenerator)), {
250
234
  annotations: documentable.annotations.map((annotation) => annotation.type.toUpperCase()),
251
235
  customTags: extractCustomTags(documentable),
252
- mermaid: {
253
- headingLevel: subHeadingLevel,
254
- heading: "Diagram",
255
- value: bodyLinesToCodeBlock("mermaid", extractAnnotationBodyLines(documentable, "mermaid"))
256
- },
257
236
  example: {
258
237
  headingLevel: subHeadingLevel,
259
238
  heading: "Example",
260
- value: bodyLinesToCodeBlock("apex", (_c = (_b = documentable.docComment) == null ? void 0 : _b.exampleAnnotation) == null ? void 0 : _c.bodyLines)
239
+ value: describableToRenderableContent((_c = (_b = documentable.docComment) == null ? void 0 : _b.exampleAnnotation) == null ? void 0 : _c.bodyLines, linkGenerator)
261
240
  },
262
241
  group: extractAnnotationBody(documentable, "group"),
263
242
  author: extractAnnotationBody(documentable, "author"),
@@ -446,7 +425,7 @@ function typeToRenderable(parsedFile, linkGenerator, config) {
446
425
  }
447
426
  }
448
427
  return __spreadProps$d(__spreadValues$d({}, getRenderable()), {
449
- filePath: parsedFile.filePath,
428
+ filePath: parsedFile.source.filePath,
450
429
  namespace: config.namespace
451
430
  });
452
431
  }
@@ -590,116 +569,53 @@ function singleGroup(headingLevel, groupName, adapter, members, linkGenerator) {
590
569
  };
591
570
  }
592
571
 
593
- function parsedFilesToRenderableBundle(config, parsedFiles) {
594
- return parsedFiles.reduce(
595
- (acc, parsedFile) => {
596
- var _a;
597
- const renderable = typeToRenderable(
598
- parsedFile,
599
- (referenceName) => {
600
- return linkFromTypeNameGenerator(
601
- parsedFile.type,
602
- parsedFiles.map((file) => file.type),
603
- referenceName,
604
- config
605
- );
606
- },
607
- config
608
- );
609
- acc.renderables.push(renderable);
610
- const descriptionLines = (_a = parsedFile.type.docComment) == null ? void 0 : _a.descriptionLines;
611
- const reference = {
612
- typeName: parsedFile.type.name,
613
- directory: getDirectoryFromRoot(config, parsedFile.type),
614
- title: getLinkFromRoot(config, parsedFile.type),
615
- description: adaptDescribable(
616
- descriptionLines,
617
- (referenceName) => getPossibleLinkFromRoot(
618
- config,
619
- referenceName,
620
- findType(
621
- parsedFiles.map((file) => file.type),
622
- referenceName
623
- )
624
- )
625
- ).description
626
- };
627
- const group = getTypeGroup(parsedFile.type, config);
628
- if (!acc.references[group]) {
629
- acc.references[group] = [];
630
- }
631
- acc.references[group].push(reference);
572
+ function parsedFilesToRenderableBundle(config, parsedFiles, references) {
573
+ const referenceFinder = apply(linkGenerator, references);
574
+ function toReferenceGuide(parsedFiles2) {
575
+ return parsedFiles2.reduce(
576
+ addToReferenceGuide(referenceFinder, config, references),
577
+ {}
578
+ );
579
+ }
580
+ function toRenderables(parsedFiles2) {
581
+ return parsedFiles2.reduce((acc, parsedFile) => {
582
+ const renderable = typeToRenderable(parsedFile, referenceFinder, config);
583
+ acc.push(renderable);
632
584
  return acc;
633
- },
634
- {
635
- references: {},
636
- renderables: []
637
- }
638
- );
639
- }
640
- function linkFromTypeNameGenerator(typeBeingDocumented, repository, referenceName, config) {
641
- const type = findType(repository, referenceName);
642
- if (!type) {
643
- return referenceName;
585
+ }, []);
644
586
  }
645
- const [fullClassName, fileLink] = getFileLinkTuple(typeBeingDocumented, type, config);
646
587
  return {
647
- __type: "link",
648
- title: fullClassName,
649
- url: fileLink
588
+ referencesByGroup: toReferenceGuide(parsedFiles),
589
+ renderables: toRenderables(parsedFiles)
650
590
  };
651
591
  }
652
- function getPossibleLinkFromRoot(config, fallback, type) {
653
- if (!type) {
654
- return fallback;
655
- }
656
- const namespacePrefix = config.namespace ? `${config.namespace}.` : "";
657
- const title = `${namespacePrefix}${type.name}`;
658
- return {
659
- __type: "link",
660
- title,
661
- url: `${getDirectoryFromRoot(config, type)}/${title}.md`
592
+ function addToReferenceGuide(findLinkFromHome, config, references) {
593
+ return (acc, parsedFile) => {
594
+ var _a, _b;
595
+ const group = getTypeGroup$1(parsedFile.type, config);
596
+ if (!acc[group]) {
597
+ acc[group] = [];
598
+ }
599
+ acc[group].push({
600
+ reference: references[parsedFile.type.name],
601
+ title: findLinkFromHome(parsedFile.type.name),
602
+ description: (_b = adaptDescribable((_a = parsedFile.type.docComment) == null ? void 0 : _a.descriptionLines, findLinkFromHome).description) != null ? _b : null
603
+ });
604
+ return acc;
662
605
  };
663
606
  }
664
- function getDirectoryFromRoot(config, type) {
665
- if (!type) {
666
- return "";
667
- }
668
- return `./${getSanitizedGroup(type, config)}`;
669
- }
670
- function findType(repository, referenceName) {
671
- return repository.find((currentType) => currentType.name.toLowerCase() === referenceName.toLowerCase());
672
- }
673
- function getFileLinkTuple(typeBeingDocumented, referencedType, config) {
674
- const namespacePrefix = config.namespace ? `${config.namespace}.` : "";
675
- const directoryRoot = `${getDirectoryRoot(typeBeingDocumented, referencedType, config)}`;
676
- const fullClassName = `${namespacePrefix}${referencedType.name}`;
677
- return [fullClassName, `${directoryRoot}${fullClassName}.md`];
678
- }
679
- function getDirectoryRoot(typeBeingDocumented, referencedType, config) {
680
- if (getTypeGroup(typeBeingDocumented, config) === getTypeGroup(referencedType, config)) {
681
- return "./";
682
- } else {
683
- return `../${getSanitizedGroup(referencedType, config)}/`;
684
- }
685
- }
686
- function getTypeGroup(type, config) {
607
+ const linkGenerator = (references, referenceName) => {
608
+ const reference = references[referenceName];
609
+ return reference ? (
610
+ // Starting the path with a "/" will ensure the link will always be relative to the root of the site.
611
+ { __type: "link", title: reference.displayName, url: `/${reference.pathFromRoot}` }
612
+ ) : referenceName;
613
+ };
614
+ function getTypeGroup$1(type, config) {
687
615
  var _a, _b;
688
616
  const groupAnnotation = (_a = type.docComment) == null ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === "group");
689
617
  return (_b = groupAnnotation == null ? void 0 : groupAnnotation.body) != null ? _b : config.defaultGroupName;
690
618
  }
691
- function getSanitizedGroup(classModel, config) {
692
- return getTypeGroup(classModel, config).replace(/ /g, "-").replace(".", "");
693
- }
694
- function getLinkFromRoot(config, type) {
695
- const namespacePrefix = config.namespace ? `${config.namespace}.` : "";
696
- const title = `${namespacePrefix}${type.name}`;
697
- return {
698
- __type: "link",
699
- title,
700
- url: `${getDirectoryFromRoot(config, type)}/${title}.md`
701
- };
702
- }
703
619
 
704
620
  function parseApexMetadata(input) {
705
621
  var _a;
@@ -751,7 +667,11 @@ function reflectSourceBody(apexBundle) {
751
667
  const { filePath, content: input, metadataContent: metadata } = apexBundle;
752
668
  const result = apexReflection.reflect(input);
753
669
  return result.error ? E__namespace.left(new ReflectionError(filePath, result.error.message)) : E__namespace.right({
754
- filePath,
670
+ source: {
671
+ filePath,
672
+ name: result.typeMirror.name,
673
+ type: result.typeMirror.type_name
674
+ },
755
675
  type: addFileMetadataToTypeAnnotation(result.typeMirror, metadata)
756
676
  });
757
677
  }
@@ -973,7 +893,7 @@ const documentablePartialTemplate = `
973
893
 
974
894
  {{#if doc.example.value}}
975
895
  {{ heading doc.example.headingLevel doc.example.heading }}
976
- {{code doc.example.value}}
896
+ {{{renderContent doc.example.value}}}
977
897
  {{/if}}
978
898
  `.trim();
979
899
 
@@ -1270,15 +1190,15 @@ const link = (source) => {
1270
1190
  }
1271
1191
  };
1272
1192
 
1273
- const convertToDocumentationBundle = (referenceGuideTemplate, { references, renderables }) => ({
1193
+ const convertToDocumentationBundle = (referenceGuideTemplate, { referencesByGroup, renderables }) => ({
1274
1194
  referenceGuide: {
1275
- directory: "",
1276
1195
  frontmatter: null,
1277
- content: referencesToReferenceGuideContent(references, referenceGuideTemplate),
1278
- fileExtension: "md",
1279
- fileName: "index"
1196
+ content: referencesToReferenceGuideContent(referencesByGroup, referenceGuideTemplate),
1197
+ filePath: "index.md"
1280
1198
  },
1281
- docs: renderables.map((renderable) => renderableToPageData(Object.values(references).flat(), renderable))
1199
+ docs: renderables.map(
1200
+ (renderable) => renderableToPageData(Object.values(referencesByGroup).flat(), renderable)
1201
+ )
1282
1202
  });
1283
1203
  function referencesToReferenceGuideContent(references, template) {
1284
1204
  function alphabetizeReferences(references2) {
@@ -1300,21 +1220,18 @@ function renderableToPageData(referenceGuideReference, renderable) {
1300
1220
  function buildDocOutput(renderable2, docContents) {
1301
1221
  var _a;
1302
1222
  const reference = referenceGuideReference.find(
1303
- (ref) => ref.typeName.toLowerCase() === renderable2.name.toLowerCase()
1223
+ (ref) => ref.reference.source.name.toLowerCase() === renderable2.name.toLowerCase()
1304
1224
  );
1305
- const namespacePrefix = renderable2.namespace ? `${renderable2.namespace}.` : "";
1306
1225
  return {
1307
1226
  source: {
1308
1227
  filePath: renderable2.filePath,
1309
1228
  name: renderable2.name,
1310
1229
  type: renderable2.type
1311
1230
  },
1312
- fileName: `${namespacePrefix}${renderable2.name}`,
1313
- fileExtension: "md",
1314
- directory: `${reference == null ? void 0 : reference.directory}`,
1231
+ filePath: reference.reference.pathFromRoot,
1315
1232
  frontmatter: null,
1316
1233
  content: docContents,
1317
- group: (_a = renderable2.doc.group) != null ? _a : "Miscellaneous"
1234
+ group: (_a = renderable2.doc.group) != null ? _a : defaults.defaults.defaultGroupName
1318
1235
  };
1319
1236
  }
1320
1237
  return _function.pipe(renderable, resolveApexTypeTemplate, compile, (docContents) => buildDocOutput(renderable, docContents));
@@ -1522,6 +1439,28 @@ function isSkip(value) {
1522
1439
  return Object.prototype.hasOwnProperty.call(value, "_tag") && value._tag === "Skip";
1523
1440
  }
1524
1441
 
1442
+ function parsedFilesToReferenceGuide(config, parsedFiles) {
1443
+ return parsedFiles.reduce((acc, parsedFile) => {
1444
+ acc[parsedFile.type.name] = parsedFileToDocPageReference(config, parsedFile);
1445
+ return acc;
1446
+ }, {});
1447
+ }
1448
+ function parsedFileToDocPageReference(config, parsedFile) {
1449
+ return {
1450
+ source: parsedFile.source,
1451
+ displayName: parsedFile.type.name,
1452
+ pathFromRoot: `${slugify(getTypeGroup(parsedFile.type, config))}/${parsedFile.type.name}.md`
1453
+ };
1454
+ }
1455
+ function getTypeGroup(type, config) {
1456
+ var _a, _b;
1457
+ const groupAnnotation = (_a = type.docComment) == null ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === "group");
1458
+ return (_b = groupAnnotation == null ? void 0 : groupAnnotation.body) != null ? _b : config.defaultGroupName;
1459
+ }
1460
+ function slugify(text) {
1461
+ return text.toLowerCase().replace(/[^a-z0-9\s-]/g, "").trim().replace(/\s+/g, "-").replace(/-+/g, "-");
1462
+ }
1463
+
1525
1464
  var __defProp$7 = Object.defineProperty;
1526
1465
  var __defProps$7 = Object.defineProperties;
1527
1466
  var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
@@ -1569,6 +1508,7 @@ class HookError {
1569
1508
  }
1570
1509
  function generateDocs(apexBundles, config) {
1571
1510
  const filterOutOfScope = apply(filterScope, config.scope);
1511
+ const convertToReferences = apply(parsedFilesToReferenceGuide, config);
1572
1512
  const convertToRenderableBundle = apply(parsedFilesToRenderableBundle, config);
1573
1513
  const convertToDocumentationBundleForTemplate = apply(convertToDocumentationBundle, config.referenceGuideTemplate);
1574
1514
  const sortTypeMembers = apply(sortMembers, config.sortMembersAlphabetically);
@@ -1580,52 +1520,50 @@ function generateDocs(apexBundles, config) {
1580
1520
  E__namespace.map(addInheritedMembersToTypes),
1581
1521
  E__namespace.map(addInheritanceChainToTypes),
1582
1522
  E__namespace.map(sortTypeMembers),
1583
- E__namespace.map(convertToRenderableBundle),
1584
- E__namespace.map(convertToDocumentationBundleForTemplate),
1523
+ E__namespace.bindTo("parsedFiles"),
1524
+ E__namespace.bind("references", ({ parsedFiles }) => E__namespace.right(convertToReferences(parsedFiles))),
1585
1525
  TE__namespace.fromEither,
1586
- TE__namespace.flatMap(
1587
- (bundle) => TE__namespace.tryCatch(
1588
- () => documentationBundleHook(bundle, config),
1589
- (error) => new HookError(error)
1590
- )
1591
- ),
1592
- TE__namespace.map((bundle) => ({
1593
- referenceGuide: isSkip(bundle.referenceGuide) ? bundle.referenceGuide : __spreadProps$7(__spreadValues$7({}, bundle.referenceGuide), {
1594
- content: Template.getInstance().compile({
1595
- source: {
1596
- frontmatter: toFrontmatterString(bundle.referenceGuide.frontmatter),
1597
- content: bundle.referenceGuide.content
1598
- },
1599
- template: hookableTemplate
1600
- })
1601
- }),
1602
- docs: bundle.docs.map((doc) => __spreadProps$7(__spreadValues$7({}, doc), {
1603
- content: Template.getInstance().compile({
1604
- source: {
1605
- frontmatter: toFrontmatterString(doc.frontmatter),
1606
- content: doc.content
1607
- },
1608
- template: hookableTemplate
1609
- })
1610
- }))
1611
- }))
1526
+ TE__namespace.flatMap(({ parsedFiles, references }) => transformReferenceHook(config)({ references, parsedFiles })),
1527
+ TE__namespace.map(({ parsedFiles, references }) => convertToRenderableBundle(parsedFiles, references)),
1528
+ TE__namespace.map(convertToDocumentationBundleForTemplate),
1529
+ TE__namespace.flatMap(transformDocumentationBundleHook(config)),
1530
+ TE__namespace.map(postHookCompile)
1612
1531
  );
1613
1532
  }
1614
- function toFrontmatterString(frontmatter) {
1615
- if (typeof frontmatter === "string") {
1616
- return frontmatter;
1617
- }
1618
- if (!frontmatter) {
1619
- return "";
1533
+ function transformReferenceHook(config) {
1534
+ function _execute(references, parsedFiles, transformReference) {
1535
+ return __async$2(this, null, function* () {
1536
+ return {
1537
+ references: yield execTransformReferenceHook(Object.values(references), transformReference),
1538
+ parsedFiles
1539
+ };
1540
+ });
1620
1541
  }
1621
- const yamlString = yaml.dump(frontmatter);
1622
- return `---
1623
- ${yamlString}---
1624
- `;
1542
+ return ({ references, parsedFiles }) => TE__namespace.tryCatch(
1543
+ () => _execute(references, parsedFiles, config.transformReference),
1544
+ (error) => new HookError(error)
1545
+ );
1546
+ }
1547
+ function transformDocumentationBundleHook(config) {
1548
+ return (bundle) => TE__namespace.tryCatch(
1549
+ () => documentationBundleHook(bundle, config),
1550
+ (error) => new HookError(error)
1551
+ );
1625
1552
  }
1626
1553
  function passThroughHook(value) {
1627
1554
  return value;
1628
1555
  }
1556
+ const execTransformReferenceHook = (_0, ..._1) => __async$2(void 0, [_0, ..._1], function* (references, hook = passThroughHook) {
1557
+ const hooked = references.map((reference) => __async$2(void 0, null, function* () {
1558
+ const hookedResult = yield hook(reference);
1559
+ return __spreadValues$7(__spreadValues$7({}, reference), hookedResult);
1560
+ }));
1561
+ const awaited = yield Promise.all(hooked);
1562
+ return awaited.reduce((acc, reference) => {
1563
+ acc[reference.source.name] = reference;
1564
+ return acc;
1565
+ }, {});
1566
+ });
1629
1567
  const documentationBundleHook = (bundle, config) => __async$2(void 0, null, function* () {
1630
1568
  return {
1631
1569
  referenceGuide: yield transformReferenceGuide(bundle.referenceGuide, config.transformReferenceGuide),
@@ -1646,6 +1584,40 @@ const transformDocs = (_0, ..._1) => __async$2(void 0, [_0, ..._1], function* (d
1646
1584
  const transformDocPage = (_0, ..._1) => __async$2(void 0, [_0, ..._1], function* (doc, hook = passThroughHook) {
1647
1585
  return __spreadValues$7(__spreadValues$7({}, doc), yield hook(doc));
1648
1586
  });
1587
+ function postHookCompile(bundle) {
1588
+ return {
1589
+ referenceGuide: isSkip(bundle.referenceGuide) ? bundle.referenceGuide : __spreadProps$7(__spreadValues$7({}, bundle.referenceGuide), {
1590
+ content: Template.getInstance().compile({
1591
+ source: {
1592
+ frontmatter: toFrontmatterString(bundle.referenceGuide.frontmatter),
1593
+ content: bundle.referenceGuide.content
1594
+ },
1595
+ template: hookableTemplate
1596
+ })
1597
+ }),
1598
+ docs: bundle.docs.map((doc) => __spreadProps$7(__spreadValues$7({}, doc), {
1599
+ content: Template.getInstance().compile({
1600
+ source: {
1601
+ frontmatter: toFrontmatterString(doc.frontmatter),
1602
+ content: doc.content
1603
+ },
1604
+ template: hookableTemplate
1605
+ })
1606
+ }))
1607
+ };
1608
+ }
1609
+ function toFrontmatterString(frontmatter) {
1610
+ if (typeof frontmatter === "string") {
1611
+ return frontmatter;
1612
+ }
1613
+ if (!frontmatter) {
1614
+ return "";
1615
+ }
1616
+ const yamlString = yaml.dump(frontmatter);
1617
+ return `---
1618
+ ${yamlString}---
1619
+ `;
1620
+ }
1649
1621
 
1650
1622
  var __defProp$6 = Object.defineProperty;
1651
1623
  var __defProps$6 = Object.defineProperties;
@@ -1669,18 +1641,15 @@ var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
1669
1641
  class FileWriter {
1670
1642
  static write(files, outputDir, onWriteCallback) {
1671
1643
  files.forEach((file) => {
1672
- const resolvedFile = this.getTargetLocation(file, outputDir);
1673
- if (!fs__namespace.existsSync(resolvedFile.directory)) {
1674
- fs__namespace.mkdirSync(resolvedFile.directory, { recursive: true });
1675
- }
1676
- const filePath = path__namespace.join(resolvedFile.directory, `${resolvedFile.fileName}.${resolvedFile.fileExtension}`);
1677
- fs__namespace.writeFileSync(filePath, resolvedFile.content, "utf8");
1678
- onWriteCallback(resolvedFile);
1644
+ const { filePath, content } = this.getTargetLocation(file, outputDir);
1645
+ fs__namespace.mkdirSync(path__namespace.dirname(filePath), { recursive: true });
1646
+ fs__namespace.writeFileSync(filePath, content, "utf8");
1647
+ onWriteCallback(file);
1679
1648
  });
1680
1649
  }
1681
1650
  static getTargetLocation(file, outputDir) {
1682
1651
  return __spreadProps$6(__spreadValues$6({}, file), {
1683
- directory: path__namespace.join(outputDir, file.directory)
1652
+ filePath: path__namespace.join(outputDir, file.filePath)
1684
1653
  });
1685
1654
  }
1686
1655
  }
@@ -1796,7 +1765,7 @@ function writeFilesToSystem(files, outputDir) {
1796
1765
  [files.referenceGuide, ...files.docs].filter((file) => !isSkip(file)),
1797
1766
  outputDir,
1798
1767
  (file) => {
1799
- Logger.logSingle(`${file.fileName} processed.`, false, "green", false);
1768
+ Logger.logSingle(`${file.filePath} processed.`, false, "green", false);
1800
1769
  }
1801
1770
  );
1802
1771
  }
@@ -2681,9 +2650,7 @@ var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
2681
2650
  function createOpenApiFile(fileName, openApiModel) {
2682
2651
  const content = JSON.stringify(__spreadProps$1(__spreadValues$1({}, openApiModel), { namespace: void 0 }), null, 2);
2683
2652
  return {
2684
- fileExtension: "json",
2685
- fileName,
2686
- directory: "",
2653
+ filePath: "",
2687
2654
  content,
2688
2655
  frontmatter: null,
2689
2656
  group: null
@@ -2756,7 +2723,7 @@ function openApi(fileBodies, config) {
2756
2723
  Transpiler.generate(filteredTypes, processor);
2757
2724
  const generatedFiles = processor.fileBuilder().files();
2758
2725
  FileWriter.write(generatedFiles, config.targetDir, (file) => {
2759
- Logger.logSingle(`${file.fileName} processed.`, false, "green", false);
2726
+ Logger.logSingle(`${file.filePath} processed.`, false, "green", false);
2760
2727
  });
2761
2728
  ErrorLogger.logErrors(filteredTypes);
2762
2729
  }