@cparra/apexdocs 2.25.0-alpha.0 → 2.25.0-alpha.2
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/__mocks__/chalk.js +12 -0
- package/__mocks__/log-update.js +6 -0
- package/eslint.config.mjs +10 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.BaseClass.md +16 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.MultiInheritanceClass.md +73 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.ParentInterface.md +15 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.ReferencedEnum.md +8 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleException.md +7 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleInterface.md +115 -0
- package/examples/plain-markdown/docs/Sample-Enums/ns.SampleEnum.md +36 -0
- package/examples/plain-markdown/docs/SampleGroup/ns.SampleClass.md +173 -0
- package/examples/plain-markdown/docs/index.md +33 -0
- package/examples/plain-markdown/force-app/classes/MultiInheritanceClass.cls +1 -0
- package/examples/plain-markdown/force-app/classes/SampleClass.cls +37 -0
- package/examples/plain-markdown/package.json +2 -6
- package/jest.config.js +4 -0
- package/jest.d.ts +7 -0
- package/lib/__spec__/core/expect-extensions.d.ts +3 -0
- package/lib/__spec__/core/expect-extensions.js +54 -0
- package/lib/__spec__/core/expect-extensions.js.map +1 -0
- package/lib/__spec__/core/generating-class-docs.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-class-docs.spec.js +427 -0
- package/lib/__spec__/core/generating-class-docs.spec.js.map +1 -0
- package/lib/__spec__/core/generating-enum-docs.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-enum-docs.spec.js +303 -0
- package/lib/__spec__/core/generating-enum-docs.spec.js.map +1 -0
- package/lib/__spec__/core/generating-interface-docs.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-interface-docs.spec.js +361 -0
- package/lib/__spec__/core/generating-interface-docs.spec.js.map +1 -0
- package/lib/__spec__/core/generating-reference-guide.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-reference-guide.spec.js +161 -0
- package/lib/__spec__/core/generating-reference-guide.spec.js.map +1 -0
- package/lib/adapters/apex-types.d.ts +5 -5
- package/lib/adapters/apex-types.js +97 -22
- package/lib/adapters/apex-types.js.map +1 -1
- package/lib/adapters/documentables.d.ts +4 -3
- package/lib/adapters/documentables.js +23 -8
- package/lib/adapters/documentables.js.map +1 -1
- package/lib/adapters/fields-and-properties.d.ts +4 -3
- package/lib/adapters/fields-and-properties.js +26 -5
- package/lib/adapters/fields-and-properties.js.map +1 -1
- package/lib/adapters/methods-and-constructors.d.ts +4 -3
- package/lib/adapters/methods-and-constructors.js +54 -12
- package/lib/adapters/methods-and-constructors.js.map +1 -1
- package/lib/adapters/references.d.ts +1 -1
- package/lib/adapters/references.js +3 -3
- package/lib/adapters/references.js.map +1 -1
- package/lib/adapters/type-utils.d.ts +1 -1
- package/lib/adapters/type-utils.js +1 -2
- package/lib/adapters/type-utils.js.map +1 -1
- package/lib/application/Apexdocs.js +21 -15
- package/lib/application/Apexdocs.js.map +1 -1
- package/lib/application/flows/generate-markdown-files.d.ts +3 -0
- package/lib/application/flows/generate-markdown-files.js +57 -0
- package/lib/application/flows/generate-markdown-files.js.map +1 -0
- package/lib/cli/generate.js +7 -7
- package/lib/cli/generate.js.map +1 -1
- package/lib/core/__test__/inheritance-chain.test.d.ts +1 -0
- package/lib/core/__test__/inheritance-chain.test.js +42 -0
- package/lib/core/__test__/inheritance-chain.test.js.map +1 -0
- package/lib/core/generate-docs.d.ts +24 -0
- package/lib/core/generate-docs.js +267 -0
- package/lib/core/generate-docs.js.map +1 -0
- package/lib/core/inheritance-chain.d.ts +2 -0
- package/lib/core/inheritance-chain.js +35 -0
- package/lib/core/inheritance-chain.js.map +1 -0
- package/lib/core/template.d.ts +10 -0
- package/lib/core/template.js +92 -0
- package/lib/core/template.js.map +1 -0
- package/lib/core/templates/reference-guide.d.ts +1 -0
- package/lib/core/templates/reference-guide.js +18 -0
- package/lib/core/templates/reference-guide.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +14 -3
- package/lib/index.js.map +1 -1
- package/lib/model/inheritance.d.ts +4 -1
- package/lib/model/manifest.js +8 -2
- package/lib/model/manifest.js.map +1 -1
- package/lib/model/markdown-file.d.ts +2 -2
- package/lib/model/markdown-file.js +5 -4
- package/lib/model/markdown-file.js.map +1 -1
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +3 -4
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -1
- package/lib/model/markdown-generation-util/field-declaration-util.js +1 -2
- package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/method-declaration-util.js +2 -3
- package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/type-declaration-util.js +1 -2
- package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -1
- package/lib/model/markdown-home-file.js.map +1 -1
- package/lib/model/markdown-type-file.js.map +1 -1
- package/lib/model/openapi/open-api.js.map +1 -1
- package/lib/model/outputFile.d.ts +1 -1
- package/lib/model/outputFile.js +2 -9
- package/lib/model/outputFile.js.map +1 -1
- package/lib/model/types-repository.js.map +1 -1
- package/lib/service/apex-file-reader.js.map +1 -1
- package/lib/service/file-writer.js.map +1 -1
- package/lib/service/manifest-factory.js +1 -2
- package/lib/service/manifest-factory.js.map +1 -1
- package/lib/service/metadata-processor.js.map +1 -1
- package/lib/service/parser.js +1 -1
- package/lib/service/parser.js.map +1 -1
- package/lib/service/state.js.map +1 -1
- package/lib/service/walkers/class-walker.js.map +1 -1
- package/lib/service/walkers/interface-walker.js.map +1 -1
- package/lib/service/walkers/walker-factory.js.map +1 -1
- package/lib/service/walkers/walker.js.map +1 -1
- package/lib/settings.d.ts +0 -6
- package/lib/settings.js +0 -11
- package/lib/settings.js.map +1 -1
- package/lib/test-helpers/ClassMirrorBuilder.d.ts +4 -0
- package/lib/test-helpers/ClassMirrorBuilder.js +11 -1
- package/lib/test-helpers/ClassMirrorBuilder.js.map +1 -1
- package/lib/transpiler/factory.js.map +1 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +1 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/class-template.js +53 -12
- package/lib/transpiler/markdown/plain-markdown/class-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js +13 -16
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js +11 -8
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/enum-template.js +7 -6
- package/lib/transpiler/markdown/plain-markdown/enum-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js +9 -6
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.js +10 -0
- package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.js +4 -4
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js +18 -20
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +0 -4
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +6 -86
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/type-doc-partial.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/type-doc-partial.js +31 -0
- package/lib/transpiler/markdown/plain-markdown/type-doc-partial.js.map +1 -0
- 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.map +1 -1
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +3 -2
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js.map +1 -1
- package/lib/transpiler/transpiler.js.map +1 -1
- package/lib/util/error-logger.js.map +1 -1
- package/lib/util/logger.js +1 -1
- package/lib/util/logger.js.map +1 -1
- package/lib/util/string-utils.js +2 -2
- package/lib/util/string-utils.js.map +1 -1
- package/package.json +17 -17
- package/src/__spec__/core/expect-extensions.ts +32 -0
- package/src/__spec__/core/generating-class-docs.spec.ts +511 -0
- package/src/__spec__/core/generating-enum-docs.spec.ts +355 -0
- package/src/__spec__/core/generating-interface-docs.spec.ts +431 -0
- package/src/__spec__/core/generating-reference-guide.spec.ts +163 -0
- package/src/adapters/__tests__/interface-adapter.spec.ts +15 -11
- package/src/adapters/__tests__/references.spec.ts +1 -1
- package/src/adapters/apex-types.ts +205 -41
- package/src/adapters/documentables.ts +44 -9
- package/src/adapters/fields-and-properties.ts +31 -7
- package/src/adapters/methods-and-constructors.ts +65 -22
- package/src/adapters/references.ts +1 -1
- package/src/adapters/type-utils.ts +1 -1
- package/src/application/Apexdocs.ts +21 -15
- package/src/application/flows/generate-markdown-files.ts +47 -0
- package/src/cli/generate.ts +96 -96
- package/src/core/__test__/inheritance-chain.test.ts +54 -0
- package/src/core/generate-docs.ts +396 -0
- package/src/core/inheritance-chain.ts +23 -0
- package/src/core/renderable/types.d.ts +131 -0
- package/src/core/template.ts +108 -0
- package/src/core/templates/reference-guide.ts +14 -0
- package/src/index.ts +3 -1
- package/src/model/inheritance.ts +2 -1
- package/src/model/manifest.ts +12 -2
- package/src/model/markdown-file.ts +5 -4
- package/src/model/markdown-generation-util/doc-comment-annotation-util.ts +1 -1
- package/src/model/markdown-generation-util/method-declaration-util.ts +1 -1
- package/src/model/outputFile.ts +2 -11
- package/src/service/parser.ts +1 -1
- package/src/settings.ts +0 -15
- package/src/test-helpers/ClassMirrorBuilder.ts +14 -1
- package/src/transpiler/markdown/class-file-generatorHelper.ts +1 -1
- package/src/transpiler/markdown/plain-markdown/class-template.ts +53 -12
- package/src/transpiler/markdown/plain-markdown/constructors-partial-template.ts +13 -16
- package/src/transpiler/markdown/plain-markdown/documentable-partial-template.ts +11 -8
- package/src/transpiler/markdown/plain-markdown/enum-template.ts +7 -6
- package/src/transpiler/markdown/plain-markdown/fieldsPartialTemplate.ts +9 -6
- package/src/transpiler/markdown/plain-markdown/grouped-members-partial-template.ts +6 -0
- package/src/transpiler/markdown/plain-markdown/interface-template.ts +4 -4
- package/src/transpiler/markdown/plain-markdown/methods-partial-template.ts +18 -20
- package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +8 -100
- package/src/transpiler/markdown/plain-markdown/type-doc-partial.ts +27 -0
- package/src/transpiler/openapi/parsers/ReferenceBuilder.ts +3 -2
- package/src/util/logger.ts +1 -1
- package/tsconfig.json +1 -1
- package/.eslintrc.js +0 -12
- package/examples/plain-markdown/README.md +0 -301
- package/lib/templating/compile.d.ts +0 -7
- package/lib/templating/compile.js +0 -98
- package/lib/templating/compile.js.map +0 -1
- package/lib/templating/helpers.d.ts +0 -2
- package/lib/templating/helpers.js +0 -18
- package/lib/templating/helpers.js.map +0 -1
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.d.ts +0 -1
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js +0 -31
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js.map +0 -1
- package/src/templating/__tests__/compile.spec.ts +0 -741
- package/src/templating/compile.ts +0 -187
- package/src/templating/helpers.ts +0 -14
- package/src/templating/types.d.ts +0 -104
- package/src/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.ts +0 -27
|
@@ -0,0 +1,131 @@
|
|
|
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
|
+
type EnumValue = {
|
|
15
|
+
value: string;
|
|
16
|
+
description?: RenderableContent[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type CustomTag = {
|
|
20
|
+
name: string;
|
|
21
|
+
description?: RenderableContent[];
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Represents an annotation to a top-level type. For example @NamespaceAccessible.
|
|
26
|
+
*/
|
|
27
|
+
type Annotation = string;
|
|
28
|
+
|
|
29
|
+
type CodeBlock = string[];
|
|
30
|
+
|
|
31
|
+
type RenderableDocumentation = {
|
|
32
|
+
annotations?: Annotation[];
|
|
33
|
+
description?: RenderableContent[];
|
|
34
|
+
customTags?: CustomTag[];
|
|
35
|
+
mermaid: RenderableSection<CodeBlock | undefined>;
|
|
36
|
+
example: RenderableSection<CodeBlock | undefined>;
|
|
37
|
+
group?: string;
|
|
38
|
+
author?: string;
|
|
39
|
+
date?: string;
|
|
40
|
+
sees?: StringOrLink[];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
type RenderableType = {
|
|
44
|
+
namespace?: string;
|
|
45
|
+
headingLevel: number;
|
|
46
|
+
heading: string;
|
|
47
|
+
name: string;
|
|
48
|
+
meta: {
|
|
49
|
+
accessModifier: string;
|
|
50
|
+
};
|
|
51
|
+
doc: RenderableDocumentation;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
type RenderableMethodParameter = {
|
|
55
|
+
name: string;
|
|
56
|
+
type: StringOrLink;
|
|
57
|
+
description?: RenderableContent[];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type TypeSource = {
|
|
61
|
+
type: StringOrLink;
|
|
62
|
+
description?: RenderableContent[];
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type RenderableConstructor = {
|
|
66
|
+
headingLevel: number;
|
|
67
|
+
heading: string;
|
|
68
|
+
signature: RenderableSection<CodeBlock>;
|
|
69
|
+
parameters?: RenderableSection<RenderableMethodParameter[] | undefined>;
|
|
70
|
+
throws?: RenderableSection<TypeSource[] | undefined>;
|
|
71
|
+
doc: RenderableDocumentation;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
type RenderableMethod = {
|
|
75
|
+
doc: RenderableDocumentation;
|
|
76
|
+
headingLevel: number;
|
|
77
|
+
heading: string;
|
|
78
|
+
signature: RenderableSection<CodeBlock>;
|
|
79
|
+
parameters: RenderableSection<RenderableMethodParameter[] | undefined>;
|
|
80
|
+
returnType: RenderableSection<TypeSource>;
|
|
81
|
+
throws: RenderableSection<TypeSource[] | undefined>;
|
|
82
|
+
inherited?: boolean;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
type RenderableField = {
|
|
86
|
+
headingLevel: number;
|
|
87
|
+
heading: string;
|
|
88
|
+
type: RenderableSection<StringOrLink>;
|
|
89
|
+
accessModifier: string;
|
|
90
|
+
inherited?: boolean;
|
|
91
|
+
signature: RenderableSection<CodeBlock>;
|
|
92
|
+
doc: RenderableDocumentation;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export type RenderableSection<T> = {
|
|
96
|
+
headingLevel: number;
|
|
97
|
+
heading: string;
|
|
98
|
+
value: T;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export type GroupedMember<T> = RenderableSection<T[]> & { groupDescription: string | undefined };
|
|
102
|
+
|
|
103
|
+
export type RenderableClass = RenderableType & {
|
|
104
|
+
type: 'class';
|
|
105
|
+
extends?: StringOrLink[];
|
|
106
|
+
implements?: StringOrLink[];
|
|
107
|
+
classModifier?: string;
|
|
108
|
+
sharingModifier?: string;
|
|
109
|
+
constructors: RenderableSection<RenderableConstructor[] | GroupedMember<RenderableConstructor>[]> & {
|
|
110
|
+
isGrouped: boolean;
|
|
111
|
+
};
|
|
112
|
+
methods: RenderableSection<RenderableMethod[] | GroupedMember<RenderableMethod>[]> & { isGrouped: boolean };
|
|
113
|
+
fields: RenderableSection<RenderableField[] | GroupedMember<RenderableField>[]> & { isGrouped: boolean };
|
|
114
|
+
properties: RenderableSection<RenderableField[] | GroupedMember<RenderableField>[]> & { isGrouped: boolean };
|
|
115
|
+
innerClasses: RenderableSection<RenderableClass[]>;
|
|
116
|
+
innerEnums: RenderableSection<RenderableEnum[]>;
|
|
117
|
+
innerInterfaces: RenderableSection<RenderableInterface[]>;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export type RenderableInterface = RenderableType & {
|
|
121
|
+
type: 'interface';
|
|
122
|
+
extends?: StringOrLink[];
|
|
123
|
+
methods: RenderableSection<RenderableMethod[]>;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
export type RenderableEnum = RenderableType & {
|
|
127
|
+
type: 'enum';
|
|
128
|
+
values: RenderableSection<EnumValue[]>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export type Renderable = RenderableClass | RenderableInterface | RenderableEnum;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import Handlebars from 'handlebars';
|
|
2
|
+
import { typeDocPartial } from '../transpiler/markdown/plain-markdown/type-doc-partial';
|
|
3
|
+
import { documentablePartialTemplate } from '../transpiler/markdown/plain-markdown/documentable-partial-template';
|
|
4
|
+
import { methodsPartialTemplate } from '../transpiler/markdown/plain-markdown/methods-partial-template';
|
|
5
|
+
import { constructorsPartialTemplate } from '../transpiler/markdown/plain-markdown/constructors-partial-template';
|
|
6
|
+
import { fieldsPartialTemplate } from '../transpiler/markdown/plain-markdown/fieldsPartialTemplate';
|
|
7
|
+
import { classMarkdownTemplate } from '../transpiler/markdown/plain-markdown/class-template';
|
|
8
|
+
import { enumMarkdownTemplate } from '../transpiler/markdown/plain-markdown/enum-template';
|
|
9
|
+
import { interfaceMarkdownTemplate } from '../transpiler/markdown/plain-markdown/interface-template';
|
|
10
|
+
import { RenderableContent, StringOrLink } from './renderable/types';
|
|
11
|
+
import { isEmptyLine } from '../adapters/type-utils';
|
|
12
|
+
import { groupedMembersPartialTemplate } from '../transpiler/markdown/plain-markdown/grouped-members-partial-template';
|
|
13
|
+
|
|
14
|
+
export type CompilationRequest = {
|
|
15
|
+
template: string;
|
|
16
|
+
source: unknown;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export class Template {
|
|
20
|
+
private static instance: Template;
|
|
21
|
+
|
|
22
|
+
private constructor() {
|
|
23
|
+
Handlebars.registerPartial('typeDocumentation', typeDocPartial);
|
|
24
|
+
Handlebars.registerPartial('documentablePartialTemplate', documentablePartialTemplate);
|
|
25
|
+
Handlebars.registerPartial('methodsPartialTemplate', methodsPartialTemplate);
|
|
26
|
+
Handlebars.registerPartial('constructorsPartialTemplate', constructorsPartialTemplate);
|
|
27
|
+
Handlebars.registerPartial('groupedMembersPartialTemplate', groupedMembersPartialTemplate);
|
|
28
|
+
Handlebars.registerPartial('fieldsPartialTemplate', fieldsPartialTemplate);
|
|
29
|
+
Handlebars.registerPartial('classTemplate', classMarkdownTemplate);
|
|
30
|
+
Handlebars.registerPartial('enumTemplate', enumMarkdownTemplate);
|
|
31
|
+
Handlebars.registerPartial('interfaceTemplate', interfaceMarkdownTemplate);
|
|
32
|
+
|
|
33
|
+
Handlebars.registerHelper('link', link);
|
|
34
|
+
Handlebars.registerHelper('code', convertCodeBlock);
|
|
35
|
+
Handlebars.registerHelper('withLinks', resolveLinksInContent);
|
|
36
|
+
Handlebars.registerHelper('heading', heading);
|
|
37
|
+
Handlebars.registerHelper('inlineCode', inlineCode);
|
|
38
|
+
Handlebars.registerHelper('splitAndCapitalize', splitAndCapitalize);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public static getInstance(): Template {
|
|
42
|
+
if (!Template.instance) {
|
|
43
|
+
Template.instance = new Template();
|
|
44
|
+
}
|
|
45
|
+
return Template.instance;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
compile(request: CompilationRequest): string {
|
|
49
|
+
const compiled = Handlebars.compile(request.template);
|
|
50
|
+
return (
|
|
51
|
+
compiled(request.source)
|
|
52
|
+
.trim()
|
|
53
|
+
// clean up extra newlines
|
|
54
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const splitAndCapitalize = (text: string) => {
|
|
60
|
+
const words = text.split(/[-_]+/);
|
|
61
|
+
const capitalizedWords = [];
|
|
62
|
+
for (const word of words) {
|
|
63
|
+
capitalizedWords.push(word.charAt(0).toUpperCase() + word.slice(1));
|
|
64
|
+
}
|
|
65
|
+
return capitalizedWords.join(' ');
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const heading = (level: number, text: string) => {
|
|
69
|
+
return `${'#'.repeat(level)} ${text}`;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const inlineCode = (text: string) => {
|
|
73
|
+
return new Handlebars.SafeString(`\`${text}\``);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const convertCodeBlock = (language: string, lines: string[]): Handlebars.SafeString => {
|
|
77
|
+
return new Handlebars.SafeString(
|
|
78
|
+
`
|
|
79
|
+
\`\`\`${language}
|
|
80
|
+
${lines.join('\n')}
|
|
81
|
+
\`\`\`
|
|
82
|
+
`.trim(),
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const resolveLinksInContent = (description?: RenderableContent[]): string => {
|
|
87
|
+
if (!description) {
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function reduceDescription(acc: string, curr: RenderableContent) {
|
|
92
|
+
if (isEmptyLine(curr)) {
|
|
93
|
+
return acc + '\n\n';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return acc + link(curr).trim() + ' ';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return description.reduce(reduceDescription, '').trim();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const link = (source: StringOrLink): string => {
|
|
103
|
+
if (typeof source === 'string') {
|
|
104
|
+
return source;
|
|
105
|
+
} else {
|
|
106
|
+
return `[${source.title}](${source.url})`;
|
|
107
|
+
}
|
|
108
|
+
};
|
package/src/index.ts
CHANGED
package/src/model/inheritance.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FieldMirror, MethodMirror, PropertyMirror } from '@cparra/apex-reflection';
|
|
1
|
+
import { ClassMirror, FieldMirror, MethodMirror, PropertyMirror } from '@cparra/apex-reflection';
|
|
2
2
|
|
|
3
3
|
export type InheritanceSupport = { inherited: boolean };
|
|
4
|
+
export type ClassMirrorWithInheritanceChain = ClassMirror & { inheritanceChain: string[] };
|
|
4
5
|
export type FieldMirrorWithInheritance = FieldMirror & InheritanceSupport;
|
|
5
6
|
export type PropertyMirrorWithInheritance = PropertyMirror & InheritanceSupport;
|
|
6
7
|
export type MethodMirrorWithInheritance = MethodMirror & InheritanceSupport;
|
package/src/model/manifest.ts
CHANGED
|
@@ -26,11 +26,21 @@ export default class Manifest {
|
|
|
26
26
|
const typesToReturn: Type[] = [];
|
|
27
27
|
for (const filteredType of filteredTypes) {
|
|
28
28
|
const currentType = filteredType as Type;
|
|
29
|
-
if (currentType.type_name
|
|
29
|
+
if (currentType.type_name === 'enum') {
|
|
30
|
+
// Ignoring enum values is not supported.
|
|
30
31
|
typesToReturn.push(currentType);
|
|
31
32
|
continue;
|
|
32
33
|
}
|
|
33
34
|
|
|
35
|
+
if (currentType.type_name === 'interface') {
|
|
36
|
+
const currentInterface = currentType as InterfaceMirror;
|
|
37
|
+
typesToReturn.push({
|
|
38
|
+
...currentType,
|
|
39
|
+
methods: this.filterAccessibleModifier(currentInterface.methods, modifiers),
|
|
40
|
+
} as InterfaceMirror);
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
|
|
34
44
|
const currentClass = currentType as ClassMirror;
|
|
35
45
|
let filteredClass = {
|
|
36
46
|
...currentType,
|
|
@@ -60,7 +70,7 @@ export default class Manifest {
|
|
|
60
70
|
filterAccessibleModifier(accessAndDocAware: AccessAndDocAware[], modifiers: string[]) {
|
|
61
71
|
return accessAndDocAware.filter((currentType) => {
|
|
62
72
|
const hasIgnoreDocAnnotation = currentType.docComment?.annotations.some(
|
|
63
|
-
(annotation: DocCommentAnnotation) => annotation.name === 'ignore',
|
|
73
|
+
(annotation: DocCommentAnnotation) => annotation.name.toLowerCase() === 'ignore',
|
|
64
74
|
);
|
|
65
75
|
if (hasIgnoreDocAnnotation) {
|
|
66
76
|
return false;
|
|
@@ -18,12 +18,13 @@ export class MarkdownFile extends OutputFile {
|
|
|
18
18
|
this.addBlankLine();
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
public addText(text: string
|
|
22
|
-
super.addText(
|
|
21
|
+
public addText(text: string) {
|
|
22
|
+
super.addText(text);
|
|
23
|
+
return this;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
public addLink(text: string
|
|
26
|
-
this.addText(
|
|
26
|
+
public addLink(text: string) {
|
|
27
|
+
this.addText(`{@link ${text}}`);
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
startCodeBlock(language = 'apex') {
|
|
@@ -15,7 +15,7 @@ export function addMermaid(markdownFile: MarkdownFile, docCommentAware: DocComme
|
|
|
15
15
|
markdownFile.addBlankLine();
|
|
16
16
|
markdownFile.startCodeBlock('mermaid');
|
|
17
17
|
mermaid.bodyLines.forEach((line) => {
|
|
18
|
-
markdownFile.addText(line
|
|
18
|
+
markdownFile.addText(line);
|
|
19
19
|
});
|
|
20
20
|
markdownFile.endCodeBlock();
|
|
21
21
|
markdownFile.addBlankLine();
|
|
@@ -153,7 +153,7 @@ function addExample(markdownFile: MarkdownFile, docCommentAware: DocCommentAware
|
|
|
153
153
|
markdownFile.addTitle('Example', startingHeadingLevel + 3);
|
|
154
154
|
markdownFile.startCodeBlock();
|
|
155
155
|
docCommentAware.docComment?.exampleAnnotation.bodyLines.forEach((line) => {
|
|
156
|
-
markdownFile.addText(line
|
|
156
|
+
markdownFile.addText(line);
|
|
157
157
|
});
|
|
158
158
|
markdownFile.endCodeBlock();
|
|
159
159
|
markdownFile.addBlankLine();
|
package/src/model/outputFile.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import xss = require('xss');
|
|
2
|
-
import { Settings } from '../settings';
|
|
3
|
-
|
|
4
|
-
const xssFilter = new xss.FilterXSS({
|
|
5
|
-
whiteList: { br: [], p: [], ul: [], li: [], code: [], pre: [] },
|
|
6
|
-
});
|
|
7
|
-
|
|
8
1
|
export abstract class OutputFile {
|
|
9
2
|
_contents = '';
|
|
10
3
|
|
|
@@ -16,10 +9,8 @@ export abstract class OutputFile {
|
|
|
16
9
|
return this._contents;
|
|
17
10
|
}
|
|
18
11
|
|
|
19
|
-
addText(text: string
|
|
20
|
-
|
|
21
|
-
const textToAdd = shouldEncode ? xssFilter.process(text) : text;
|
|
22
|
-
this._contents += textToAdd;
|
|
12
|
+
addText(text: string) {
|
|
13
|
+
this._contents += text;
|
|
23
14
|
this.addBlankLine();
|
|
24
15
|
}
|
|
25
16
|
|
package/src/service/parser.ts
CHANGED
|
@@ -60,7 +60,7 @@ export class RawBodyParser implements TypeParser {
|
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
//
|
|
63
|
+
// At this stage, we can be sure we are dealing with an interface
|
|
64
64
|
let typeAsInterface = currentType as InterfaceMirror;
|
|
65
65
|
if (!typeAsInterface.extended_interfaces.length) {
|
|
66
66
|
typesWithFields.push(currentType);
|
package/src/settings.ts
CHANGED
|
@@ -40,9 +40,6 @@ 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;
|
|
46
43
|
}
|
|
47
44
|
|
|
48
45
|
export class Settings {
|
|
@@ -147,16 +144,4 @@ export class Settings {
|
|
|
147
144
|
}
|
|
148
145
|
return [];
|
|
149
146
|
}
|
|
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
|
-
}
|
|
162
147
|
}
|
|
@@ -10,6 +10,8 @@ export class ClassMirrorBuilder {
|
|
|
10
10
|
private docComment?: DocComment;
|
|
11
11
|
private methods: MethodMirror[] = [];
|
|
12
12
|
private fields: FieldMirror[] = [];
|
|
13
|
+
private innerClasses: ClassMirror[] = [];
|
|
14
|
+
private extendedClass: string | undefined;
|
|
13
15
|
|
|
14
16
|
withName(name: string): ClassMirrorBuilder {
|
|
15
17
|
this.name = name;
|
|
@@ -36,6 +38,16 @@ export class ClassMirrorBuilder {
|
|
|
36
38
|
return this;
|
|
37
39
|
}
|
|
38
40
|
|
|
41
|
+
addInnerClass(innerClass: ClassMirror): ClassMirrorBuilder {
|
|
42
|
+
this.innerClasses.push(innerClass);
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
withExtendedClass(extendedClass: string): ClassMirrorBuilder {
|
|
47
|
+
this.extendedClass = extendedClass;
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
39
51
|
build(): ClassMirror {
|
|
40
52
|
return {
|
|
41
53
|
annotations: this.annotations,
|
|
@@ -48,9 +60,10 @@ export class ClassMirrorBuilder {
|
|
|
48
60
|
constructors: [],
|
|
49
61
|
enums: [],
|
|
50
62
|
interfaces: [],
|
|
51
|
-
classes:
|
|
63
|
+
classes: this.innerClasses,
|
|
52
64
|
access_modifier: 'public',
|
|
53
65
|
docComment: this.docComment,
|
|
66
|
+
extended_class: this.extendedClass,
|
|
54
67
|
};
|
|
55
68
|
}
|
|
56
69
|
}
|
|
@@ -3,7 +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 '../../
|
|
6
|
+
import { StringOrLink } from '../../core/renderable/types';
|
|
7
7
|
|
|
8
8
|
export default class ClassFileGeneratorHelper {
|
|
9
9
|
public static getSanitizedGroup(classModel: Type) {
|
|
@@ -1,32 +1,73 @@
|
|
|
1
1
|
export const classMarkdownTemplate = `
|
|
2
|
-
|
|
2
|
+
{{ heading headingLevel heading }}
|
|
3
3
|
{{#if classModifier}}
|
|
4
4
|
\`{{classModifier}}\`
|
|
5
5
|
{{/if}}
|
|
6
6
|
|
|
7
|
-
{{>
|
|
7
|
+
{{> typeDocumentation}}
|
|
8
8
|
|
|
9
|
-
{{#if extends}}
|
|
10
|
-
**
|
|
11
|
-
{{extends}}
|
|
9
|
+
{{#if extends.length}}
|
|
10
|
+
**Inheritance**
|
|
11
|
+
{{#each extends}}{{link this}}{{#unless @last}} < {{/unless}}{{/each}}
|
|
12
12
|
{{/if}}
|
|
13
13
|
|
|
14
14
|
{{#if implements}}
|
|
15
15
|
**Implements**
|
|
16
16
|
{{#each implements}}
|
|
17
|
-
{{this}}{{#unless @last}}, {{/unless}}
|
|
17
|
+
{{link this}}{{#unless @last}}, {{/unless}}
|
|
18
18
|
{{/each}}
|
|
19
19
|
{{/if}}
|
|
20
20
|
|
|
21
|
-
{{#if fields}}
|
|
22
|
-
{{
|
|
21
|
+
{{#if fields.value}}
|
|
22
|
+
{{#if fields.isGrouped}}
|
|
23
|
+
{{> groupedMembersPartialTemplate fields subTemplate="fieldsPartialTemplate"}}
|
|
24
|
+
{{else}}
|
|
25
|
+
{{> fieldsPartialTemplate fields}}
|
|
26
|
+
{{/if}}
|
|
27
|
+
{{/if}}
|
|
28
|
+
|
|
29
|
+
{{#if properties.value}}
|
|
30
|
+
{{#if properties.isGrouped}}
|
|
31
|
+
{{> groupedMembersPartialTemplate properties subTemplate="fieldsPartialTemplate"}}
|
|
32
|
+
{{else}}
|
|
33
|
+
{{> fieldsPartialTemplate properties}}
|
|
34
|
+
{{/if}}
|
|
23
35
|
{{/if}}
|
|
24
36
|
|
|
25
|
-
{{#if constructors}}
|
|
26
|
-
{{
|
|
37
|
+
{{#if constructors.value}}
|
|
38
|
+
{{#if constructors.isGrouped}}
|
|
39
|
+
{{> groupedMembersPartialTemplate constructors subTemplate="constructorsPartialTemplate"}}
|
|
40
|
+
{{else}}
|
|
41
|
+
{{> constructorsPartialTemplate constructors}}
|
|
42
|
+
{{/if}}
|
|
43
|
+
{{/if}}
|
|
44
|
+
|
|
45
|
+
{{#if methods.value}}
|
|
46
|
+
{{#if methods.isGrouped}}
|
|
47
|
+
{{> groupedMembersPartialTemplate methods subTemplate="methodsPartialTemplate"}}
|
|
48
|
+
{{else}}
|
|
49
|
+
{{> methodsPartialTemplate methods}}
|
|
50
|
+
{{/if}}
|
|
27
51
|
{{/if}}
|
|
28
52
|
|
|
29
|
-
{{#if
|
|
30
|
-
{{
|
|
53
|
+
{{#if innerClasses.value}}
|
|
54
|
+
{{ heading innerClasses.headingLevel innerClasses.heading }}
|
|
55
|
+
{{#each innerClasses.value}}
|
|
56
|
+
{{> classTemplate this}}
|
|
57
|
+
{{/each}}
|
|
58
|
+
{{/if}}
|
|
59
|
+
|
|
60
|
+
{{#if innerEnums.value}}
|
|
61
|
+
{{ heading innerEnums.headingLevel innerEnums.heading }}
|
|
62
|
+
{{#each innerEnums.value}}
|
|
63
|
+
{{> enumTemplate this}}
|
|
64
|
+
{{/each}}
|
|
65
|
+
{{/if}}
|
|
66
|
+
|
|
67
|
+
{{#if innerInterfaces.value}}
|
|
68
|
+
{{ heading innerInterfaces.headingLevel innerInterfaces.heading }}
|
|
69
|
+
{{#each innerInterfaces.value}}
|
|
70
|
+
{{> interfaceTemplate this}}
|
|
71
|
+
{{/each}}
|
|
31
72
|
{{/if}}
|
|
32
73
|
`.trim();
|
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
export const constructorsPartialTemplate = `
|
|
2
|
-
|
|
3
|
-
{{#each
|
|
4
|
-
|
|
2
|
+
{{ heading headingLevel heading }}
|
|
3
|
+
{{#each value}}
|
|
4
|
+
{{{ heading headingLevel (inlineCode heading) }}}
|
|
5
5
|
|
|
6
6
|
{{#> documentablePartialTemplate}}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
{{signature}}
|
|
11
|
-
\`\`\`
|
|
8
|
+
{{ heading signature.headingLevel signature.heading }}
|
|
9
|
+
{{ code "apex" signature.value }}
|
|
12
10
|
|
|
13
|
-
{{#if parameters}}
|
|
14
|
-
|
|
11
|
+
{{#if parameters.value}}
|
|
12
|
+
{{ heading parameters.headingLevel parameters.heading }}
|
|
15
13
|
| Name | Type | Description |
|
|
16
14
|
|------|------|-------------|
|
|
17
|
-
{{#each parameters}}
|
|
15
|
+
{{#each parameters.value}}
|
|
18
16
|
| {{name}} | {{type}} | {{description}} |
|
|
19
17
|
{{/each}}
|
|
20
18
|
{{/if}}
|
|
21
19
|
|
|
22
|
-
{{#if throws}}
|
|
23
|
-
|
|
24
|
-
{{#each throws}}
|
|
25
|
-
{{this.type}}: {{this.description}}
|
|
20
|
+
{{#if throws.value}}
|
|
21
|
+
{{ heading throws.headingLevel throws.heading }}
|
|
22
|
+
{{#each throws.value}}
|
|
23
|
+
{{link this.type}}: {{this.description}}
|
|
26
24
|
|
|
27
25
|
{{/each}}
|
|
28
26
|
{{/if}}
|
|
29
|
-
|
|
30
27
|
{{/documentablePartialTemplate}}
|
|
31
28
|
|
|
32
29
|
{{#unless @last}}---{{/unless}}
|
|
33
|
-
{{/each}}
|
|
34
30
|
|
|
31
|
+
{{/each}}
|
|
35
32
|
`.trim();
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
export const documentablePartialTemplate = `
|
|
2
|
-
{{#each annotations}}
|
|
2
|
+
{{#each doc.annotations}}
|
|
3
3
|
\`{{this}}\`
|
|
4
4
|
{{/each}}
|
|
5
5
|
|
|
6
|
-
{{description}}
|
|
6
|
+
{{withLinks doc.description}}
|
|
7
7
|
|
|
8
|
-
{{#each customTags}}
|
|
9
|
-
**{{splitAndCapitalize name}}** {{description}}
|
|
8
|
+
{{#each doc.customTags}}
|
|
9
|
+
**{{splitAndCapitalize name}}** {{withLinks description}}
|
|
10
10
|
|
|
11
11
|
{{/each}}
|
|
12
12
|
|
|
13
13
|
{{> @partial-block}}
|
|
14
14
|
|
|
15
|
-
{{
|
|
15
|
+
{{#if doc.mermaid.value}}
|
|
16
|
+
{{ heading doc.mermaid.headingLevel doc.mermaid.heading }}
|
|
17
|
+
{{code "mermaid" doc.mermaid.value}}
|
|
18
|
+
{{/if}}
|
|
16
19
|
|
|
17
|
-
{{#if example}}
|
|
18
|
-
|
|
19
|
-
{{
|
|
20
|
+
{{#if doc.example.value}}
|
|
21
|
+
{{ heading doc.example.headingLevel doc.example.heading }}
|
|
22
|
+
{{code "apex" doc.example.value}}
|
|
20
23
|
{{/if}}
|
|
21
24
|
`.trim();
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export const enumMarkdownTemplate = `
|
|
2
|
-
|
|
2
|
+
{{ heading headingLevel heading }}
|
|
3
3
|
|
|
4
|
-
{{>
|
|
4
|
+
{{> typeDocumentation }}
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
{{
|
|
6
|
+
{{ heading values.headingLevel values.heading }}
|
|
7
|
+
| Value | Description |
|
|
8
|
+
|-------|-------------|
|
|
9
|
+
{{#each values.value}}
|
|
10
|
+
| {{value}} | {{description}} |
|
|
10
11
|
{{/each}}
|
|
11
12
|
`.trim();
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
export const fieldsPartialTemplate = `
|
|
2
|
-
|
|
3
|
-
{{#each
|
|
4
|
-
|
|
2
|
+
{{ heading headingLevel heading }}
|
|
3
|
+
{{#each value}}
|
|
4
|
+
{{{ heading headingLevel (inlineCode heading) }}}
|
|
5
5
|
|
|
6
6
|
{{#if inherited}}
|
|
7
7
|
*Inherited*
|
|
8
8
|
{{/if}}
|
|
9
9
|
|
|
10
|
-
{{#> documentablePartialTemplate}}
|
|
10
|
+
{{#> documentablePartialTemplate }}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
{{
|
|
12
|
+
{{ heading signature.headingLevel signature.heading }}
|
|
13
|
+
{{ code "apex" signature.value }}
|
|
14
|
+
|
|
15
|
+
{{ heading type.headingLevel type.heading }}
|
|
16
|
+
{{link type.value}}
|
|
14
17
|
|
|
15
18
|
{{/documentablePartialTemplate}}
|
|
16
19
|
|