@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,187 @@
|
|
|
1
|
+
import Handlebars from 'handlebars';
|
|
2
|
+
import {
|
|
3
|
+
EnumSource,
|
|
4
|
+
ConvertRenderableContentsToString,
|
|
5
|
+
InterfaceSource,
|
|
6
|
+
ClassSource,
|
|
7
|
+
MethodSource,
|
|
8
|
+
RenderableContent,
|
|
9
|
+
DocumentableSource,
|
|
10
|
+
} from './types';
|
|
11
|
+
import { namespace, splitAndCapitalize } from './helpers';
|
|
12
|
+
import { typeLevelApexDocPartialTemplate } from '../transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template';
|
|
13
|
+
import { methodsPartialTemplate } from '../transpiler/markdown/plain-markdown/methods-partial-template';
|
|
14
|
+
import { constructorsPartialTemplate } from '../transpiler/markdown/plain-markdown/constructors-partial-template';
|
|
15
|
+
import { fieldsPartialTemplate } from '../transpiler/markdown/plain-markdown/fieldsPartialTemplate';
|
|
16
|
+
import { documentablePartialTemplate } from '../transpiler/markdown/plain-markdown/documentable-partial-template';
|
|
17
|
+
|
|
18
|
+
type CompileOptions = {
|
|
19
|
+
renderableContentConverter: ConvertRenderableContentsToString;
|
|
20
|
+
codeBlockConverter: (language: string, lines: string[]) => string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function compile(template: string, source: EnumSource | InterfaceSource | ClassSource, options: CompileOptions) {
|
|
24
|
+
Handlebars.registerPartial('typeLevelApexDocPartialTemplate', typeLevelApexDocPartialTemplate);
|
|
25
|
+
Handlebars.registerPartial('documentablePartialTemplate', documentablePartialTemplate);
|
|
26
|
+
Handlebars.registerPartial('methodsPartialTemplate', methodsPartialTemplate);
|
|
27
|
+
Handlebars.registerPartial('constructorsPartialTemplate', constructorsPartialTemplate);
|
|
28
|
+
Handlebars.registerPartial('fieldsPartialTemplate', fieldsPartialTemplate);
|
|
29
|
+
|
|
30
|
+
Handlebars.registerHelper('splitAndCapitalize', splitAndCapitalize);
|
|
31
|
+
|
|
32
|
+
const prepared = { ...prepare(source, options), namespace: namespace() };
|
|
33
|
+
const compiled = Handlebars.compile(template);
|
|
34
|
+
return (
|
|
35
|
+
compiled(prepared)
|
|
36
|
+
.trim()
|
|
37
|
+
// clean up extra newlines
|
|
38
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function prepare(
|
|
43
|
+
source: EnumSource | InterfaceSource | ClassSource,
|
|
44
|
+
{ renderableContentConverter, codeBlockConverter }: CompileOptions,
|
|
45
|
+
) {
|
|
46
|
+
const base = {
|
|
47
|
+
...source,
|
|
48
|
+
...prepareDocumentable(source, renderableContentConverter, codeBlockConverter),
|
|
49
|
+
...prepareBaseType(source, renderableContentConverter),
|
|
50
|
+
};
|
|
51
|
+
if (isEnumSource(source)) {
|
|
52
|
+
return {
|
|
53
|
+
...base,
|
|
54
|
+
...prepareEnum(source, renderableContentConverter),
|
|
55
|
+
};
|
|
56
|
+
} else if (isInterfaceSource(source)) {
|
|
57
|
+
return {
|
|
58
|
+
...base,
|
|
59
|
+
...prepareInterface(source, renderableContentConverter, codeBlockConverter),
|
|
60
|
+
};
|
|
61
|
+
} else {
|
|
62
|
+
return {
|
|
63
|
+
...base,
|
|
64
|
+
...prepareClass(source, renderableContentConverter, codeBlockConverter),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function prepareDocumentable(
|
|
70
|
+
source: DocumentableSource,
|
|
71
|
+
renderableContentConverter: ConvertRenderableContentsToString,
|
|
72
|
+
codeBlockConverter: (language: string, lines: string[]) => string,
|
|
73
|
+
) {
|
|
74
|
+
return {
|
|
75
|
+
description: renderableContentConverter(source.description),
|
|
76
|
+
mermaid: source.mermaid ? codeBlockConverter('mermaid', source.mermaid) : undefined,
|
|
77
|
+
example: source.example ? codeBlockConverter('apex', source.example) : undefined,
|
|
78
|
+
customTags: source.customTags?.map((tag) => ({
|
|
79
|
+
name: tag.name,
|
|
80
|
+
value: renderableContentConverter(tag.description),
|
|
81
|
+
})),
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function prepareBaseType(
|
|
86
|
+
source: EnumSource | InterfaceSource | ClassSource,
|
|
87
|
+
renderableContentConverter: ConvertRenderableContentsToString,
|
|
88
|
+
) {
|
|
89
|
+
return {
|
|
90
|
+
sees: source.sees?.map((see) => renderableContentConverter([see])),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function prepareEnum(source: EnumSource, renderableContentConverter: ConvertRenderableContentsToString) {
|
|
95
|
+
return {
|
|
96
|
+
values: source.values.map((value) => ({
|
|
97
|
+
value: value.value,
|
|
98
|
+
description: renderableContentConverter(value.description),
|
|
99
|
+
})),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function prepareInterface(
|
|
104
|
+
source: InterfaceSource,
|
|
105
|
+
renderableContentConverter: ConvertRenderableContentsToString,
|
|
106
|
+
codeBlockConverter: (language: string, lines: string[]) => string,
|
|
107
|
+
) {
|
|
108
|
+
return {
|
|
109
|
+
extends: source.extends?.map((ext) => renderableContentConverter([ext])),
|
|
110
|
+
methods: source.methods?.map((method) => mapMethod(method, renderableContentConverter, codeBlockConverter)),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function prepareClass(
|
|
115
|
+
source: ClassSource,
|
|
116
|
+
renderableContentConverter: ConvertRenderableContentsToString,
|
|
117
|
+
codeBlockConverter: (language: string, lines: string[]) => string,
|
|
118
|
+
) {
|
|
119
|
+
return {
|
|
120
|
+
implements: source.implements?.map((impl) => renderableContentConverter([impl])),
|
|
121
|
+
extends: source.extends ? renderableContentConverter([source.extends]) : undefined,
|
|
122
|
+
constructors: source.constructors?.map((constructor) =>
|
|
123
|
+
mapConstructor(constructor, renderableContentConverter, codeBlockConverter),
|
|
124
|
+
),
|
|
125
|
+
methods: source.methods?.map((method) => mapMethod(method, renderableContentConverter, codeBlockConverter)),
|
|
126
|
+
fields: source.fields?.map((field) => ({
|
|
127
|
+
...field,
|
|
128
|
+
...prepareDocumentable(field, renderableContentConverter, codeBlockConverter),
|
|
129
|
+
type: renderableContentConverter([field.type]),
|
|
130
|
+
})),
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function mapMethod(
|
|
135
|
+
method: MethodSource,
|
|
136
|
+
renderableContentConverter: (content?: RenderableContent[]) => string,
|
|
137
|
+
codeBlockConverter: (language: string, lines: string[]) => string,
|
|
138
|
+
) {
|
|
139
|
+
return {
|
|
140
|
+
...method,
|
|
141
|
+
...prepareDocumentable(method, renderableContentConverter, codeBlockConverter),
|
|
142
|
+
returnType: {
|
|
143
|
+
...method,
|
|
144
|
+
type: method.returnType?.type ? renderableContentConverter([method.returnType.type]) : undefined,
|
|
145
|
+
description: renderableContentConverter(method.returnType?.description),
|
|
146
|
+
},
|
|
147
|
+
throws: method.throws?.map((thrown) => ({
|
|
148
|
+
...thrown,
|
|
149
|
+
type: renderableContentConverter([thrown.type]),
|
|
150
|
+
description: renderableContentConverter(thrown.description),
|
|
151
|
+
})),
|
|
152
|
+
parameters: method.parameters?.map((param) => ({
|
|
153
|
+
...param,
|
|
154
|
+
type: renderableContentConverter([param.type]),
|
|
155
|
+
description: renderableContentConverter(param.description),
|
|
156
|
+
})),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function mapConstructor(
|
|
161
|
+
constructor: MethodSource,
|
|
162
|
+
renderableContentConverter: (content?: RenderableContent[]) => string,
|
|
163
|
+
codeBlockConverter: (language: string, lines: string[]) => string,
|
|
164
|
+
) {
|
|
165
|
+
return {
|
|
166
|
+
...constructor,
|
|
167
|
+
...prepareDocumentable(constructor, renderableContentConverter, codeBlockConverter),
|
|
168
|
+
parameters: constructor.parameters?.map((param) => ({
|
|
169
|
+
...param,
|
|
170
|
+
type: renderableContentConverter([param.type]),
|
|
171
|
+
description: renderableContentConverter(param.description),
|
|
172
|
+
})),
|
|
173
|
+
throws: constructor.throws?.map((thrown) => ({
|
|
174
|
+
...thrown,
|
|
175
|
+
type: renderableContentConverter([thrown.type]),
|
|
176
|
+
description: renderableContentConverter(thrown.description),
|
|
177
|
+
})),
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function isEnumSource(source: { __type: string }): source is EnumSource {
|
|
182
|
+
return source.__type === 'enum';
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function isInterfaceSource(source: { __type: string }): source is InterfaceSource {
|
|
186
|
+
return source.__type === 'interface';
|
|
187
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Settings } from '../settings';
|
|
2
|
+
|
|
3
|
+
export const splitAndCapitalize = (text: string) => {
|
|
4
|
+
const words = text.split(/[-_]+/);
|
|
5
|
+
const capitalizedWords = [];
|
|
6
|
+
for (const word of words) {
|
|
7
|
+
capitalizedWords.push(word.charAt(0).toUpperCase() + word.slice(1));
|
|
8
|
+
}
|
|
9
|
+
return capitalizedWords.join(' ');
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const namespace = () => {
|
|
13
|
+
return Settings.getInstance().getNamespace();
|
|
14
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export type Link = {
|
|
2
|
+
title: string;
|
|
3
|
+
url: string;
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type EmptyLine = {
|
|
7
|
+
type: 'empty-line';
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type StringOrLink = string | Link;
|
|
11
|
+
|
|
12
|
+
export type RenderableContent = StringOrLink | EmptyLine;
|
|
13
|
+
|
|
14
|
+
export type ConvertRenderableContentsToString = (content?: RenderableContent[]) => string;
|
|
15
|
+
|
|
16
|
+
type EnumValue = {
|
|
17
|
+
value: string;
|
|
18
|
+
description?: RenderableContent[];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
type CustomTag = {
|
|
22
|
+
name: string;
|
|
23
|
+
description?: RenderableContent[];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Represents an annotation to a top-level type. For example @NamespaceAccessible.
|
|
28
|
+
*/
|
|
29
|
+
type Annotation = string;
|
|
30
|
+
|
|
31
|
+
type CodeBlock = string[];
|
|
32
|
+
|
|
33
|
+
type DocumentableSource = {
|
|
34
|
+
annotations?: Annotation[];
|
|
35
|
+
description?: RenderableContent[];
|
|
36
|
+
customTags?: CustomTag[];
|
|
37
|
+
mermaid?: CodeBlock;
|
|
38
|
+
example?: CodeBlock;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
type BaseTypeSource = DocumentableSource & {
|
|
42
|
+
name: string;
|
|
43
|
+
accessModifier: string;
|
|
44
|
+
group?: string;
|
|
45
|
+
author?: string;
|
|
46
|
+
date?: string;
|
|
47
|
+
sees?: StringOrLink[];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
type MethodParameterSource = {
|
|
51
|
+
name: string;
|
|
52
|
+
type: StringOrLink;
|
|
53
|
+
description?: RenderableContent[];
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
type TypeSource = {
|
|
57
|
+
type: StringOrLink;
|
|
58
|
+
description?: RenderableContent[];
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
type ConstructorSource = DocumentableSource & {
|
|
62
|
+
title: string;
|
|
63
|
+
signature: string;
|
|
64
|
+
parameters?: MethodParameterSource[];
|
|
65
|
+
throws?: TypeSource[];
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type MethodSource = DocumentableSource & {
|
|
69
|
+
title: string;
|
|
70
|
+
signature: string;
|
|
71
|
+
parameters?: MethodParameterSource[];
|
|
72
|
+
returnType?: TypeSource;
|
|
73
|
+
throws?: TypeSource[];
|
|
74
|
+
inherited?: boolean;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
type FieldSource = DocumentableSource & {
|
|
78
|
+
name: string;
|
|
79
|
+
type: StringOrLink;
|
|
80
|
+
accessModifier: string;
|
|
81
|
+
inherited?: boolean;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export type ClassSource = BaseTypeSource & {
|
|
85
|
+
__type: 'class';
|
|
86
|
+
extends?: StringOrLink;
|
|
87
|
+
implements?: StringOrLink[];
|
|
88
|
+
constructors?: ConstructorSource[];
|
|
89
|
+
methods?: MethodSource[];
|
|
90
|
+
classModifier?: string;
|
|
91
|
+
sharingModifier?: string;
|
|
92
|
+
fields?: FieldSource[];
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type InterfaceSource = BaseTypeSource & {
|
|
96
|
+
__type: 'interface';
|
|
97
|
+
extends?: StringOrLink[];
|
|
98
|
+
methods?: MethodSource[];
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type EnumSource = BaseTypeSource & {
|
|
102
|
+
__type: 'enum';
|
|
103
|
+
values: EnumValue[];
|
|
104
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DocComment, FieldMirror } from '@cparra/apex-reflection';
|
|
2
|
-
import { ReferencedType } from '@cparra/apex-reflection
|
|
2
|
+
import { ReferencedType } from '@cparra/apex-reflection';
|
|
3
3
|
|
|
4
4
|
type MemberModifier = 'static' | 'webservice' | 'final' | 'override' | 'testmethod' | 'transient';
|
|
5
5
|
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Annotation, DocComment, InterfaceMirror, MethodMirror } from '@cparra/apex-reflection';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Builder class to create Interface objects.
|
|
5
|
+
* For testing purposes only.
|
|
6
|
+
*/
|
|
7
|
+
export class InterfaceMirrorBuilder {
|
|
8
|
+
private name = 'SampleClass';
|
|
9
|
+
private annotations: Annotation[] = [];
|
|
10
|
+
private docComment?: DocComment;
|
|
11
|
+
private methods: MethodMirror[] = [];
|
|
12
|
+
|
|
13
|
+
withName(name: string): InterfaceMirrorBuilder {
|
|
14
|
+
this.name = name;
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
addAnnotation(annotation: Annotation): InterfaceMirrorBuilder {
|
|
19
|
+
this.annotations.push(annotation);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
withDocComment(docComment: DocComment): InterfaceMirrorBuilder {
|
|
24
|
+
this.docComment = docComment;
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
addMethod(method: MethodMirror): InterfaceMirrorBuilder {
|
|
29
|
+
this.methods.push(method);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
build(): InterfaceMirror {
|
|
34
|
+
return {
|
|
35
|
+
annotations: this.annotations,
|
|
36
|
+
name: this.name,
|
|
37
|
+
type_name: 'interface',
|
|
38
|
+
methods: this.methods,
|
|
39
|
+
access_modifier: 'public',
|
|
40
|
+
docComment: this.docComment,
|
|
41
|
+
extended_interfaces: [],
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { Annotation, DocComment, MethodMirror } from '@cparra/apex-reflection';
|
|
1
|
+
import { Annotation, DocComment, MethodMirror, ParameterMirror } from '@cparra/apex-reflection';
|
|
2
|
+
|
|
3
|
+
type Parameter = ParameterMirror;
|
|
2
4
|
|
|
3
5
|
export class MethodMirrorBuilder {
|
|
4
6
|
private name = 'sampleMethod';
|
|
5
7
|
private annotations: Annotation[] = [];
|
|
6
8
|
private docComment?: DocComment;
|
|
9
|
+
private typeReference: { type: string; rawDeclaration: string } = {
|
|
10
|
+
type: 'void',
|
|
11
|
+
rawDeclaration: 'void',
|
|
12
|
+
};
|
|
13
|
+
private parameters: Parameter[] = [];
|
|
7
14
|
|
|
8
15
|
withName(name: string): MethodMirrorBuilder {
|
|
9
16
|
this.name = name;
|
|
@@ -20,18 +27,51 @@ export class MethodMirrorBuilder {
|
|
|
20
27
|
return this;
|
|
21
28
|
}
|
|
22
29
|
|
|
30
|
+
withTypeReference(param: { type: string; rawDeclaration: string }) {
|
|
31
|
+
this.typeReference = param;
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
addParameter(parameter: Parameter): MethodMirrorBuilder {
|
|
36
|
+
this.parameters.push(parameter);
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
23
40
|
build(): MethodMirror {
|
|
24
41
|
return {
|
|
25
42
|
access_modifier: 'public',
|
|
26
43
|
annotations: this.annotations,
|
|
27
44
|
name: this.name,
|
|
28
45
|
memberModifiers: [],
|
|
29
|
-
typeReference:
|
|
30
|
-
|
|
31
|
-
rawDeclaration: 'void',
|
|
32
|
-
},
|
|
33
|
-
parameters: [],
|
|
46
|
+
typeReference: this.typeReference,
|
|
47
|
+
parameters: this.parameters,
|
|
34
48
|
docComment: this.docComment,
|
|
35
49
|
};
|
|
36
50
|
}
|
|
37
51
|
}
|
|
52
|
+
|
|
53
|
+
export class ParameterBuilder {
|
|
54
|
+
private name = 'param';
|
|
55
|
+
private typeReference: { type: string; rawDeclaration: string } = {
|
|
56
|
+
type: 'String',
|
|
57
|
+
rawDeclaration: 'String',
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
withName(name: string): ParameterBuilder {
|
|
61
|
+
this.name = name;
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
withTypeReference(param: { type: string; rawDeclaration: string }) {
|
|
66
|
+
this.typeReference = param;
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
build(): Parameter {
|
|
71
|
+
return {
|
|
72
|
+
memberModifiers: [],
|
|
73
|
+
name: this.name,
|
|
74
|
+
typeReference: this.typeReference,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -3,6 +3,7 @@ import { TypesRepository } from '../../model/types-repository';
|
|
|
3
3
|
import { Settings } from '../../settings';
|
|
4
4
|
import State from '../../service/state';
|
|
5
5
|
import { TypeTranspilerFactory } from '../factory';
|
|
6
|
+
import { StringOrLink } from '../../templating/types';
|
|
6
7
|
|
|
7
8
|
export default class ClassFileGeneratorHelper {
|
|
8
9
|
public static getSanitizedGroup(classModel: Type) {
|
|
@@ -10,13 +11,18 @@ export default class ClassFileGeneratorHelper {
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
public static getFileLink(classModel: Type) {
|
|
14
|
+
const [fullClassName, fileLink] = ClassFileGeneratorHelper.getFileLinkTuple(classModel);
|
|
15
|
+
return `[${fullClassName}](${fileLink})`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
private static getFileLinkTuple(classModel: Type): [string, string] {
|
|
13
19
|
const documentationRoot = Settings.getInstance().getRootDir() ?? '';
|
|
14
20
|
const directoryRoot = `${documentationRoot}${this.getDirectoryRoot(classModel)}`;
|
|
15
21
|
const fullClassName = `${Settings.getInstance().getNamespacePrefix()}${classModel.name}`;
|
|
16
|
-
return
|
|
22
|
+
return [fullClassName, `${directoryRoot}${fullClassName}.md`];
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
public static getFileLinkByTypeName(typeName: string) {
|
|
25
|
+
public static getFileLinkByTypeName(typeName: string): string {
|
|
20
26
|
const type = TypesRepository.getInstance().getFromScopedByName(typeName);
|
|
21
27
|
if (!type) {
|
|
22
28
|
// If the type is not found, we return a Markdown hyperlink with whatever we received.
|
|
@@ -26,6 +32,20 @@ export default class ClassFileGeneratorHelper {
|
|
|
26
32
|
return this.getFileLink(type);
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
public static getRenderableLinkByTypeName(typeName: string): StringOrLink {
|
|
36
|
+
const type = TypesRepository.getInstance().getFromScopedByName(typeName);
|
|
37
|
+
if (!type) {
|
|
38
|
+
// If the type is not found, we return the type name as a string.
|
|
39
|
+
return typeName;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const [fullClassName, fileLink] = ClassFileGeneratorHelper.getFileLinkTuple(type);
|
|
43
|
+
return {
|
|
44
|
+
title: fullClassName,
|
|
45
|
+
url: fileLink,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
29
49
|
private static getDirectoryRoot(classModel: Type) {
|
|
30
50
|
// root-relative links start from the root by using a leading '/'
|
|
31
51
|
const generator = Settings.getInstance().targetGenerator;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const classMarkdownTemplate = `
|
|
2
|
+
# {{name}} Class
|
|
3
|
+
{{#if classModifier}}
|
|
4
|
+
\`{{classModifier}}\`
|
|
5
|
+
{{/if}}
|
|
6
|
+
|
|
7
|
+
{{> typeLevelApexDocPartialTemplate}}
|
|
8
|
+
|
|
9
|
+
{{#if extends}}
|
|
10
|
+
**Extends**
|
|
11
|
+
{{extends}}
|
|
12
|
+
{{/if}}
|
|
13
|
+
|
|
14
|
+
{{#if implements}}
|
|
15
|
+
**Implements**
|
|
16
|
+
{{#each implements}}
|
|
17
|
+
{{this}}{{#unless @last}}, {{/unless}}
|
|
18
|
+
{{/each}}
|
|
19
|
+
{{/if}}
|
|
20
|
+
|
|
21
|
+
{{#if fields}}
|
|
22
|
+
{{> fieldsPartialTemplate}}
|
|
23
|
+
{{/if}}
|
|
24
|
+
|
|
25
|
+
{{#if constructors}}
|
|
26
|
+
{{> constructorsPartialTemplate}}
|
|
27
|
+
{{/if}}
|
|
28
|
+
|
|
29
|
+
{{#if methods}}
|
|
30
|
+
{{> methodsPartialTemplate}}
|
|
31
|
+
{{/if}}
|
|
32
|
+
`.trim();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const constructorsPartialTemplate = `
|
|
2
|
+
## Constructors
|
|
3
|
+
{{#each constructors}}
|
|
4
|
+
### \`{{title}}\`
|
|
5
|
+
|
|
6
|
+
{{#> documentablePartialTemplate}}
|
|
7
|
+
|
|
8
|
+
### Signature
|
|
9
|
+
\`\`\`apex
|
|
10
|
+
{{signature}}
|
|
11
|
+
\`\`\`
|
|
12
|
+
|
|
13
|
+
{{#if parameters}}
|
|
14
|
+
### Parameters
|
|
15
|
+
| Name | Type | Description |
|
|
16
|
+
|------|------|-------------|
|
|
17
|
+
{{#each parameters}}
|
|
18
|
+
| {{name}} | {{type}} | {{description}} |
|
|
19
|
+
{{/each}}
|
|
20
|
+
{{/if}}
|
|
21
|
+
|
|
22
|
+
{{#if throws}}
|
|
23
|
+
### Throws
|
|
24
|
+
{{#each throws}}
|
|
25
|
+
{{this.type}}: {{this.description}}
|
|
26
|
+
|
|
27
|
+
{{/each}}
|
|
28
|
+
{{/if}}
|
|
29
|
+
|
|
30
|
+
{{/documentablePartialTemplate}}
|
|
31
|
+
|
|
32
|
+
{{#unless @last}}---{{/unless}}
|
|
33
|
+
{{/each}}
|
|
34
|
+
|
|
35
|
+
`.trim();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export const documentablePartialTemplate = `
|
|
2
|
+
{{#each annotations}}
|
|
3
|
+
\`{{this}}\`
|
|
4
|
+
{{/each}}
|
|
5
|
+
|
|
6
|
+
{{description}}
|
|
7
|
+
|
|
8
|
+
{{#each customTags}}
|
|
9
|
+
**{{splitAndCapitalize name}}** {{description}}
|
|
10
|
+
|
|
11
|
+
{{/each}}
|
|
12
|
+
|
|
13
|
+
{{> @partial-block}}
|
|
14
|
+
|
|
15
|
+
{{{mermaid}}}
|
|
16
|
+
|
|
17
|
+
{{#if example}}
|
|
18
|
+
##{{#if isInner}}#{{/if}} Example
|
|
19
|
+
{{{example}}}
|
|
20
|
+
{{/if}}
|
|
21
|
+
`.trim();
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const fieldsPartialTemplate = `
|
|
2
|
+
## Fields
|
|
3
|
+
{{#each fields}}
|
|
4
|
+
### \`\{{name}}\`
|
|
5
|
+
|
|
6
|
+
{{#if inherited}}
|
|
7
|
+
*Inherited*
|
|
8
|
+
{{/if}}
|
|
9
|
+
|
|
10
|
+
{{#> documentablePartialTemplate}}
|
|
11
|
+
|
|
12
|
+
#### Type
|
|
13
|
+
{{type}}
|
|
14
|
+
|
|
15
|
+
{{/documentablePartialTemplate}}
|
|
16
|
+
|
|
17
|
+
{{#unless @last}}---{{/unless}}
|
|
18
|
+
|
|
19
|
+
{{/each}}
|
|
20
|
+
`.trim();
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const interfaceMarkdownTemplate = `
|
|
2
|
+
# {{name}} Interface
|
|
3
|
+
|
|
4
|
+
{{> typeLevelApexDocPartialTemplate}}
|
|
5
|
+
|
|
6
|
+
{{#if extends}}
|
|
7
|
+
**Extends**
|
|
8
|
+
{{#each extends}}
|
|
9
|
+
{{this}}{{#unless @last}}, {{/unless}}
|
|
10
|
+
{{/each}}
|
|
11
|
+
{{/if}}
|
|
12
|
+
|
|
13
|
+
{{#if methods}}
|
|
14
|
+
{{> methodsPartialTemplate}}
|
|
15
|
+
{{/if}}
|
|
16
|
+
`.trim();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const methodsPartialTemplate = `
|
|
2
|
+
## Methods
|
|
3
|
+
{{#each methods}}
|
|
4
|
+
### \`{{title}}\`
|
|
5
|
+
|
|
6
|
+
{{#if inherited}}
|
|
7
|
+
*Inherited*
|
|
8
|
+
{{/if}}
|
|
9
|
+
|
|
10
|
+
{{#> documentablePartialTemplate isInner=true}}
|
|
11
|
+
|
|
12
|
+
### Signature
|
|
13
|
+
\`\`\`apex
|
|
14
|
+
{{signature}}
|
|
15
|
+
\`\`\`
|
|
16
|
+
|
|
17
|
+
{{#if parameters}}
|
|
18
|
+
### Parameters
|
|
19
|
+
| Name | Type | Description |
|
|
20
|
+
|------|------|-------------|
|
|
21
|
+
{{#each parameters}}
|
|
22
|
+
| {{name}} | {{type}} | {{description}} |
|
|
23
|
+
{{/each}}
|
|
24
|
+
{{/if}}
|
|
25
|
+
|
|
26
|
+
{{#if returnType}}
|
|
27
|
+
### Returns
|
|
28
|
+
**{{returnType.type}}**
|
|
29
|
+
|
|
30
|
+
{{returnType.description}}
|
|
31
|
+
{{/if}}
|
|
32
|
+
|
|
33
|
+
{{#if throws}}
|
|
34
|
+
### Throws
|
|
35
|
+
{{#each throws}}
|
|
36
|
+
{{this.type}}: {{this.description}}
|
|
37
|
+
|
|
38
|
+
{{/each}}
|
|
39
|
+
{{/if}}
|
|
40
|
+
{{/documentablePartialTemplate}}
|
|
41
|
+
|
|
42
|
+
{{#unless @last}}---{{/unless}}
|
|
43
|
+
|
|
44
|
+
{{/each}}
|
|
45
|
+
`.trim();
|