@cparra/apexdocs 3.0.0-alpha.8 → 3.0.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.
- package/dist/cli/generate.js +146 -94
- package/package.json +2 -2
- package/src/application/generators/markdown.ts +1 -1
- package/src/core/markdown/generate-docs.ts +11 -12
- package/src/core/markdown/reflection/reflect-source.ts +97 -20
- package/dist/defaults-DUwru49Q.js +0 -12
- package/dist/defaults-SH0Rsi5E.js +0 -11
- package/dist/defaults-jLXD2y8-.js +0 -13
- package/src/core/markdown/reflection/error-handling.ts +0 -37
package/dist/cli/generate.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var _function = require('fp-ts/function');
|
|
5
|
-
var E = require('fp-ts/Either');
|
|
6
5
|
var TE = require('fp-ts/TaskEither');
|
|
7
6
|
var yaml = require('js-yaml');
|
|
8
7
|
var path = require('path');
|
|
8
|
+
var T = require('fp-ts/Task');
|
|
9
|
+
var A = require('fp-ts/lib/Array');
|
|
9
10
|
var apexReflection = require('@cparra/apex-reflection');
|
|
10
11
|
var O = require('fp-ts/Option');
|
|
11
12
|
var fastXmlParser = require('fast-xml-parser');
|
|
@@ -34,10 +35,11 @@ function _interopNamespaceDefault(e) {
|
|
|
34
35
|
return Object.freeze(n);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
var E__namespace = /*#__PURE__*/_interopNamespaceDefault(E);
|
|
38
38
|
var TE__namespace = /*#__PURE__*/_interopNamespaceDefault(TE);
|
|
39
39
|
var yaml__namespace = /*#__PURE__*/_interopNamespaceDefault(yaml);
|
|
40
40
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
|
|
41
|
+
var T__namespace = /*#__PURE__*/_interopNamespaceDefault(T);
|
|
42
|
+
var A__namespace = /*#__PURE__*/_interopNamespaceDefault(A);
|
|
41
43
|
var O__namespace = /*#__PURE__*/_interopNamespaceDefault(O);
|
|
42
44
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
43
45
|
var yargs__namespace = /*#__PURE__*/_interopNamespaceDefault(yargs);
|
|
@@ -145,25 +147,25 @@ function isInlineCode(content) {
|
|
|
145
147
|
return Object.keys(content).includes("__type") && content.__type === "inline-code";
|
|
146
148
|
}
|
|
147
149
|
|
|
148
|
-
var __defProp$
|
|
149
|
-
var __defProps$
|
|
150
|
-
var __getOwnPropDescs$
|
|
151
|
-
var __getOwnPropSymbols$
|
|
152
|
-
var __hasOwnProp$
|
|
153
|
-
var __propIsEnum$
|
|
154
|
-
var __defNormalProp$
|
|
155
|
-
var __spreadValues$
|
|
150
|
+
var __defProp$g = Object.defineProperty;
|
|
151
|
+
var __defProps$g = Object.defineProperties;
|
|
152
|
+
var __getOwnPropDescs$g = Object.getOwnPropertyDescriptors;
|
|
153
|
+
var __getOwnPropSymbols$g = Object.getOwnPropertySymbols;
|
|
154
|
+
var __hasOwnProp$g = Object.prototype.hasOwnProperty;
|
|
155
|
+
var __propIsEnum$g = Object.prototype.propertyIsEnumerable;
|
|
156
|
+
var __defNormalProp$g = (obj, key, value) => key in obj ? __defProp$g(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
157
|
+
var __spreadValues$g = (a, b) => {
|
|
156
158
|
for (var prop in b || (b = {}))
|
|
157
|
-
if (__hasOwnProp$
|
|
158
|
-
__defNormalProp$
|
|
159
|
-
if (__getOwnPropSymbols$
|
|
160
|
-
for (var prop of __getOwnPropSymbols$
|
|
161
|
-
if (__propIsEnum$
|
|
162
|
-
__defNormalProp$
|
|
159
|
+
if (__hasOwnProp$g.call(b, prop))
|
|
160
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
161
|
+
if (__getOwnPropSymbols$g)
|
|
162
|
+
for (var prop of __getOwnPropSymbols$g(b)) {
|
|
163
|
+
if (__propIsEnum$g.call(b, prop))
|
|
164
|
+
__defNormalProp$g(a, prop, b[prop]);
|
|
163
165
|
}
|
|
164
166
|
return a;
|
|
165
167
|
};
|
|
166
|
-
var __spreadProps$
|
|
168
|
+
var __spreadProps$g = (a, b) => __defProps$g(a, __getOwnPropDescs$g(b));
|
|
167
169
|
function adaptDescribable(describable, linkGenerator) {
|
|
168
170
|
return {
|
|
169
171
|
description: describableToRenderableContent(describable, linkGenerator)
|
|
@@ -215,7 +217,7 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
|
|
|
215
217
|
function extractCustomTags(type) {
|
|
216
218
|
var _a2, _b2;
|
|
217
219
|
const baseTags = ["description", "group", "author", "date", "see", "example", "throws", "exception"];
|
|
218
|
-
return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase())).map((currentAnnotation) => __spreadProps$
|
|
220
|
+
return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase())).map((currentAnnotation) => __spreadProps$g(__spreadValues$g({}, adaptDescribable(currentAnnotation.bodyLines, linkGenerator)), {
|
|
219
221
|
name: currentAnnotation.name
|
|
220
222
|
}))) != null ? _b2 : [];
|
|
221
223
|
}
|
|
@@ -229,7 +231,7 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
|
|
|
229
231
|
var _a2, _b2;
|
|
230
232
|
return (_b2 = (_a2 = type.docComment) == null ? void 0 : _a2.annotations.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === "see").map((currentAnnotation) => currentAnnotation.body)) != null ? _b2 : [];
|
|
231
233
|
}
|
|
232
|
-
return __spreadProps$
|
|
234
|
+
return __spreadProps$g(__spreadValues$g({}, adaptDescribable((_a = documentable.docComment) == null ? void 0 : _a.descriptionLines, linkGenerator)), {
|
|
233
235
|
annotations: documentable.annotations.map((annotation) => annotation.type.toUpperCase()),
|
|
234
236
|
customTags: extractCustomTags(documentable),
|
|
235
237
|
example: {
|
|
@@ -244,25 +246,25 @@ function adaptDocumentable(documentable, linkGenerator, subHeadingLevel) {
|
|
|
244
246
|
});
|
|
245
247
|
}
|
|
246
248
|
|
|
247
|
-
var __defProp$
|
|
248
|
-
var __defProps$
|
|
249
|
-
var __getOwnPropDescs$
|
|
250
|
-
var __getOwnPropSymbols$
|
|
251
|
-
var __hasOwnProp$
|
|
252
|
-
var __propIsEnum$
|
|
253
|
-
var __defNormalProp$
|
|
254
|
-
var __spreadValues$
|
|
249
|
+
var __defProp$f = Object.defineProperty;
|
|
250
|
+
var __defProps$f = Object.defineProperties;
|
|
251
|
+
var __getOwnPropDescs$f = Object.getOwnPropertyDescriptors;
|
|
252
|
+
var __getOwnPropSymbols$f = Object.getOwnPropertySymbols;
|
|
253
|
+
var __hasOwnProp$f = Object.prototype.hasOwnProperty;
|
|
254
|
+
var __propIsEnum$f = Object.prototype.propertyIsEnumerable;
|
|
255
|
+
var __defNormalProp$f = (obj, key, value) => key in obj ? __defProp$f(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
256
|
+
var __spreadValues$f = (a, b) => {
|
|
255
257
|
for (var prop in b || (b = {}))
|
|
256
|
-
if (__hasOwnProp$
|
|
257
|
-
__defNormalProp$
|
|
258
|
-
if (__getOwnPropSymbols$
|
|
259
|
-
for (var prop of __getOwnPropSymbols$
|
|
260
|
-
if (__propIsEnum$
|
|
261
|
-
__defNormalProp$
|
|
258
|
+
if (__hasOwnProp$f.call(b, prop))
|
|
259
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
260
|
+
if (__getOwnPropSymbols$f)
|
|
261
|
+
for (var prop of __getOwnPropSymbols$f(b)) {
|
|
262
|
+
if (__propIsEnum$f.call(b, prop))
|
|
263
|
+
__defNormalProp$f(a, prop, b[prop]);
|
|
262
264
|
}
|
|
263
265
|
return a;
|
|
264
266
|
};
|
|
265
|
-
var __spreadProps$
|
|
267
|
+
var __spreadProps$f = (a, b) => __defProps$f(a, __getOwnPropDescs$f(b));
|
|
266
268
|
function adaptMethod(method, linkGenerator, baseHeadingLevel) {
|
|
267
269
|
var _a, _b, _c;
|
|
268
270
|
function buildTitle(method2) {
|
|
@@ -292,7 +294,7 @@ function adaptMethod(method, linkGenerator, baseHeadingLevel) {
|
|
|
292
294
|
returnType: {
|
|
293
295
|
headingLevel: baseHeadingLevel + 1,
|
|
294
296
|
heading: "Return Type",
|
|
295
|
-
value: __spreadProps$
|
|
297
|
+
value: __spreadProps$f(__spreadValues$f({}, adaptDescribable((_b = (_a = method.docComment) == null ? void 0 : _a.returnAnnotation) == null ? void 0 : _b.bodyLines, linkGenerator)), {
|
|
296
298
|
type: linkGenerator(method.typeReference.rawDeclaration)
|
|
297
299
|
})
|
|
298
300
|
},
|
|
@@ -351,13 +353,13 @@ function mapParameters(documentable, param, linkGenerator) {
|
|
|
351
353
|
const paramAnnotation = (_a = documentable.docComment) == null ? void 0 : _a.paramAnnotations.find(
|
|
352
354
|
(pa) => pa.paramName.toLowerCase() === param.name.toLowerCase()
|
|
353
355
|
);
|
|
354
|
-
return __spreadProps$
|
|
356
|
+
return __spreadProps$f(__spreadValues$f({}, adaptDescribable(paramAnnotation == null ? void 0 : paramAnnotation.bodyLines, linkGenerator)), {
|
|
355
357
|
name: param.name,
|
|
356
358
|
type: linkGenerator(param.typeReference.rawDeclaration)
|
|
357
359
|
});
|
|
358
360
|
}
|
|
359
361
|
function mapThrows(thrown, linkGenerator) {
|
|
360
|
-
return __spreadProps$
|
|
362
|
+
return __spreadProps$f(__spreadValues$f({}, adaptDescribable(thrown.bodyLines, linkGenerator)), {
|
|
361
363
|
type: linkGenerator(thrown.exceptionName)
|
|
362
364
|
});
|
|
363
365
|
}
|
|
@@ -392,25 +394,25 @@ function adaptFieldOrProperty(field, linkGenerator, baseHeadingLevel) {
|
|
|
392
394
|
};
|
|
393
395
|
}
|
|
394
396
|
|
|
395
|
-
var __defProp$
|
|
396
|
-
var __defProps$
|
|
397
|
-
var __getOwnPropDescs$
|
|
398
|
-
var __getOwnPropSymbols$
|
|
399
|
-
var __hasOwnProp$
|
|
400
|
-
var __propIsEnum$
|
|
401
|
-
var __defNormalProp$
|
|
402
|
-
var __spreadValues$
|
|
397
|
+
var __defProp$e = Object.defineProperty;
|
|
398
|
+
var __defProps$e = Object.defineProperties;
|
|
399
|
+
var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
|
|
400
|
+
var __getOwnPropSymbols$e = Object.getOwnPropertySymbols;
|
|
401
|
+
var __hasOwnProp$e = Object.prototype.hasOwnProperty;
|
|
402
|
+
var __propIsEnum$e = Object.prototype.propertyIsEnumerable;
|
|
403
|
+
var __defNormalProp$e = (obj, key, value) => key in obj ? __defProp$e(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
404
|
+
var __spreadValues$e = (a, b) => {
|
|
403
405
|
for (var prop in b || (b = {}))
|
|
404
|
-
if (__hasOwnProp$
|
|
405
|
-
__defNormalProp$
|
|
406
|
-
if (__getOwnPropSymbols$
|
|
407
|
-
for (var prop of __getOwnPropSymbols$
|
|
408
|
-
if (__propIsEnum$
|
|
409
|
-
__defNormalProp$
|
|
406
|
+
if (__hasOwnProp$e.call(b, prop))
|
|
407
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
408
|
+
if (__getOwnPropSymbols$e)
|
|
409
|
+
for (var prop of __getOwnPropSymbols$e(b)) {
|
|
410
|
+
if (__propIsEnum$e.call(b, prop))
|
|
411
|
+
__defNormalProp$e(a, prop, b[prop]);
|
|
410
412
|
}
|
|
411
413
|
return a;
|
|
412
414
|
};
|
|
413
|
-
var __spreadProps$
|
|
415
|
+
var __spreadProps$e = (a, b) => __defProps$e(a, __getOwnPropDescs$e(b));
|
|
414
416
|
function typeToRenderable(parsedFile, linkGenerator, config) {
|
|
415
417
|
function getRenderable() {
|
|
416
418
|
const { type } = parsedFile;
|
|
@@ -423,7 +425,7 @@ function typeToRenderable(parsedFile, linkGenerator, config) {
|
|
|
423
425
|
return classTypeToClassSource(type, linkGenerator);
|
|
424
426
|
}
|
|
425
427
|
}
|
|
426
|
-
return __spreadProps$
|
|
428
|
+
return __spreadProps$e(__spreadValues$e({}, getRenderable()), {
|
|
427
429
|
filePath: parsedFile.source.filePath,
|
|
428
430
|
namespace: config.namespace
|
|
429
431
|
});
|
|
@@ -448,7 +450,7 @@ function baseTypeAdapter(type, linkGenerator, baseHeadingLevel) {
|
|
|
448
450
|
};
|
|
449
451
|
}
|
|
450
452
|
function enumTypeToEnumSource(enumType, linkGenerator, baseHeadingLevel = 1) {
|
|
451
|
-
return __spreadProps$
|
|
453
|
+
return __spreadProps$e(__spreadValues$e({
|
|
452
454
|
type: "enum"
|
|
453
455
|
}, baseTypeAdapter(enumType, linkGenerator, baseHeadingLevel)), {
|
|
454
456
|
values: {
|
|
@@ -456,7 +458,7 @@ function enumTypeToEnumSource(enumType, linkGenerator, baseHeadingLevel = 1) {
|
|
|
456
458
|
heading: "Values",
|
|
457
459
|
value: enumType.values.map((value) => {
|
|
458
460
|
var _a;
|
|
459
|
-
return __spreadProps$
|
|
461
|
+
return __spreadProps$e(__spreadValues$e({}, adaptDescribable((_a = value.docComment) == null ? void 0 : _a.descriptionLines, linkGenerator)), {
|
|
460
462
|
value: value.name
|
|
461
463
|
});
|
|
462
464
|
})
|
|
@@ -464,7 +466,7 @@ function enumTypeToEnumSource(enumType, linkGenerator, baseHeadingLevel = 1) {
|
|
|
464
466
|
});
|
|
465
467
|
}
|
|
466
468
|
function interfaceTypeToInterfaceSource(interfaceType, linkGenerator, baseHeadingLevel = 1) {
|
|
467
|
-
return __spreadProps$
|
|
469
|
+
return __spreadProps$e(__spreadValues$e({
|
|
468
470
|
type: "interface"
|
|
469
471
|
}, baseTypeAdapter(interfaceType, linkGenerator, baseHeadingLevel)), {
|
|
470
472
|
extends: interfaceType.extended_interfaces.map(linkGenerator),
|
|
@@ -476,7 +478,7 @@ function interfaceTypeToInterfaceSource(interfaceType, linkGenerator, baseHeadin
|
|
|
476
478
|
});
|
|
477
479
|
}
|
|
478
480
|
function classTypeToClassSource(classType, linkGenerator, baseHeadingLevel = 1) {
|
|
479
|
-
return __spreadProps$
|
|
481
|
+
return __spreadProps$e(__spreadValues$e({
|
|
480
482
|
type: "class"
|
|
481
483
|
}, baseTypeAdapter(classType, linkGenerator, baseHeadingLevel)), {
|
|
482
484
|
classModifier: classType.classModifier,
|
|
@@ -509,7 +511,7 @@ function classTypeToClassSource(classType, linkGenerator, baseHeadingLevel = 1)
|
|
|
509
511
|
headingLevel: baseHeadingLevel + 1,
|
|
510
512
|
heading: "Classes",
|
|
511
513
|
value: classType.classes.map(
|
|
512
|
-
(innerClass) => classTypeToClassSource(__spreadProps$
|
|
514
|
+
(innerClass) => classTypeToClassSource(__spreadProps$e(__spreadValues$e({}, innerClass), { inheritanceChain: [] }), linkGenerator, baseHeadingLevel + 2)
|
|
513
515
|
)
|
|
514
516
|
},
|
|
515
517
|
innerEnums: {
|
|
@@ -671,6 +673,45 @@ function parseApexMetadata(input) {
|
|
|
671
673
|
return map;
|
|
672
674
|
}
|
|
673
675
|
|
|
676
|
+
var __defProp$d = Object.defineProperty;
|
|
677
|
+
var __defProps$d = Object.defineProperties;
|
|
678
|
+
var __getOwnPropDescs$d = Object.getOwnPropertyDescriptors;
|
|
679
|
+
var __getOwnPropSymbols$d = Object.getOwnPropertySymbols;
|
|
680
|
+
var __hasOwnProp$d = Object.prototype.hasOwnProperty;
|
|
681
|
+
var __propIsEnum$d = Object.prototype.propertyIsEnumerable;
|
|
682
|
+
var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
683
|
+
var __spreadValues$d = (a, b) => {
|
|
684
|
+
for (var prop in b || (b = {}))
|
|
685
|
+
if (__hasOwnProp$d.call(b, prop))
|
|
686
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
687
|
+
if (__getOwnPropSymbols$d)
|
|
688
|
+
for (var prop of __getOwnPropSymbols$d(b)) {
|
|
689
|
+
if (__propIsEnum$d.call(b, prop))
|
|
690
|
+
__defNormalProp$d(a, prop, b[prop]);
|
|
691
|
+
}
|
|
692
|
+
return a;
|
|
693
|
+
};
|
|
694
|
+
var __spreadProps$d = (a, b) => __defProps$d(a, __getOwnPropDescs$d(b));
|
|
695
|
+
var __async$5 = (__this, __arguments, generator) => {
|
|
696
|
+
return new Promise((resolve, reject) => {
|
|
697
|
+
var fulfilled = (value) => {
|
|
698
|
+
try {
|
|
699
|
+
step(generator.next(value));
|
|
700
|
+
} catch (e) {
|
|
701
|
+
reject(e);
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
var rejected = (value) => {
|
|
705
|
+
try {
|
|
706
|
+
step(generator.throw(value));
|
|
707
|
+
} catch (e) {
|
|
708
|
+
reject(e);
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
712
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
713
|
+
});
|
|
714
|
+
};
|
|
674
715
|
class ReflectionErrors {
|
|
675
716
|
constructor(errors) {
|
|
676
717
|
this.errors = errors;
|
|
@@ -683,39 +724,51 @@ class ReflectionError {
|
|
|
683
724
|
this.message = message;
|
|
684
725
|
}
|
|
685
726
|
}
|
|
686
|
-
function
|
|
687
|
-
function
|
|
688
|
-
return
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
return
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
727
|
+
function reflectAsync(rawSource) {
|
|
728
|
+
return __async$5(this, null, function* () {
|
|
729
|
+
return new Promise((resolve, reject) => {
|
|
730
|
+
const result = apexReflection.reflect(rawSource);
|
|
731
|
+
if (result.typeMirror) {
|
|
732
|
+
return resolve(result.typeMirror);
|
|
733
|
+
} else if (result.error) {
|
|
734
|
+
return reject(result.error);
|
|
735
|
+
} else {
|
|
736
|
+
return reject(new Error("Unknown error"));
|
|
696
737
|
}
|
|
697
|
-
);
|
|
698
|
-
}
|
|
699
|
-
return _function.pipe(
|
|
700
|
-
reflectionResult,
|
|
701
|
-
reduceReflectionResultIntoSingleEither,
|
|
702
|
-
({ errors, parsedFiles }) => errors.length ? E__namespace.left(new ReflectionErrors(errors)) : E__namespace.right(parsedFiles)
|
|
703
|
-
);
|
|
738
|
+
});
|
|
739
|
+
});
|
|
704
740
|
}
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
741
|
+
function myPipeSeq(apexBundles) {
|
|
742
|
+
const semiGroupReflectionError = {
|
|
743
|
+
concat: (x, y) => new ReflectionErrors([...x.errors, ...y.errors])
|
|
744
|
+
};
|
|
745
|
+
const Ap = TE__namespace.getApplicativeTaskValidation(T__namespace.ApplyPar, semiGroupReflectionError);
|
|
746
|
+
return _function.pipe(apexBundles, A__namespace.traverse(Ap)(myPipe));
|
|
747
|
+
}
|
|
748
|
+
function myPipe(apexBundle) {
|
|
749
|
+
const convertToParsedFile = apply(toParsedFile, apexBundle.filePath);
|
|
750
|
+
const withMetadata = apply(addMetadata, apexBundle.metadataContent);
|
|
751
|
+
return _function.pipe(apexBundle, reflectAsTask, TE__namespace.map(convertToParsedFile), TE__namespace.map(withMetadata));
|
|
752
|
+
}
|
|
753
|
+
function reflectAsTask(apexBundle) {
|
|
754
|
+
return TE__namespace.tryCatch(
|
|
755
|
+
() => reflectAsync(apexBundle.content),
|
|
756
|
+
(error) => new ReflectionErrors([new ReflectionError(apexBundle.filePath, error.message)])
|
|
757
|
+
);
|
|
708
758
|
}
|
|
709
|
-
function
|
|
710
|
-
|
|
711
|
-
const result = apexReflection.reflect(input);
|
|
712
|
-
return result.error ? E__namespace.left(new ReflectionError(filePath, result.error.message)) : E__namespace.right({
|
|
759
|
+
function toParsedFile(filePath, typeMirror) {
|
|
760
|
+
return {
|
|
713
761
|
source: {
|
|
714
762
|
filePath,
|
|
715
|
-
name:
|
|
716
|
-
type:
|
|
763
|
+
name: typeMirror.name,
|
|
764
|
+
type: typeMirror.type_name
|
|
717
765
|
},
|
|
718
|
-
type:
|
|
766
|
+
type: typeMirror
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
function addMetadata(rawMetadataContent, parsedFile) {
|
|
770
|
+
return __spreadProps$d(__spreadValues$d({}, parsedFile), {
|
|
771
|
+
type: addFileMetadataToTypeAnnotation(parsedFile.type, rawMetadataContent)
|
|
719
772
|
});
|
|
720
773
|
}
|
|
721
774
|
function addFileMetadataToTypeAnnotation(type, metadata) {
|
|
@@ -1559,15 +1612,14 @@ function generateDocs(apexBundles, config) {
|
|
|
1559
1612
|
const sortTypeMembers = apply(sortMembers, config.sortMembersAlphabetically);
|
|
1560
1613
|
return _function.pipe(
|
|
1561
1614
|
apexBundles,
|
|
1562
|
-
|
|
1563
|
-
checkForReflectionErrors,
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
TE__namespace.fromEither,
|
|
1615
|
+
myPipeSeq,
|
|
1616
|
+
//checkForReflectionErrors,
|
|
1617
|
+
TE__namespace.map(filterOutOfScope),
|
|
1618
|
+
TE__namespace.map(addInheritedMembersToTypes),
|
|
1619
|
+
TE__namespace.map(addInheritanceChainToTypes),
|
|
1620
|
+
TE__namespace.map(sortTypeMembers),
|
|
1621
|
+
TE__namespace.bindTo("parsedFiles"),
|
|
1622
|
+
TE__namespace.bind("references", ({ parsedFiles }) => TE__namespace.right(convertToReferences(parsedFiles))),
|
|
1571
1623
|
TE__namespace.flatMap(({ parsedFiles, references }) => transformReferenceHook(config)({ references, parsedFiles })),
|
|
1572
1624
|
TE__namespace.map(({ parsedFiles, references }) => convertToRenderableBundle(parsedFiles, references)),
|
|
1573
1625
|
TE__namespace.map(convertToDocumentationBundleForTemplate),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.9",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
]
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@cparra/apex-reflection": "2.
|
|
61
|
+
"@cparra/apex-reflection": "2.12.1",
|
|
62
62
|
"@types/js-yaml": "^4.0.9",
|
|
63
63
|
"@types/yargs": "^17.0.32",
|
|
64
64
|
"chalk": "^4.1.2",
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
UnparsedSourceFile,
|
|
9
9
|
UserDefinedMarkdownConfig,
|
|
10
10
|
} from '../../core/shared/types';
|
|
11
|
-
import { ReflectionError } from '../../core/markdown/reflection/error-handling';
|
|
12
11
|
import { referenceGuideTemplate } from '../../core/markdown/templates/reference-guide';
|
|
13
12
|
import * as TE from 'fp-ts/TaskEither';
|
|
14
13
|
import { isSkip } from '../../core/shared/utils';
|
|
14
|
+
import { ReflectionError } from '../../core/markdown/reflection/reflect-source';
|
|
15
15
|
|
|
16
16
|
class FileWritingError {
|
|
17
17
|
readonly _tag = 'FileWritingError';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { pipe } from 'fp-ts/function';
|
|
2
|
-
import * as E from 'fp-ts/Either';
|
|
2
|
+
//import * as E from 'fp-ts/Either';
|
|
3
3
|
import * as TE from 'fp-ts/TaskEither';
|
|
4
4
|
import yaml from 'js-yaml';
|
|
5
5
|
|
|
@@ -20,8 +20,8 @@ import {
|
|
|
20
20
|
ParsedFile,
|
|
21
21
|
} from '../shared/types';
|
|
22
22
|
import { parsedFilesToRenderableBundle } from './adapters/renderable-bundle';
|
|
23
|
-
import { reflectSourceCode } from './reflection/reflect-source';
|
|
24
|
-
import { checkForReflectionErrors } from './reflection/error-handling';
|
|
23
|
+
import { myPipeSeq /*reflectSourceCode*/ } from './reflection/reflect-source';
|
|
24
|
+
//import { checkForReflectionErrors } from './reflection/error-handling';
|
|
25
25
|
import { addInheritanceChainToTypes } from './reflection/inheritance-chain-expanion';
|
|
26
26
|
import { addInheritedMembersToTypes } from './reflection/inherited-member-expansion';
|
|
27
27
|
import { convertToDocumentationBundle } from './adapters/renderable-to-page-data';
|
|
@@ -63,15 +63,14 @@ export function generateDocs(apexBundles: UnparsedSourceFile[], config: Markdown
|
|
|
63
63
|
|
|
64
64
|
return pipe(
|
|
65
65
|
apexBundles,
|
|
66
|
-
|
|
67
|
-
checkForReflectionErrors,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
TE.fromEither,
|
|
66
|
+
myPipeSeq,
|
|
67
|
+
//checkForReflectionErrors,
|
|
68
|
+
TE.map(filterOutOfScope),
|
|
69
|
+
TE.map(addInheritedMembersToTypes),
|
|
70
|
+
TE.map(addInheritanceChainToTypes),
|
|
71
|
+
TE.map(sortTypeMembers),
|
|
72
|
+
TE.bindTo('parsedFiles'),
|
|
73
|
+
TE.bind('references', ({ parsedFiles }) => TE.right(convertToReferences(parsedFiles))),
|
|
75
74
|
TE.flatMap(({ parsedFiles, references }) => transformReferenceHook(config)({ references, parsedFiles })),
|
|
76
75
|
TE.map(({ parsedFiles, references }) => convertToRenderableBundle(parsedFiles, references)),
|
|
77
76
|
TE.map(convertToDocumentationBundleForTemplate),
|
|
@@ -1,34 +1,111 @@
|
|
|
1
1
|
import { ParsedFile, UnparsedSourceFile } from '../../shared/types';
|
|
2
|
-
import * as E from 'fp-ts/Either';
|
|
2
|
+
//import * as E from 'fp-ts/Either';
|
|
3
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
4
|
+
import * as T from 'fp-ts/Task';
|
|
5
|
+
import * as A from 'fp-ts/lib/Array';
|
|
3
6
|
import { reflect as mirrorReflection, Type } from '@cparra/apex-reflection';
|
|
4
7
|
import { pipe } from 'fp-ts/function';
|
|
5
8
|
import * as O from 'fp-ts/Option';
|
|
6
9
|
import { parseApexMetadata } from '../../parse-apex-metadata';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
import { ParsingError } from '@cparra/apex-reflection/index';
|
|
11
|
+
import { apply } from '#utils/fp';
|
|
12
|
+
import { Semigroup } from 'fp-ts/Semigroup';
|
|
13
|
+
|
|
14
|
+
export class ReflectionErrors {
|
|
15
|
+
readonly _tag = 'ReflectionErrors';
|
|
16
|
+
|
|
17
|
+
constructor(public errors: ReflectionError[]) {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class ReflectionError {
|
|
21
|
+
constructor(
|
|
22
|
+
public file: string,
|
|
23
|
+
public message: string,
|
|
24
|
+
) {}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function reflectAsync(rawSource: string): Promise<Type> {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
const result = mirrorReflection(rawSource);
|
|
30
|
+
if (result.typeMirror) {
|
|
31
|
+
return resolve(result.typeMirror);
|
|
32
|
+
} else if (result.error) {
|
|
33
|
+
return reject(result.error);
|
|
34
|
+
} else {
|
|
35
|
+
return reject(new Error('Unknown error'));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function myPipeSeq(apexBundles: UnparsedSourceFile[]) {
|
|
41
|
+
const semiGroupReflectionError: Semigroup<ReflectionErrors> = {
|
|
42
|
+
concat: (x, y) => new ReflectionErrors([...x.errors, ...y.errors]),
|
|
43
|
+
};
|
|
44
|
+
const Ap = TE.getApplicativeTaskValidation(T.ApplyPar, semiGroupReflectionError);
|
|
45
|
+
|
|
46
|
+
return pipe(apexBundles, A.traverse(Ap)(myPipe));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function myPipe(apexBundle: UnparsedSourceFile): TE.TaskEither<ReflectionErrors, ParsedFile> {
|
|
50
|
+
const convertToParsedFile: (typeMirror: Type) => ParsedFile = apply(toParsedFile, apexBundle.filePath);
|
|
51
|
+
const withMetadata: (parsedFile: ParsedFile) => ParsedFile = apply(addMetadata, apexBundle.metadataContent);
|
|
52
|
+
|
|
53
|
+
return pipe(apexBundle, reflectAsTask, TE.map(convertToParsedFile), TE.map(withMetadata));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function reflectAsTask(apexBundle: UnparsedSourceFile): TE.TaskEither<ReflectionErrors, Type> {
|
|
57
|
+
return TE.tryCatch(
|
|
58
|
+
() => reflectAsync(apexBundle.content),
|
|
59
|
+
(error) =>
|
|
60
|
+
new ReflectionErrors([new ReflectionError(apexBundle.filePath, (error as ParsingError | Error).message)]),
|
|
61
|
+
);
|
|
26
62
|
}
|
|
27
63
|
|
|
64
|
+
function toParsedFile(filePath: string, typeMirror: Type): ParsedFile {
|
|
65
|
+
return {
|
|
66
|
+
source: {
|
|
67
|
+
filePath: filePath,
|
|
68
|
+
name: typeMirror.name,
|
|
69
|
+
type: typeMirror.type_name,
|
|
70
|
+
},
|
|
71
|
+
type: typeMirror,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function addMetadata(rawMetadataContent: string | null, parsedFile: ParsedFile) {
|
|
76
|
+
return {
|
|
77
|
+
...parsedFile,
|
|
78
|
+
type: addFileMetadataToTypeAnnotation(parsedFile.type, rawMetadataContent),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// TODO: Not Async below
|
|
83
|
+
|
|
84
|
+
// export function reflectSourceCode(apexBundles: UnparsedSourceFile[]) {
|
|
85
|
+
// return apexBundles.map(reflectSourceBody);
|
|
86
|
+
// }
|
|
87
|
+
//
|
|
88
|
+
// function reflectSourceBody(apexBundle: UnparsedSourceFile): E.Either<ReflectionError, ParsedFile> {
|
|
89
|
+
// const { filePath, content: input, metadataContent: metadata } = apexBundle;
|
|
90
|
+
// const result = mirrorReflection(input);
|
|
91
|
+
// return result.error
|
|
92
|
+
// ? E.left(new ReflectionError(filePath, result.error.message))
|
|
93
|
+
// : E.right({
|
|
94
|
+
// source: {
|
|
95
|
+
// filePath,
|
|
96
|
+
// name: result.typeMirror!.name,
|
|
97
|
+
// type: result.typeMirror!.type_name,
|
|
98
|
+
// },
|
|
99
|
+
// type: addFileMetadataToTypeAnnotation(result.typeMirror!, metadata),
|
|
100
|
+
// });
|
|
101
|
+
// }
|
|
102
|
+
|
|
28
103
|
function addFileMetadataToTypeAnnotation(type: Type, metadata: string | null): Type {
|
|
29
104
|
return pipe(
|
|
30
105
|
O.fromNullable(metadata),
|
|
31
106
|
O.map((metadata) => {
|
|
107
|
+
// TODO: Do we need to error check this, as it is coming from an external library?
|
|
108
|
+
// Or maybe what we do is return the Either from the parse-apex-metadata function?
|
|
32
109
|
const metadataParams = parseApexMetadata(metadata);
|
|
33
110
|
metadataParams.forEach((value, key) => {
|
|
34
111
|
const declaration = `${key}: ${value}`;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const defaults = {
|
|
4
|
-
targetGenerator: "markdown",
|
|
5
|
-
targetDir: "./docs/",
|
|
6
|
-
scope: ["global"],
|
|
7
|
-
defaultGroupName: "Miscellaneous",
|
|
8
|
-
includeMetadata: false,
|
|
9
|
-
sortMembersAlphabetically: false,
|
|
10
|
-
documentationRootDir: ""
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
exports.defaults = defaults;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import * as E from 'fp-ts/Either';
|
|
2
|
-
import { ParsedFile } from '../../shared/types';
|
|
3
|
-
import { pipe } from 'fp-ts/function';
|
|
4
|
-
|
|
5
|
-
export class ReflectionErrors {
|
|
6
|
-
readonly _tag = 'ReflectionErrors';
|
|
7
|
-
constructor(public errors: ReflectionError[]) {}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class ReflectionError {
|
|
11
|
-
constructor(
|
|
12
|
-
public file: string,
|
|
13
|
-
public message: string,
|
|
14
|
-
) {}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function checkForReflectionErrors(reflectionResult: E.Either<ReflectionError, ParsedFile>[]) {
|
|
18
|
-
function reduceReflectionResultIntoSingleEither(results: E.Either<ReflectionError, ParsedFile>[]): {
|
|
19
|
-
errors: ReflectionError[];
|
|
20
|
-
parsedFiles: ParsedFile[];
|
|
21
|
-
} {
|
|
22
|
-
return results.reduce<{ errors: ReflectionError[]; parsedFiles: ParsedFile[] }>(
|
|
23
|
-
(acc, result) => {
|
|
24
|
-
E.isLeft(result) ? acc.errors.push(result.left) : acc.parsedFiles.push(result.right);
|
|
25
|
-
return acc;
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
errors: [],
|
|
29
|
-
parsedFiles: [],
|
|
30
|
-
},
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return pipe(reflectionResult, reduceReflectionResultIntoSingleEither, ({ errors, parsedFiles }) =>
|
|
35
|
-
errors.length ? E.left(new ReflectionErrors(errors)) : E.right(parsedFiles),
|
|
36
|
-
);
|
|
37
|
-
}
|