@cparra/apexdocs 2.24.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/.eslintrc.js +12 -12
- package/.github/workflows/ci.yaml +22 -0
- package/.github/workflows/close_stale.yml +22 -22
- package/.prettierrc.js +7 -7
- package/LICENSE +21 -21
- package/README.md +742 -718
- package/apexdocs.config.ts +13 -13
- package/docs/{README.md → __old/README.md} +1 -1
- package/docs/{restapi.json → __old/restapi.json} +589 -589
- package/docs/{types → __old/types}/Classes/nspc.ChildClass.md +97 -97
- package/docs/{types → __old/types}/Main/nspc.SampleClass.md +189 -189
- package/examples/force-app/main/default/classes/AnotherInterface.cls +16 -16
- package/examples/force-app/main/default/classes/ChildClass.cls +42 -42
- package/examples/force-app/main/default/classes/EscapedAnnotations.cls +5 -5
- package/examples/force-app/main/default/classes/GrandparentClass.cls +4 -4
- package/examples/force-app/main/default/classes/GroupedClass.cls +8 -8
- package/examples/force-app/main/default/classes/MemberGrouping.cls +17 -17
- package/examples/force-app/main/default/classes/ParentClass.cls +16 -16
- package/examples/force-app/main/default/classes/SampleClass.cls +166 -166
- package/examples/force-app/main/default/classes/SampleClass.cls-meta.xml +5 -5
- package/examples/force-app/main/default/classes/SampleClassWithoutModifier.cls +9 -9
- package/examples/force-app/main/default/classes/SampleInterface.cls +16 -16
- package/examples/force-app/main/default/restapi/SampleRestResource.cls +195 -195
- package/examples/force-app/main/default/restapi/SampleRestResourceToSkip.cls +35 -35
- package/examples/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +24 -24
- package/examples/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +15 -15
- package/examples/force-app/main/default/restapi/references/Reference1.cls +9 -9
- package/examples/force-app/main/default/restapi/references/Reference2.cls +9 -9
- package/examples/force-app/main/default/restapi/references/Reference3.cls +3 -3
- package/examples/force-app/main/default/restapi/references/Reference4.cls +3 -3
- package/examples/force-app/main/default/restapi/references/Reference5.cls +3 -3
- package/examples/force-app/main/default/restapi/references/Reference6.cls +6 -6
- package/examples/force-app/main/default/restapi/references/Reference7.cls +3 -3
- package/examples/includes/header.md +3 -3
- 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/jest.config.js +5 -5
- 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.d.ts +13 -13
- package/lib/application/Apexdocs.js +79 -76
- package/lib/application/Apexdocs.js.map +1 -1
- package/lib/cli/generate.d.ts +2 -2
- package/lib/cli/generate.js +156 -130
- package/lib/cli/generate.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +17 -17
- package/lib/model/apex-bundle.d.ts +6 -6
- package/lib/model/apex-bundle.js +10 -10
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.d.ts +7 -7
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.js +13 -13
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.d.ts +7 -7
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.js +11 -11
- package/lib/model/inheritance.d.ts +8 -8
- package/lib/model/inheritance.js +2 -2
- package/lib/model/manifest.d.ts +22 -22
- package/lib/model/manifest.js +46 -46
- package/lib/model/manifest.js.map +1 -1
- package/lib/model/markdown-file.d.ts +16 -16
- package/lib/model/markdown-file.js +109 -106
- package/lib/model/markdown-file.js.map +1 -1
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.d.ts +8 -8
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +46 -43
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -1
- package/lib/model/markdown-generation-util/field-declaration-util.d.ts +3 -3
- package/lib/model/markdown-generation-util/field-declaration-util.js +54 -54
- package/lib/model/markdown-generation-util/index.d.ts +3 -3
- package/lib/model/markdown-generation-util/index.js +19 -19
- package/lib/model/markdown-generation-util/method-declaration-util.d.ts +4 -4
- package/lib/model/markdown-generation-util/method-declaration-util.js +114 -114
- package/lib/model/markdown-generation-util/type-declaration-util.d.ts +3 -3
- package/lib/model/markdown-generation-util/type-declaration-util.js +81 -81
- package/lib/model/markdown-home-file.d.ts +11 -11
- package/lib/model/markdown-home-file.js +56 -53
- package/lib/model/markdown-home-file.js.map +1 -1
- package/lib/model/markdown-type-file.d.ts +26 -26
- package/lib/model/markdown-type-file.js +136 -133
- package/lib/model/markdown-type-file.js.map +1 -1
- package/lib/model/openapi/apex-doc-types.d.ts +19 -19
- package/lib/model/openapi/apex-doc-types.js +4 -4
- package/lib/model/openapi/open-api-types.d.ts +93 -93
- package/lib/model/openapi/open-api-types.js +2 -2
- package/lib/model/openapi/open-api.d.ts +16 -16
- package/lib/model/openapi/open-api.js +33 -33
- package/lib/model/openapi/openapi-type-file.d.ts +7 -7
- package/lib/model/openapi/openapi-type-file.js +16 -16
- package/lib/model/outputFile.d.ts +10 -10
- package/lib/model/outputFile.js +28 -28
- package/lib/model/types-repository.d.ts +16 -16
- package/lib/model/types-repository.js +53 -53
- package/lib/service/apex-file-reader.d.ts +14 -14
- package/lib/service/apex-file-reader.js +48 -45
- package/lib/service/apex-file-reader.js.map +1 -1
- package/lib/service/file-system.d.ts +14 -14
- package/lib/service/file-system.js +47 -24
- package/lib/service/file-system.js.map +1 -1
- package/lib/service/file-writer.d.ts +6 -6
- package/lib/service/file-writer.js +56 -33
- package/lib/service/file-writer.js.map +1 -1
- package/lib/service/manifest-factory.d.ts +10 -10
- package/lib/service/manifest-factory.js +16 -13
- package/lib/service/manifest-factory.js.map +1 -1
- package/lib/service/metadata-processor.d.ts +3 -3
- package/lib/service/metadata-processor.js +16 -16
- package/lib/service/parser.d.ts +21 -21
- package/lib/service/parser.js +137 -134
- package/lib/service/parser.js.map +1 -1
- package/lib/service/state.d.ts +9 -9
- package/lib/service/state.js +19 -19
- package/lib/service/walkers/class-walker.d.ts +4 -4
- package/lib/service/walkers/class-walker.js +32 -32
- package/lib/service/walkers/enum-walker.d.ts +4 -4
- package/lib/service/walkers/enum-walker.js +10 -10
- package/lib/service/walkers/interface-walker.d.ts +4 -4
- package/lib/service/walkers/interface-walker.js +14 -14
- package/lib/service/walkers/walker-factory.d.ts +5 -5
- package/lib/service/walkers/walker-factory.js +20 -20
- package/lib/service/walkers/walker.d.ts +19 -19
- package/lib/service/walkers/walker.js +16 -16
- package/lib/settings.d.ts +70 -64
- package/lib/settings.js +99 -88
- 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/AnnotationBuilder.d.ts +12 -12
- package/lib/test-helpers/AnnotationBuilder.js +30 -30
- package/lib/test-helpers/ClassMirrorBuilder.d.ts +18 -18
- package/lib/test-helpers/ClassMirrorBuilder.js +53 -53
- package/lib/test-helpers/DocCommentAnnotationBuilder.d.ts +8 -8
- package/lib/test-helpers/DocCommentAnnotationBuilder.js +25 -25
- package/lib/test-helpers/DocCommentBuilder.d.ts +12 -12
- package/lib/test-helpers/DocCommentBuilder.js +37 -37
- package/lib/test-helpers/FieldMirrorBuilder.d.ts +18 -18
- package/lib/test-helpers/FieldMirrorBuilder.js +53 -53
- 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 +29 -10
- package/lib/test-helpers/MethodMirrorBuilder.js +71 -36
- package/lib/test-helpers/MethodMirrorBuilder.js.map +1 -1
- package/lib/test-helpers/SettingsBuilder.d.ts +8 -8
- package/lib/test-helpers/SettingsBuilder.js +26 -26
- package/lib/transpiler/factory.d.ts +6 -6
- package/lib/transpiler/factory.js +34 -31
- package/lib/transpiler/factory.js.map +1 -1
- package/lib/transpiler/file-container.d.ts +6 -6
- package/lib/transpiler/file-container.js +15 -15
- package/lib/transpiler/generator-choices.d.ts +1 -1
- package/lib/transpiler/generator-choices.js +2 -2
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +11 -8
- package/lib/transpiler/markdown/class-file-generatorHelper.js +74 -55
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +6 -6
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js +12 -12
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +11 -11
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +50 -50
- package/lib/transpiler/markdown/markdown-transpiler-base.d.ts +11 -11
- package/lib/transpiler/markdown/markdown-transpiler-base.js +26 -23
- 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 +13 -6
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +121 -13
- 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.d.ts +13 -13
- package/lib/transpiler/openapi/open-api-docs-processor.js +77 -74
- package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -1
- package/lib/transpiler/openapi/parsers/Builder.d.ts +16 -16
- package/lib/transpiler/openapi/parsers/Builder.js +29 -29
- package/lib/transpiler/openapi/parsers/Builder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/MethodParser.d.ts +20 -20
- package/lib/transpiler/openapi/parsers/MethodParser.js +189 -166
- package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.d.ts +7 -7
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.js +10 -10
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.d.ts +39 -39
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +248 -225
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.d.ts +10 -10
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.js +19 -19
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.d.ts +7 -7
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js +21 -21
- package/lib/transpiler/processor-type-transpiler.d.ts +10 -10
- package/lib/transpiler/processor-type-transpiler.js +8 -8
- package/lib/transpiler/transpiler.d.ts +5 -5
- package/lib/transpiler/transpiler.js +29 -26
- package/lib/transpiler/transpiler.js.map +1 -1
- package/lib/util/error-logger.d.ts +8 -8
- package/lib/util/error-logger.js +89 -89
- package/lib/util/error-logger.js.map +1 -1
- package/lib/util/logger.d.ts +21 -21
- package/lib/util/logger.js +60 -57
- package/lib/util/logger.js.map +1 -1
- package/lib/util/string-utils.d.ts +2 -2
- package/lib/util/string-utils.js +14 -14
- package/package.json +79 -78
- 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 +21 -20
- package/tslint.json +5 -5
- 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/{index.html → __old/index.html} +0 -0
- /package/docs/{types → __old/types}/Classes/nspc.AnotherInterface.md +0 -0
- /package/docs/{types → __old/types}/Main/nspc.GroupedClass.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,741 @@
|
|
|
1
|
+
import { compile as testSubject } from '../compile';
|
|
2
|
+
import { ClassSource, EnumSource, InterfaceSource, Link, RenderableContent } from '../types';
|
|
3
|
+
|
|
4
|
+
jest.mock('../../settings', () => {
|
|
5
|
+
return {
|
|
6
|
+
Settings: {
|
|
7
|
+
getInstance: jest.fn(() => ({
|
|
8
|
+
getNamespace: jest.fn(() => 'MyNamespace'),
|
|
9
|
+
})),
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function renderableContentsToString(content?: RenderableContent[]) {
|
|
15
|
+
if (!content) {
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function reduceDescription(acc: string, curr: RenderableContent) {
|
|
20
|
+
if (typeof curr === 'string') {
|
|
21
|
+
return acc + curr;
|
|
22
|
+
} else if (Object.keys(curr).includes('title')) {
|
|
23
|
+
return acc + (curr as Link).title;
|
|
24
|
+
} else {
|
|
25
|
+
return acc;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return content.reduce(reduceDescription, '');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function linesToCodeBlock(_: string, lines: string[]): string {
|
|
33
|
+
return lines.join('\n');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function compile(template: string, source: EnumSource | InterfaceSource | ClassSource) {
|
|
37
|
+
return testSubject(template, source, {
|
|
38
|
+
renderableContentConverter: renderableContentsToString,
|
|
39
|
+
codeBlockConverter: linesToCodeBlock,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe('compile', () => {
|
|
44
|
+
describe('helpers', () => {
|
|
45
|
+
it('can split and capitalize text', () => {
|
|
46
|
+
const template = '{{splitAndCapitalize name}}';
|
|
47
|
+
|
|
48
|
+
const enumSource: EnumSource = {
|
|
49
|
+
__type: 'enum',
|
|
50
|
+
accessModifier: 'public',
|
|
51
|
+
name: 'my-enum',
|
|
52
|
+
values: [],
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const result = compile(template, enumSource);
|
|
56
|
+
|
|
57
|
+
expect(result).toBe('My Enum');
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('class', () => {
|
|
62
|
+
it('can reference the class name', () => {
|
|
63
|
+
const template = '{{name}} class';
|
|
64
|
+
|
|
65
|
+
const classSource: ClassSource = {
|
|
66
|
+
__type: 'class',
|
|
67
|
+
name: 'MyClass',
|
|
68
|
+
accessModifier: 'public',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const result = compile(template, classSource);
|
|
72
|
+
|
|
73
|
+
expect(result).toBe('MyClass class');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('can reference the class modifier', () => {
|
|
77
|
+
const template = '{{classModifier}} class';
|
|
78
|
+
|
|
79
|
+
const classSource: ClassSource = {
|
|
80
|
+
__type: 'class',
|
|
81
|
+
name: 'MyClass',
|
|
82
|
+
accessModifier: 'public',
|
|
83
|
+
classModifier: 'abstract',
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const result = compile(template, classSource);
|
|
87
|
+
|
|
88
|
+
expect(result).toBe('abstract class');
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('can reference the sharing modifier', () => {
|
|
92
|
+
const template = '{{sharingModifier}} class';
|
|
93
|
+
|
|
94
|
+
const classSource: ClassSource = {
|
|
95
|
+
__type: 'class',
|
|
96
|
+
name: 'MyClass',
|
|
97
|
+
accessModifier: 'public',
|
|
98
|
+
sharingModifier: 'with sharing',
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const result = compile(template, classSource);
|
|
102
|
+
|
|
103
|
+
expect(result).toBe('with sharing class');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('can reference the implemented interfaces', () => {
|
|
107
|
+
const template = '{{#each implements}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}';
|
|
108
|
+
|
|
109
|
+
const classSource: ClassSource = {
|
|
110
|
+
__type: 'class',
|
|
111
|
+
name: 'MyClass',
|
|
112
|
+
accessModifier: 'public',
|
|
113
|
+
implements: [
|
|
114
|
+
{ title: 'MyInterface', url: 'https://example.com' },
|
|
115
|
+
{ title: 'MyOtherInterface', url: 'https://example.com' },
|
|
116
|
+
],
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const result = compile(template, classSource);
|
|
120
|
+
|
|
121
|
+
expect(result).toBe('MyInterface, MyOtherInterface');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('can reference an extended class', () => {
|
|
125
|
+
const template = '{{extends}}';
|
|
126
|
+
|
|
127
|
+
const classSource: ClassSource = {
|
|
128
|
+
__type: 'class',
|
|
129
|
+
name: 'MyClass',
|
|
130
|
+
accessModifier: 'public',
|
|
131
|
+
extends: { title: 'MySuperClass', url: 'https://example.com' },
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const result = compile(template, classSource);
|
|
135
|
+
|
|
136
|
+
expect(result).toBe('MySuperClass');
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe('class fields', () => {
|
|
140
|
+
it('can reference the field name', () => {
|
|
141
|
+
const template = '{{#each fields}}{{name}}{{/each}}';
|
|
142
|
+
|
|
143
|
+
const classSource: ClassSource = {
|
|
144
|
+
__type: 'class',
|
|
145
|
+
name: 'MyClass',
|
|
146
|
+
accessModifier: 'public',
|
|
147
|
+
fields: [{ name: 'myField', type: 'String', accessModifier: 'public' }],
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const result = compile(template, classSource);
|
|
151
|
+
|
|
152
|
+
expect(result).toBe('myField');
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
it('can reference the field type', () => {
|
|
156
|
+
const template = '{{#each fields}}{{type}}{{/each}}';
|
|
157
|
+
|
|
158
|
+
const classSource: ClassSource = {
|
|
159
|
+
__type: 'class',
|
|
160
|
+
name: 'MyClass',
|
|
161
|
+
accessModifier: 'public',
|
|
162
|
+
fields: [{ name: 'myField', type: 'String', accessModifier: 'public' }],
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const result = compile(template, classSource);
|
|
166
|
+
|
|
167
|
+
expect(result).toBe('String');
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('can reference the field access modifier', () => {
|
|
171
|
+
const template = '{{#each fields}}{{accessModifier}}{{/each}}';
|
|
172
|
+
|
|
173
|
+
const classSource: ClassSource = {
|
|
174
|
+
__type: 'class',
|
|
175
|
+
name: 'MyClass',
|
|
176
|
+
accessModifier: 'public',
|
|
177
|
+
fields: [{ name: 'myField', type: 'String', accessModifier: 'public' }],
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const result = compile(template, classSource);
|
|
181
|
+
|
|
182
|
+
expect(result).toBe('public');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
it('can reference if it is inherited', () => {
|
|
186
|
+
const template = '{{#each fields}}{{#if inherited}}Inherited{{/if}}{{/each}}';
|
|
187
|
+
|
|
188
|
+
const classSource: ClassSource = {
|
|
189
|
+
__type: 'class',
|
|
190
|
+
name: 'MyClass',
|
|
191
|
+
accessModifier: 'public',
|
|
192
|
+
fields: [{ name: 'myField', type: 'String', accessModifier: 'public', inherited: true }],
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const result = compile(template, classSource);
|
|
196
|
+
|
|
197
|
+
expect(result).toBe('Inherited');
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
describe('interface', () => {
|
|
203
|
+
it('can reference the interface name', () => {
|
|
204
|
+
const template = '{{name}} interface';
|
|
205
|
+
|
|
206
|
+
const interfaceSource: InterfaceSource = {
|
|
207
|
+
__type: 'interface',
|
|
208
|
+
name: 'MyInterface',
|
|
209
|
+
accessModifier: 'public',
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const result = compile(template, interfaceSource);
|
|
213
|
+
|
|
214
|
+
expect(result).toBe('MyInterface interface');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it('can reference the access modifier', () => {
|
|
218
|
+
const template = '{{accessModifier}} interface';
|
|
219
|
+
|
|
220
|
+
const interfaceSource: InterfaceSource = {
|
|
221
|
+
__type: 'interface',
|
|
222
|
+
name: 'MyInterface',
|
|
223
|
+
accessModifier: 'public',
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const result = compile(template, interfaceSource);
|
|
227
|
+
|
|
228
|
+
expect(result).toBe('public interface');
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('can reference the interface name with annotations', () => {
|
|
232
|
+
const template = '{{name}} interface {{#each annotations}}{{this}} {{/each}}';
|
|
233
|
+
|
|
234
|
+
const interfaceSource: InterfaceSource = {
|
|
235
|
+
__type: 'interface',
|
|
236
|
+
name: 'MyInterface',
|
|
237
|
+
accessModifier: 'public',
|
|
238
|
+
annotations: ['MyAnnotation'],
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
const result = compile(template, interfaceSource);
|
|
242
|
+
|
|
243
|
+
expect(result).toBe('MyInterface interface MyAnnotation');
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it('can reference the interface name with a description', () => {
|
|
247
|
+
const template = '{{description}}';
|
|
248
|
+
|
|
249
|
+
const interfaceSource: InterfaceSource = {
|
|
250
|
+
__type: 'interface',
|
|
251
|
+
name: 'MyInterface',
|
|
252
|
+
accessModifier: 'public',
|
|
253
|
+
description: ['An interface of things'],
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
const result = compile(template, interfaceSource);
|
|
257
|
+
|
|
258
|
+
expect(result).toBe('An interface of things');
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('can reference a description with links', () => {
|
|
262
|
+
const template = '{{description}}';
|
|
263
|
+
|
|
264
|
+
const interfaceSource: InterfaceSource = {
|
|
265
|
+
__type: 'interface',
|
|
266
|
+
name: 'MyInterface',
|
|
267
|
+
accessModifier: 'public',
|
|
268
|
+
description: ['An interface of things: ', { title: 'More info', url: 'https://example.com' }],
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const result = compile(template, interfaceSource);
|
|
272
|
+
|
|
273
|
+
expect(result).toBe('An interface of things: More info');
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('can reference the extended interfaces of an interface', () => {
|
|
277
|
+
const template = '{{#each extends}}{{this}}{{#unless @last}}, {{/unless}}{{/each}}';
|
|
278
|
+
|
|
279
|
+
const interfaceSource: InterfaceSource = {
|
|
280
|
+
__type: 'interface',
|
|
281
|
+
name: 'MyInterface',
|
|
282
|
+
accessModifier: 'public',
|
|
283
|
+
extends: [
|
|
284
|
+
{ title: 'MyInterface', url: 'https://example.com' },
|
|
285
|
+
{ title: 'MyOtherInterface', url: 'https://example.com' },
|
|
286
|
+
],
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
const result = compile(template, interfaceSource);
|
|
290
|
+
|
|
291
|
+
expect(result).toBe('MyInterface, MyOtherInterface');
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
it('can have a mermaid block at the top level description', () => {
|
|
295
|
+
const template = '{{{mermaid}}}';
|
|
296
|
+
|
|
297
|
+
const interfaceSource: InterfaceSource = {
|
|
298
|
+
__type: 'interface',
|
|
299
|
+
name: 'MyInterface',
|
|
300
|
+
accessModifier: 'public',
|
|
301
|
+
mermaid: ['graph TD;', 'A-->B;', 'A-->C;'],
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
const result = compile(template, interfaceSource);
|
|
305
|
+
|
|
306
|
+
expect(result).toBe('graph TD;\nA-->B;\nA-->C;');
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
it('can have an example block at the top level description', () => {
|
|
310
|
+
const template = '{{{example}}}';
|
|
311
|
+
|
|
312
|
+
const interfaceSource: InterfaceSource = {
|
|
313
|
+
__type: 'interface',
|
|
314
|
+
name: 'MyInterface',
|
|
315
|
+
accessModifier: 'public',
|
|
316
|
+
example: ['Example code block'],
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const result = compile(template, interfaceSource);
|
|
320
|
+
|
|
321
|
+
expect(result).toBe('Example code block');
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('can display method titles', () => {
|
|
325
|
+
const template = '{{#each methods}}{{title}}{{/each}}';
|
|
326
|
+
|
|
327
|
+
const interfaceSource: InterfaceSource = {
|
|
328
|
+
__type: 'interface',
|
|
329
|
+
name: 'MyInterface',
|
|
330
|
+
accessModifier: 'public',
|
|
331
|
+
methods: [{ title: 'myMethod()', signature: 'void myMethod()' }],
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const result = compile(template, interfaceSource);
|
|
335
|
+
|
|
336
|
+
expect(result).toBe('myMethod()');
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
it('can display method signatures', () => {
|
|
340
|
+
const template = '{{#each methods}}{{signature}}{{/each}}';
|
|
341
|
+
|
|
342
|
+
const interfaceSource: InterfaceSource = {
|
|
343
|
+
__type: 'interface',
|
|
344
|
+
name: 'MyInterface',
|
|
345
|
+
accessModifier: 'public',
|
|
346
|
+
methods: [{ title: 'myMethod()', signature: 'void myMethod()' }],
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const result = compile(template, interfaceSource);
|
|
350
|
+
|
|
351
|
+
expect(result).toBe('void myMethod()');
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('can display methods with a description', () => {
|
|
355
|
+
const template = '{{#each methods}}{{signature}} - {{description}}{{/each}}';
|
|
356
|
+
|
|
357
|
+
const interfaceSource: InterfaceSource = {
|
|
358
|
+
__type: 'interface',
|
|
359
|
+
name: 'MyInterface',
|
|
360
|
+
accessModifier: 'public',
|
|
361
|
+
methods: [{ title: 'myMethod()', signature: 'void myMethod()', description: ['The method'] }],
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
const result = compile(template, interfaceSource);
|
|
365
|
+
|
|
366
|
+
expect(result).toBe('void myMethod() - The method');
|
|
367
|
+
});
|
|
368
|
+
|
|
369
|
+
it('can display annotations of a method', () => {
|
|
370
|
+
const template = '{{#each methods}}{{#each annotations}}{{this}}{{/each}}{{/each}}';
|
|
371
|
+
|
|
372
|
+
const interfaceSource: InterfaceSource = {
|
|
373
|
+
__type: 'interface',
|
|
374
|
+
name: 'MyInterface',
|
|
375
|
+
accessModifier: 'public',
|
|
376
|
+
methods: [{ title: 'myMethod()', signature: 'void myMethod()', annotations: ['MyAnnotation'] }],
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const result = compile(template, interfaceSource);
|
|
380
|
+
|
|
381
|
+
expect(result).toBe('MyAnnotation');
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
it('can display the parameters of a method', () => {
|
|
385
|
+
const template = '{{#each methods}}{{#each parameters}}{{name}} - {{description}}{{/each}}{{/each}}';
|
|
386
|
+
|
|
387
|
+
const parameters = [
|
|
388
|
+
{ name: 'arg1', type: 'String', description: ['The first argument'] },
|
|
389
|
+
{ name: 'arg2', type: 'Integer' },
|
|
390
|
+
];
|
|
391
|
+
const interfaceSource: InterfaceSource = {
|
|
392
|
+
__type: 'interface',
|
|
393
|
+
name: 'MyInterface',
|
|
394
|
+
accessModifier: 'public',
|
|
395
|
+
methods: [{ title: 'myMethod()', signature: 'void myMethod(String arg1, Integer arg2)', parameters }],
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
const result = compile(template, interfaceSource);
|
|
399
|
+
|
|
400
|
+
expect(result).toBe('arg1 - The first argumentarg2 -');
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it('can display the return value of a method', () => {
|
|
404
|
+
const template = '{{#each methods}}{{returnType.type}}{{/each}}';
|
|
405
|
+
|
|
406
|
+
const interfaceSource: InterfaceSource = {
|
|
407
|
+
__type: 'interface',
|
|
408
|
+
name: 'MyInterface',
|
|
409
|
+
accessModifier: 'public',
|
|
410
|
+
methods: [
|
|
411
|
+
{
|
|
412
|
+
title: 'myMethod()',
|
|
413
|
+
signature: 'String myMethod()',
|
|
414
|
+
returnType: {
|
|
415
|
+
type: 'String',
|
|
416
|
+
description: ['The return value'],
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
],
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const result = compile(template, interfaceSource);
|
|
423
|
+
|
|
424
|
+
expect(result).toBe('String');
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it('can display the exceptions that a method throws', () => {
|
|
428
|
+
const template = '{{#each methods}}{{#each throws}}{{type}}{{/each}}{{/each}}';
|
|
429
|
+
|
|
430
|
+
const interfaceSource: InterfaceSource = {
|
|
431
|
+
__type: 'interface',
|
|
432
|
+
name: 'MyInterface',
|
|
433
|
+
accessModifier: 'public',
|
|
434
|
+
methods: [
|
|
435
|
+
{
|
|
436
|
+
title: 'myMethod()',
|
|
437
|
+
signature: 'void myMethod()',
|
|
438
|
+
throws: [{ type: 'IOException', description: ['An exception'] }],
|
|
439
|
+
},
|
|
440
|
+
],
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
const result = compile(template, interfaceSource);
|
|
444
|
+
|
|
445
|
+
expect(result).toBe('IOException');
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
it('can display custom tags in a method', () => {
|
|
449
|
+
const template = '{{#each methods}}{{#each customTags}}{{name}} - {{value}}{{/each}}{{/each}}';
|
|
450
|
+
|
|
451
|
+
const interfaceSource: InterfaceSource = {
|
|
452
|
+
__type: 'interface',
|
|
453
|
+
name: 'MyInterface',
|
|
454
|
+
accessModifier: 'public',
|
|
455
|
+
methods: [
|
|
456
|
+
{
|
|
457
|
+
title: 'myMethod()',
|
|
458
|
+
signature: 'void myMethod()',
|
|
459
|
+
customTags: [{ name: 'CustomTag', description: ['My custom tag'] }],
|
|
460
|
+
},
|
|
461
|
+
],
|
|
462
|
+
};
|
|
463
|
+
|
|
464
|
+
const result = compile(template, interfaceSource);
|
|
465
|
+
|
|
466
|
+
expect(result).toBe('CustomTag - My custom tag');
|
|
467
|
+
});
|
|
468
|
+
|
|
469
|
+
it('can display mermaid blocks in a method', () => {
|
|
470
|
+
const template = '{{#each methods}}{{{mermaid}}}{{/each}}';
|
|
471
|
+
|
|
472
|
+
const interfaceSource: InterfaceSource = {
|
|
473
|
+
__type: 'interface',
|
|
474
|
+
name: 'MyInterface',
|
|
475
|
+
accessModifier: 'public',
|
|
476
|
+
methods: [
|
|
477
|
+
{
|
|
478
|
+
title: 'myMethod()',
|
|
479
|
+
signature: 'void myMethod()',
|
|
480
|
+
mermaid: ['graph TD;', 'A-->B;', 'A-->C;'],
|
|
481
|
+
},
|
|
482
|
+
],
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
const result = compile(template, interfaceSource);
|
|
486
|
+
|
|
487
|
+
expect(result).toBe('graph TD;\nA-->B;\nA-->C;');
|
|
488
|
+
});
|
|
489
|
+
|
|
490
|
+
it('can display example blocks in a method', () => {
|
|
491
|
+
const template = '{{#each methods}}{{{example}}}{{/each}}';
|
|
492
|
+
|
|
493
|
+
const interfaceSource: InterfaceSource = {
|
|
494
|
+
__type: 'interface',
|
|
495
|
+
name: 'MyInterface',
|
|
496
|
+
accessModifier: 'public',
|
|
497
|
+
methods: [
|
|
498
|
+
{
|
|
499
|
+
title: 'myMethod()',
|
|
500
|
+
signature: 'void myMethod()',
|
|
501
|
+
example: ['Example code block'],
|
|
502
|
+
},
|
|
503
|
+
],
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
const result = compile(template, interfaceSource);
|
|
507
|
+
|
|
508
|
+
expect(result).toBe('Example code block');
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it('can display if a method was inherited from a super interface', () => {
|
|
512
|
+
const template = '{{#each methods}}{{#if inherited}}Inherited{{/if}}{{/each}}';
|
|
513
|
+
|
|
514
|
+
const interfaceSource: InterfaceSource = {
|
|
515
|
+
__type: 'interface',
|
|
516
|
+
name: 'MyInterface',
|
|
517
|
+
accessModifier: 'public',
|
|
518
|
+
methods: [
|
|
519
|
+
{
|
|
520
|
+
title: 'myMethod()',
|
|
521
|
+
signature: 'void myMethod()',
|
|
522
|
+
inherited: true,
|
|
523
|
+
},
|
|
524
|
+
],
|
|
525
|
+
};
|
|
526
|
+
|
|
527
|
+
const result = compile(template, interfaceSource);
|
|
528
|
+
|
|
529
|
+
expect(result).toBe('Inherited');
|
|
530
|
+
});
|
|
531
|
+
});
|
|
532
|
+
|
|
533
|
+
describe('enum', () => {
|
|
534
|
+
it('can reference the enum name', () => {
|
|
535
|
+
const template = '{{name}} enum';
|
|
536
|
+
|
|
537
|
+
const enumSource: EnumSource = {
|
|
538
|
+
__type: 'enum',
|
|
539
|
+
accessModifier: 'public',
|
|
540
|
+
name: 'MyEnum',
|
|
541
|
+
values: [],
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
const result = compile(template, enumSource);
|
|
545
|
+
|
|
546
|
+
expect(result).toBe('MyEnum enum');
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
it('can reference the access modifier', () => {
|
|
550
|
+
const template = '{{accessModifier}} enum';
|
|
551
|
+
|
|
552
|
+
const enumSource: EnumSource = {
|
|
553
|
+
__type: 'enum',
|
|
554
|
+
accessModifier: 'public',
|
|
555
|
+
name: 'MyEnum',
|
|
556
|
+
values: [],
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
const result = compile(template, enumSource);
|
|
560
|
+
|
|
561
|
+
expect(result).toBe('public enum');
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
it('can reference the enum name with a description', () => {
|
|
565
|
+
const template = '{{description}}';
|
|
566
|
+
|
|
567
|
+
const enumSource: EnumSource = {
|
|
568
|
+
__type: 'enum',
|
|
569
|
+
accessModifier: 'public',
|
|
570
|
+
name: 'MyEnum',
|
|
571
|
+
values: [],
|
|
572
|
+
description: ['An enum of things'],
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
const result = compile(template, enumSource);
|
|
576
|
+
|
|
577
|
+
expect(result).toBe('An enum of things');
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
it('can reference a description with links', () => {
|
|
581
|
+
const template = '{{description}}';
|
|
582
|
+
|
|
583
|
+
const enumSource: EnumSource = {
|
|
584
|
+
__type: 'enum',
|
|
585
|
+
accessModifier: 'public',
|
|
586
|
+
name: 'MyEnum',
|
|
587
|
+
values: [],
|
|
588
|
+
description: ['An enum of things: ', { title: 'More info', url: 'https://example.com' }],
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
const result = compile(template, enumSource);
|
|
592
|
+
|
|
593
|
+
expect(result).toBe('An enum of things: More info');
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
it('can have a mermaid block at the top level description', () => {
|
|
597
|
+
const template = '{{{mermaid}}}';
|
|
598
|
+
|
|
599
|
+
const enumSource: EnumSource = {
|
|
600
|
+
__type: 'enum',
|
|
601
|
+
name: 'MyEnum',
|
|
602
|
+
accessModifier: 'public',
|
|
603
|
+
mermaid: ['graph TD;', 'A-->B;', 'A-->C;'],
|
|
604
|
+
values: [],
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
const result = compile(template, enumSource);
|
|
608
|
+
|
|
609
|
+
expect(result).toBe('graph TD;\nA-->B;\nA-->C;');
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
it('can have an example block at the top level description', () => {
|
|
613
|
+
const template = '{{{example}}}';
|
|
614
|
+
|
|
615
|
+
const enumSource: EnumSource = {
|
|
616
|
+
__type: 'enum',
|
|
617
|
+
name: 'MyEnum',
|
|
618
|
+
accessModifier: 'public',
|
|
619
|
+
example: ['Example code block'],
|
|
620
|
+
values: [],
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
const result = compile(template, enumSource);
|
|
624
|
+
|
|
625
|
+
expect(result).toBe('Example code block');
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
it('can reference enum values', () => {
|
|
629
|
+
const template = '{{#each values}}{{value}}{{/each}}';
|
|
630
|
+
|
|
631
|
+
const enumSource: EnumSource = {
|
|
632
|
+
__type: 'enum',
|
|
633
|
+
accessModifier: 'public',
|
|
634
|
+
name: 'MyEnum',
|
|
635
|
+
values: [{ value: 'Value1' }, { value: 'Value2' }],
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
const result = compile(template, enumSource);
|
|
639
|
+
|
|
640
|
+
expect(result).toBe('Value1Value2');
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
it('can reference enum values with a description', () => {
|
|
644
|
+
const template = '{{#each values}}{{value}} - {{description}}{{/each}}';
|
|
645
|
+
|
|
646
|
+
const enumSource: EnumSource = {
|
|
647
|
+
__type: 'enum',
|
|
648
|
+
accessModifier: 'public',
|
|
649
|
+
name: 'MyEnum',
|
|
650
|
+
values: [
|
|
651
|
+
{ value: 'Value1', description: ['The first value'] },
|
|
652
|
+
{ value: 'Value2', description: ['The second value'] },
|
|
653
|
+
],
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
const result = compile(template, enumSource);
|
|
657
|
+
|
|
658
|
+
expect(result).toBe('Value1 - The first valueValue2 - The second value');
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
it('can reference a group reference', () => {
|
|
662
|
+
const template = '** Group {{group}}';
|
|
663
|
+
|
|
664
|
+
const enumSource: EnumSource = {
|
|
665
|
+
__type: 'enum',
|
|
666
|
+
accessModifier: 'public',
|
|
667
|
+
name: 'MyEnum',
|
|
668
|
+
values: [],
|
|
669
|
+
group: 'MyGroup',
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
const result = compile(template, enumSource);
|
|
673
|
+
|
|
674
|
+
expect(result).toBe('** Group MyGroup');
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
it('can reference an author reference', () => {
|
|
678
|
+
const template = '** Author {{author}}';
|
|
679
|
+
|
|
680
|
+
const enumSource: EnumSource = {
|
|
681
|
+
__type: 'enum',
|
|
682
|
+
accessModifier: 'public',
|
|
683
|
+
name: 'MyEnum',
|
|
684
|
+
values: [],
|
|
685
|
+
author: 'Test Testerson',
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
const result = compile(template, enumSource);
|
|
689
|
+
|
|
690
|
+
expect(result).toBe('** Author Test Testerson');
|
|
691
|
+
});
|
|
692
|
+
|
|
693
|
+
it('can reference a date reference', () => {
|
|
694
|
+
const template = '** Date {{date}}';
|
|
695
|
+
|
|
696
|
+
const enumSource: EnumSource = {
|
|
697
|
+
__type: 'enum',
|
|
698
|
+
accessModifier: 'public',
|
|
699
|
+
name: 'MyEnum',
|
|
700
|
+
values: [],
|
|
701
|
+
date: '2021-01-01',
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
const result = compile(template, enumSource);
|
|
705
|
+
|
|
706
|
+
expect(result).toBe('** Date 2021-01-01');
|
|
707
|
+
});
|
|
708
|
+
|
|
709
|
+
it('can reference custom tags', () => {
|
|
710
|
+
const template = '{{#each customTags}}**{{name}}** {{value}}{{/each}}';
|
|
711
|
+
|
|
712
|
+
const enumSource: EnumSource = {
|
|
713
|
+
__type: 'enum',
|
|
714
|
+
accessModifier: 'public',
|
|
715
|
+
name: 'MyEnum',
|
|
716
|
+
values: [],
|
|
717
|
+
customTags: [{ name: 'CustomTag', description: ['My custom tag'] }],
|
|
718
|
+
};
|
|
719
|
+
|
|
720
|
+
const result = compile(template, enumSource);
|
|
721
|
+
|
|
722
|
+
expect(result).toBe('**CustomTag** My custom tag');
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
it('can reference see references', () => {
|
|
726
|
+
const template = '{{#each sees}}**See** {{this}}{{/each}}';
|
|
727
|
+
|
|
728
|
+
const enumSource: EnumSource = {
|
|
729
|
+
__type: 'enum',
|
|
730
|
+
accessModifier: 'public',
|
|
731
|
+
name: 'MyEnum',
|
|
732
|
+
values: [],
|
|
733
|
+
sees: [{ title: 'More info', url: 'https://example.com' }],
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
const result = compile(template, enumSource);
|
|
737
|
+
|
|
738
|
+
expect(result).toBe('**See** More info');
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
});
|