@cparra/apexdocs 2.23.0 → 2.25.0-alpha.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.
- package/.github/workflows/ci.yaml +22 -0
- package/README.md +40 -16
- package/examples/plain-markdown/.forceignore +12 -0
- package/examples/plain-markdown/README.md +301 -0
- package/examples/plain-markdown/config/project-scratch-def.json +5 -0
- package/examples/plain-markdown/force-app/classes/BaseClass.cls +3 -0
- package/examples/plain-markdown/force-app/classes/ParentInterface.cls +3 -0
- package/examples/plain-markdown/force-app/classes/ReferencedEnum.cls +3 -0
- package/examples/plain-markdown/force-app/classes/SampleClass.cls +35 -0
- package/examples/plain-markdown/force-app/classes/SampleEnum.cls +30 -0
- package/examples/plain-markdown/force-app/classes/SampleException.cls +1 -0
- package/examples/plain-markdown/force-app/classes/SampleInterface.cls +46 -0
- package/examples/plain-markdown/package-lock.json +665 -0
- package/examples/plain-markdown/package.json +24 -0
- package/examples/plain-markdown/sfdx-project.json +12 -0
- package/examples/plain-markdown/template.md +3 -0
- package/lib/adapters/apex-types.d.ts +5 -0
- package/lib/adapters/apex-types.js +34 -0
- package/lib/adapters/apex-types.js.map +1 -0
- package/lib/adapters/documentables.d.ts +6 -0
- package/lib/adapters/documentables.js +41 -0
- package/lib/adapters/documentables.js.map +1 -0
- package/lib/adapters/fields-and-properties.d.ts +3 -0
- package/lib/adapters/fields-and-properties.js +10 -0
- package/lib/adapters/fields-and-properties.js.map +1 -0
- package/lib/adapters/methods-and-constructors.d.ts +4 -0
- package/lib/adapters/methods-and-constructors.js +49 -0
- package/lib/adapters/methods-and-constructors.js.map +1 -0
- package/lib/adapters/references.d.ts +5 -0
- package/lib/adapters/references.js +82 -0
- package/lib/adapters/references.js.map +1 -0
- package/lib/adapters/type-utils.d.ts +2 -0
- package/lib/adapters/type-utils.js +8 -0
- package/lib/adapters/type-utils.js.map +1 -0
- package/lib/application/Apexdocs.js +5 -2
- package/lib/application/Apexdocs.js.map +1 -1
- package/lib/cli/generate.js +28 -2
- package/lib/cli/generate.js.map +1 -1
- package/lib/model/manifest.d.ts +1 -1
- package/lib/model/manifest.js +2 -2
- package/lib/model/manifest.js.map +1 -1
- package/lib/model/markdown-file.js +5 -2
- package/lib/model/markdown-file.js.map +1 -1
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +4 -1
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -1
- package/lib/model/markdown-home-file.js +4 -1
- package/lib/model/markdown-home-file.js.map +1 -1
- package/lib/model/markdown-type-file.js +4 -1
- package/lib/model/markdown-type-file.js.map +1 -1
- package/lib/model/openapi/open-api-types.d.ts +2 -2
- package/lib/service/apex-file-reader.js +4 -1
- package/lib/service/apex-file-reader.js.map +1 -1
- package/lib/service/file-system.js +25 -2
- package/lib/service/file-system.js.map +1 -1
- package/lib/service/file-writer.js +25 -2
- package/lib/service/file-writer.js.map +1 -1
- package/lib/service/manifest-factory.js +4 -1
- package/lib/service/manifest-factory.js.map +1 -1
- package/lib/service/parser.js +4 -1
- package/lib/service/parser.js.map +1 -1
- package/lib/settings.d.ts +6 -0
- package/lib/settings.js +11 -0
- package/lib/settings.js.map +1 -1
- package/lib/templating/compile.d.ts +7 -0
- package/lib/templating/compile.js +98 -0
- package/lib/templating/compile.js.map +1 -0
- package/lib/templating/helpers.d.ts +2 -0
- package/lib/templating/helpers.js +18 -0
- package/lib/templating/helpers.js.map +1 -0
- package/lib/test-helpers/FieldMirrorBuilder.d.ts +1 -1
- package/lib/test-helpers/InterfaceMirrorBuilder.d.ts +16 -0
- package/lib/test-helpers/InterfaceMirrorBuilder.js +43 -0
- package/lib/test-helpers/InterfaceMirrorBuilder.js.map +1 -0
- package/lib/test-helpers/MethodMirrorBuilder.d.ts +20 -1
- package/lib/test-helpers/MethodMirrorBuilder.js +41 -6
- package/lib/test-helpers/MethodMirrorBuilder.js.map +1 -1
- package/lib/transpiler/factory.js +4 -1
- package/lib/transpiler/factory.js.map +1 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +3 -0
- package/lib/transpiler/markdown/class-file-generatorHelper.js +21 -2
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
- package/lib/transpiler/markdown/markdown-transpiler-base.js +4 -1
- package/lib/transpiler/markdown/markdown-transpiler-base.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/class-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/class-template.js +36 -0
- package/lib/transpiler/markdown/plain-markdown/class-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js +39 -0
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js +25 -0
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/enum-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/enum-template.js +15 -0
- package/lib/transpiler/markdown/plain-markdown/enum-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js +24 -0
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.js +20 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js +49 -0
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +7 -0
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +108 -0
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js +31 -0
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js.map +1 -0
- package/lib/transpiler/openapi/open-api-docs-processor.js +4 -1
- package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -1
- package/lib/transpiler/openapi/parsers/Builder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/MethodParser.js +25 -2
- package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +25 -2
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -1
- package/lib/transpiler/transpiler.js +4 -1
- package/lib/transpiler/transpiler.js.map +1 -1
- package/lib/util/error-logger.js +4 -4
- package/lib/util/error-logger.js.map +1 -1
- package/lib/util/logger.js +10 -7
- package/lib/util/logger.js.map +1 -1
- package/package.json +16 -15
- package/src/adapters/__tests__/interface-adapter.spec.ts +76 -0
- package/src/adapters/__tests__/references.spec.ts +115 -0
- package/src/adapters/apex-types.ts +67 -0
- package/src/adapters/documentables.ts +58 -0
- package/src/adapters/fields-and-properties.ts +14 -0
- package/src/adapters/methods-and-constructors.ts +78 -0
- package/src/adapters/references.ts +113 -0
- package/src/adapters/type-utils.ts +5 -0
- package/src/adapters/types.d.ts +8 -0
- package/src/cli/generate.ts +3 -0
- package/src/model/__tests__/manifest.spec.ts +1 -0
- package/src/model/manifest.ts +3 -3
- package/src/model/markdown-file.ts +1 -1
- package/src/model/openapi/open-api-types.ts +2 -2
- package/src/service/__tests__/apex-file-reader.spec.ts +4 -4
- package/src/service/__tests__/manifest-factory.spec.ts +1 -2
- package/src/settings.ts +15 -0
- package/src/templating/__tests__/compile.spec.ts +741 -0
- package/src/templating/compile.ts +187 -0
- package/src/templating/helpers.ts +14 -0
- package/src/templating/types.d.ts +104 -0
- package/src/test-helpers/FieldMirrorBuilder.ts +1 -1
- package/src/test-helpers/InterfaceMirrorBuilder.ts +44 -0
- package/src/test-helpers/MethodMirrorBuilder.ts +46 -6
- package/src/transpiler/markdown/class-file-generatorHelper.ts +22 -2
- package/src/transpiler/markdown/plain-markdown/class-template.ts +32 -0
- package/src/transpiler/markdown/plain-markdown/constructors-partial-template.ts +35 -0
- package/src/transpiler/markdown/plain-markdown/documentable-partial-template.ts +21 -0
- package/src/transpiler/markdown/plain-markdown/enum-template.ts +11 -0
- package/src/transpiler/markdown/plain-markdown/fieldsPartialTemplate.ts +20 -0
- package/src/transpiler/markdown/plain-markdown/interface-template.ts +16 -0
- package/src/transpiler/markdown/plain-markdown/methods-partial-template.ts +45 -0
- package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +122 -0
- package/src/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.ts +27 -0
- package/src/transpiler/openapi/parsers/Builder.ts +1 -1
- package/src/transpiler/openapi/parsers/MethodParser.ts +1 -1
- package/src/transpiler/openapi/parsers/ReferenceBuilder.ts +1 -1
- package/src/util/error-logger.ts +4 -4
- package/src/util/logger.ts +3 -3
- package/tsconfig.json +1 -0
- package/lib/model/manifest-diff.d.ts +0 -27
- package/lib/model/manifest-diff.js +0 -69
- package/lib/model/manifest-diff.js.map +0 -1
- package/src/model/__tests__/manifest-diff.spec.ts +0 -139
- package/src/model/manifest-diff.ts +0 -94
- /package/docs/{README.md → __old/README.md} +0 -0
- /package/docs/{index.html → __old/index.html} +0 -0
- /package/docs/{restapi.json → __old/restapi.json} +0 -0
- /package/docs/{types → __old/types}/Classes/nspc.AnotherInterface.md +0 -0
- /package/docs/{types → __old/types}/Classes/nspc.ChildClass.md +0 -0
- /package/docs/{types → __old/types}/Main/nspc.GroupedClass.md +0 -0
- /package/docs/{types → __old/types}/Main/nspc.SampleClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.EscapedAnnotations.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.GrandparentClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.InterfaceWithInheritance.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.MemberGrouping.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.ParentClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference1.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference2.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference3.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference4.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference5.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference6.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference7.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleClassWithoutModifier.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleRestResource.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleRestResourceWithInnerClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleRestResourceWithoutApexDocs.md +0 -0
- /package/docs/{types → __old/types}/README.md +0 -0
- /package/docs/{types → __old/types}/Sample-Interfaces/nspc.SampleInterface.md +0 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ConstructorMirror, MethodMirror, ParameterMirror, ThrowsAnnotation } from '@cparra/apex-reflection';
|
|
2
|
+
import { ConstructorSource, MethodSource } from '../templating/types';
|
|
3
|
+
import { MethodMirrorWithInheritance } from '../model/inheritance';
|
|
4
|
+
import { adaptDescribable, adaptDocumentable } from './documentables';
|
|
5
|
+
import { linkFromTypeNameGenerator } from './references';
|
|
6
|
+
import { Documentable } from './types';
|
|
7
|
+
|
|
8
|
+
export function adaptMethod(method: MethodMirror): MethodSource {
|
|
9
|
+
function buildTitle(method: MethodMirrorWithInheritance): string {
|
|
10
|
+
const { name, parameters } = method;
|
|
11
|
+
const parametersString = parameters.map((param) => param.name).join(', ');
|
|
12
|
+
return `${name}(${parametersString})`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function buildSignature(method: MethodMirrorWithInheritance): string {
|
|
16
|
+
const { access_modifier, typeReference, name, memberModifiers } = method;
|
|
17
|
+
const parameters = method.parameters
|
|
18
|
+
.map((param) => `${param.typeReference.rawDeclaration} ${param.name}`)
|
|
19
|
+
.join(', ');
|
|
20
|
+
const members = memberModifiers.length > 0 ? `${memberModifiers.join(' ')} ` : '';
|
|
21
|
+
return `${access_modifier} ${members}${typeReference.rawDeclaration} ${name}(${parameters})`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
...adaptDocumentable(method),
|
|
26
|
+
title: buildTitle(method as MethodMirrorWithInheritance),
|
|
27
|
+
signature: buildSignature(method as MethodMirrorWithInheritance),
|
|
28
|
+
returnType: {
|
|
29
|
+
...adaptDescribable(method.docComment?.returnAnnotation?.bodyLines),
|
|
30
|
+
type: linkFromTypeNameGenerator(method.typeReference.rawDeclaration),
|
|
31
|
+
},
|
|
32
|
+
throws: method.docComment?.throwsAnnotations.map((thrown) => mapThrows(thrown)),
|
|
33
|
+
parameters: method.parameters.map((param) => mapParameters(method, param)),
|
|
34
|
+
inherited: (method as MethodMirrorWithInheritance).inherited,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function adaptConstructor(typeName: string, constructor: ConstructorMirror): ConstructorSource {
|
|
39
|
+
function buildTitle(name: string, constructor: ConstructorMirror): string {
|
|
40
|
+
const { parameters } = constructor;
|
|
41
|
+
const parametersString = parameters.map((param) => param.name).join(', ');
|
|
42
|
+
return `${name}(${parametersString})`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function buildSignature(name: string, constructor: ConstructorMirror): string {
|
|
46
|
+
const { access_modifier } = constructor;
|
|
47
|
+
const parameters = constructor.parameters
|
|
48
|
+
.map((param) => `${param.typeReference.rawDeclaration} ${param.name}`)
|
|
49
|
+
.join(', ');
|
|
50
|
+
return `${access_modifier} ${name}(${parameters})`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
...adaptDocumentable(constructor),
|
|
55
|
+
title: buildTitle(typeName, constructor),
|
|
56
|
+
signature: buildSignature(typeName, constructor),
|
|
57
|
+
parameters: constructor.parameters.map((param) => mapParameters(constructor, param)),
|
|
58
|
+
throws: constructor.docComment?.throwsAnnotations.map((thrown) => mapThrows(thrown)),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function mapParameters(documentable: Documentable, param: ParameterMirror) {
|
|
63
|
+
const paramAnnotation = documentable.docComment?.paramAnnotations.find(
|
|
64
|
+
(pa) => pa.paramName.toLowerCase() === param.name.toLowerCase(),
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
...adaptDescribable(paramAnnotation?.bodyLines),
|
|
68
|
+
name: param.name,
|
|
69
|
+
type: linkFromTypeNameGenerator(param.typeReference.rawDeclaration),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function mapThrows(thrown: ThrowsAnnotation) {
|
|
74
|
+
return {
|
|
75
|
+
...adaptDescribable(thrown.bodyLines),
|
|
76
|
+
type: linkFromTypeNameGenerator(thrown.exceptionName),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import ClassFileGeneratorHelper from '../transpiler/markdown/class-file-generatorHelper';
|
|
2
|
+
import { Link, RenderableContent, StringOrLink } from '../templating/types';
|
|
3
|
+
|
|
4
|
+
export type GetRenderableContentByTypeName = (typeName: string) => StringOrLink;
|
|
5
|
+
|
|
6
|
+
export const linkFromTypeNameGenerator: GetRenderableContentByTypeName =
|
|
7
|
+
ClassFileGeneratorHelper.getRenderableLinkByTypeName;
|
|
8
|
+
|
|
9
|
+
function defaultGetEmailByReference(email: string): Link {
|
|
10
|
+
return {
|
|
11
|
+
title: email,
|
|
12
|
+
url: `mailto:${email}`,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function replaceInlineReferences(
|
|
17
|
+
text: string,
|
|
18
|
+
linkReplacer: GetRenderableContentByTypeName = linkFromTypeNameGenerator,
|
|
19
|
+
emailReplacer: GetRenderableContentByTypeName = defaultGetEmailByReference,
|
|
20
|
+
): RenderableContent[] {
|
|
21
|
+
return replaceInlineEmails(replaceInlineLinks([text], linkReplacer), emailReplacer);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function replaceInlineLinks(
|
|
25
|
+
renderableContents: RenderableContent[],
|
|
26
|
+
getLinkByTypeName: GetRenderableContentByTypeName,
|
|
27
|
+
): RenderableContent[] {
|
|
28
|
+
return renderableContents.flatMap((renderableContent) => inlineLinkContent(renderableContent, getLinkByTypeName));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function inlineLinkContent(
|
|
32
|
+
renderableContent: RenderableContent,
|
|
33
|
+
getLinkByTypeName: GetRenderableContentByTypeName,
|
|
34
|
+
): RenderableContent[] {
|
|
35
|
+
if (typeof renderableContent !== 'string') {
|
|
36
|
+
return [renderableContent];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const text = renderableContent;
|
|
40
|
+
|
|
41
|
+
// Matches either `<<ClassName>>` or `{@link ClassName}`
|
|
42
|
+
const linkFormatRegEx = '{@link (.*?)}|<<([^>]+)>>';
|
|
43
|
+
const matches = match(linkFormatRegEx, text);
|
|
44
|
+
return createRenderableContents(matches, text, getLinkByTypeName);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function replaceInlineEmails(
|
|
48
|
+
renderableContents: RenderableContent[],
|
|
49
|
+
getLinkByTypeName: GetRenderableContentByTypeName,
|
|
50
|
+
): RenderableContent[] {
|
|
51
|
+
return renderableContents.flatMap((renderableContent) => inlineEmailContent(renderableContent, getLinkByTypeName));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function inlineEmailContent(
|
|
55
|
+
renderableContent: RenderableContent,
|
|
56
|
+
getLinkByTypeName: GetRenderableContentByTypeName,
|
|
57
|
+
): RenderableContent[] {
|
|
58
|
+
if (typeof renderableContent !== 'string') {
|
|
59
|
+
return [renderableContent];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const text = renderableContent;
|
|
63
|
+
|
|
64
|
+
// Parsing references using the format '{@email email}'
|
|
65
|
+
const linkFormatRegEx = '{@email (.*?)}';
|
|
66
|
+
const matches = match(linkFormatRegEx, text);
|
|
67
|
+
return createRenderableContents(matches, text, getLinkByTypeName);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function match(regex: string, text: string) {
|
|
71
|
+
const expression = new RegExp(regex, 'gi');
|
|
72
|
+
let match;
|
|
73
|
+
const matches = [];
|
|
74
|
+
|
|
75
|
+
do {
|
|
76
|
+
match = expression.exec(text);
|
|
77
|
+
if (match) {
|
|
78
|
+
matches.push(match);
|
|
79
|
+
}
|
|
80
|
+
} while (match);
|
|
81
|
+
|
|
82
|
+
return matches;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function createRenderableContents(matches: RegExpExecArray[], text: string, linker: GetRenderableContentByTypeName) {
|
|
86
|
+
if (matches.length === 0) {
|
|
87
|
+
return [text];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const result: RenderableContent[] = [];
|
|
91
|
+
let lastIndex = 0;
|
|
92
|
+
for (const match of matches) {
|
|
93
|
+
const index = match.index;
|
|
94
|
+
const length = match[0].length;
|
|
95
|
+
|
|
96
|
+
// loop through the matches (skip the first one, which is the full match)
|
|
97
|
+
// until we find the first capturing group that has a value
|
|
98
|
+
const capturedGroup = match.slice(1).find((group) => group);
|
|
99
|
+
if (!capturedGroup) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
result.push(text.slice(lastIndex, index));
|
|
103
|
+
result.push(linker(capturedGroup));
|
|
104
|
+
|
|
105
|
+
lastIndex = index + length;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (lastIndex < text.length) {
|
|
109
|
+
result.push(text.slice(lastIndex));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return result;
|
|
113
|
+
}
|
package/src/cli/generate.ts
CHANGED
|
@@ -126,6 +126,9 @@ result.then((config) => {
|
|
|
126
126
|
onAfterProcess: config?.config?.onAfterProcess,
|
|
127
127
|
onBeforeFileWrite: config?.config?.onBeforeFileWrite,
|
|
128
128
|
frontMatterHeader: config?.config?.frontMatterHeader,
|
|
129
|
+
singleFile: config?.config?.singleFile,
|
|
130
|
+
fileName: config?.config?.fileName,
|
|
131
|
+
templateFilePath: config?.config?.templateFilePath,
|
|
129
132
|
});
|
|
130
133
|
|
|
131
134
|
try {
|
package/src/model/manifest.ts
CHANGED
|
@@ -38,7 +38,7 @@ export default class Manifest {
|
|
|
38
38
|
properties: this.filterAccessibleModifier(currentClass.properties, modifiers),
|
|
39
39
|
fields: this.filterAccessibleModifier(currentClass.fields, modifiers),
|
|
40
40
|
constructors: this.filterAccessibleModifier(currentClass.constructors, modifiers),
|
|
41
|
-
};
|
|
41
|
+
} as ClassMirror;
|
|
42
42
|
|
|
43
43
|
if (!this.isForInnerTypes) {
|
|
44
44
|
filteredClass = {
|
|
@@ -57,8 +57,8 @@ export default class Manifest {
|
|
|
57
57
|
return typesToReturn;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
filterAccessibleModifier(
|
|
61
|
-
return
|
|
60
|
+
filterAccessibleModifier(accessAndDocAware: AccessAndDocAware[], modifiers: string[]) {
|
|
61
|
+
return accessAndDocAware.filter((currentType) => {
|
|
62
62
|
const hasIgnoreDocAnnotation = currentType.docComment?.annotations.some(
|
|
63
63
|
(annotation: DocCommentAnnotation) => annotation.name === 'ignore',
|
|
64
64
|
);
|
|
@@ -56,14 +56,14 @@ export type RequestBodyContent = {
|
|
|
56
56
|
|
|
57
57
|
export type MediaTypeObject = {
|
|
58
58
|
schema?: SchemaObject;
|
|
59
|
-
example?:
|
|
59
|
+
example?: unknown;
|
|
60
60
|
examples?: { [index: string]: ExampleObject };
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
export type ExampleObject = {
|
|
64
64
|
summary?: string;
|
|
65
65
|
description?: string;
|
|
66
|
-
value?:
|
|
66
|
+
value?: unknown;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
// Responses
|
|
@@ -45,16 +45,16 @@ describe('File Reader', () => {
|
|
|
45
45
|
|
|
46
46
|
it('returns an empty list when there are no Apex files in the directory', () => {
|
|
47
47
|
const result = ApexFileReader.processFiles({
|
|
48
|
-
isDirectory(
|
|
48
|
+
isDirectory(): boolean {
|
|
49
49
|
return false;
|
|
50
50
|
},
|
|
51
|
-
joinPath(
|
|
51
|
+
joinPath(): string {
|
|
52
52
|
return '';
|
|
53
53
|
},
|
|
54
|
-
readDirectory(
|
|
54
|
+
readDirectory(): string[] {
|
|
55
55
|
return ['SomeFile.md'];
|
|
56
56
|
},
|
|
57
|
-
readFile(
|
|
57
|
+
readFile(): string {
|
|
58
58
|
return '';
|
|
59
59
|
},
|
|
60
60
|
exists(): boolean {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createManifest } from '../manifest-factory';
|
|
2
2
|
import { Type } from '@cparra/apex-reflection';
|
|
3
3
|
import { TypeParser } from '../parser';
|
|
4
|
-
import ApexBundle from '../../model/apex-bundle';
|
|
5
4
|
|
|
6
5
|
class TestParser implements TypeParser {
|
|
7
6
|
parse(): Type[] {
|
|
@@ -10,7 +9,7 @@ class TestParser implements TypeParser {
|
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
it('creates a manifest from the result of a type parser', () => {
|
|
13
|
-
const manifest = createManifest(new TestParser(), (
|
|
12
|
+
const manifest = createManifest(new TestParser(), () => {
|
|
14
13
|
return {};
|
|
15
14
|
});
|
|
16
15
|
expect(manifest.types.length).toBe(0);
|
package/src/settings.ts
CHANGED
|
@@ -40,6 +40,9 @@ export interface SettingsConfig {
|
|
|
40
40
|
onAfterProcess?: (files: TargetFile[]) => void;
|
|
41
41
|
onBeforeFileWrite?: (file: TargetFile) => TargetFile;
|
|
42
42
|
frontMatterHeader?: (file: TargetType) => string[];
|
|
43
|
+
singleFile?: boolean;
|
|
44
|
+
fileName?: string;
|
|
45
|
+
templateFilePath?: string;
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
export class Settings {
|
|
@@ -144,4 +147,16 @@ export class Settings {
|
|
|
144
147
|
}
|
|
145
148
|
return [];
|
|
146
149
|
}
|
|
150
|
+
|
|
151
|
+
public shouldOutputSingleFile(): boolean {
|
|
152
|
+
return this.config.singleFile ?? false;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public getSingleFileName(): string {
|
|
156
|
+
return this.config.fileName ?? 'README';
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
public getTemplateFilePath(): string | undefined {
|
|
160
|
+
return this.config.templateFilePath;
|
|
161
|
+
}
|
|
147
162
|
}
|