@cparra/apexdocs 3.0.0-rc.0 → 3.1.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/README.md +61 -576
- package/dist/cli/generate.js +73 -3094
- package/dist/defaults-BcE8DTat.js +13 -0
- package/dist/defaults-D07y_bq4.js +40 -0
- package/dist/defaults-gPzwP66p.js +14 -0
- package/dist/index.d.ts +35 -3
- package/dist/index.js +90 -2
- package/dist/logger-BEbUIfqN.js +3282 -0
- package/dist/logger-BGuf1PnL.js +3281 -0
- package/dist/logger-CWBRF2za.js +3284 -0
- package/dist/logger-CdBmDEN1.js +3283 -0
- package/dist/logger-Ce4QqPFR.js +3278 -0
- package/dist/logger-CyEVYaAC.js +3284 -0
- package/dist/logger-D7a83ycP.js +3277 -0
- package/dist/logger-DGaHeBKk.js +3279 -0
- package/dist/logger-Dqhl_lO_.js +3278 -0
- package/dist/logger-aySSWi0G.js +3280 -0
- package/dist/logger-qLCcAtiy.js +3284 -0
- package/package.json +5 -2
- package/.github/workflows/ci.yaml +0 -22
- package/.github/workflows/close_stale.yml +0 -22
- package/.prettierrc.js +0 -7
- package/__mocks__/chalk.js +0 -12
- package/__mocks__/log-update.js +0 -6
- package/eslint.config.mjs +0 -10
- package/examples/markdown/.forceignore +0 -12
- package/examples/markdown/config/project-scratch-def.json +0 -5
- package/examples/markdown/docs/index.md +0 -109
- package/examples/markdown/docs/miscellaneous/BaseClass.md +0 -16
- package/examples/markdown/docs/miscellaneous/MultiInheritanceClass.md +0 -72
- package/examples/markdown/docs/miscellaneous/ParentInterface.md +0 -15
- package/examples/markdown/docs/miscellaneous/ReferencedEnum.md +0 -8
- package/examples/markdown/docs/miscellaneous/SampleException.md +0 -24
- package/examples/markdown/docs/miscellaneous/SampleInterface.md +0 -116
- package/examples/markdown/docs/miscellaneous/Url.md +0 -311
- package/examples/markdown/docs/sample-enums/SampleEnum.md +0 -36
- package/examples/markdown/docs/samplegroup/SampleClass.md +0 -170
- package/examples/markdown/force-app/classes/BaseClass.cls +0 -3
- package/examples/markdown/force-app/classes/MultiInheritanceClass.cls +0 -1
- package/examples/markdown/force-app/classes/ParentInterface.cls +0 -3
- package/examples/markdown/force-app/classes/ReferencedEnum.cls +0 -3
- package/examples/markdown/force-app/classes/SampleClass.cls +0 -72
- package/examples/markdown/force-app/classes/SampleEnum.cls +0 -30
- package/examples/markdown/force-app/classes/SampleException.cls +0 -17
- package/examples/markdown/force-app/classes/SampleInterface.cls +0 -50
- package/examples/markdown/force-app/classes/Url.cls +0 -196
- package/examples/markdown/package-lock.json +0 -665
- package/examples/markdown/package.json +0 -20
- package/examples/markdown/sfdx-project.json +0 -12
- package/examples/markdown-jsconfig/.forceignore +0 -12
- package/examples/markdown-jsconfig/apexdocs.config.mjs +0 -21
- package/examples/markdown-jsconfig/config/project-scratch-def.json +0 -5
- package/examples/markdown-jsconfig/docs/index.md +0 -12
- package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +0 -315
- package/examples/markdown-jsconfig/force-app/classes/Url.cls +0 -196
- package/examples/markdown-jsconfig/package-lock.json +0 -665
- package/examples/markdown-jsconfig/package.json +0 -15
- package/examples/markdown-jsconfig/sfdx-project.json +0 -12
- package/examples/open-api/config/project-scratch-def.json +0 -13
- package/examples/open-api/docs/openapi.json +0 -582
- package/examples/open-api/force-app/main/default/classes/ChildClass.cls +0 -42
- package/examples/open-api/force-app/main/default/classes/SampleClass.cls +0 -167
- package/examples/open-api/force-app/main/default/restapi/SampleRestResource.cls +0 -195
- package/examples/open-api/force-app/main/default/restapi/SampleRestResourceToSkip.cls +0 -35
- package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +0 -24
- package/examples/open-api/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +0 -15
- package/examples/open-api/force-app/main/default/restapi/references/Reference1.cls +0 -9
- package/examples/open-api/force-app/main/default/restapi/references/Reference2.cls +0 -9
- package/examples/open-api/force-app/main/default/restapi/references/Reference3.cls +0 -3
- package/examples/open-api/force-app/main/default/restapi/references/Reference4.cls +0 -3
- package/examples/open-api/force-app/main/default/restapi/references/Reference5.cls +0 -3
- package/examples/open-api/force-app/main/default/restapi/references/Reference6.cls +0 -6
- package/examples/open-api/force-app/main/default/restapi/references/Reference7.cls +0 -3
- package/examples/open-api/package-lock.json +0 -724
- package/examples/open-api/package.json +0 -20
- package/examples/open-api/sfdx-project.json +0 -12
- package/examples/vitepress/.forceignore +0 -12
- package/examples/vitepress/apexdocs.config.ts +0 -111
- package/examples/vitepress/config/project-scratch-def.json +0 -13
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +0 -259
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +0 -40
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +0 -11474
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +0 -9172
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/package.json +0 -3
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4339
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -567
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +0 -323
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/config.mts +0 -21
- package/examples/vitepress/docs/.vitepress/sidebar.json +0 -119
- package/examples/vitepress/docs/api-examples.md +0 -49
- package/examples/vitepress/docs/index-frontmatter.md +0 -16
- package/examples/vitepress/docs/index.md +0 -56
- package/examples/vitepress/docs/markdown-examples.md +0 -85
- package/examples/vitepress/docs/miscellaneous/BaseClass.md +0 -20
- package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +0 -76
- package/examples/vitepress/docs/miscellaneous/ParentInterface.md +0 -19
- package/examples/vitepress/docs/miscellaneous/ReferencedEnum.md +0 -15
- package/examples/vitepress/docs/miscellaneous/SampleException.md +0 -28
- package/examples/vitepress/docs/miscellaneous/SampleInterface.md +0 -116
- package/examples/vitepress/docs/miscellaneous/Url.md +0 -317
- package/examples/vitepress/docs/sample-enums/SampleEnum.md +0 -40
- package/examples/vitepress/docs/samplegroup/SampleClass.md +0 -174
- package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +0 -3
- package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +0 -1
- package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +0 -3
- package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +0 -5
- package/examples/vitepress/force-app/main/default/classes/SampleClass.cls +0 -72
- package/examples/vitepress/force-app/main/default/classes/SampleEnum.cls +0 -30
- package/examples/vitepress/force-app/main/default/classes/SampleException.cls +0 -17
- package/examples/vitepress/force-app/main/default/classes/SampleInterface.cls +0 -46
- package/examples/vitepress/force-app/main/default/classes/Url.cls +0 -198
- package/examples/vitepress/package-lock.json +0 -2574
- package/examples/vitepress/package.json +0 -18
- package/examples/vitepress/sfdx-project.json +0 -12
- package/jest.config.js +0 -10
- package/jest.d.ts +0 -7
- package/src/application/Apexdocs.ts +0 -72
- package/src/application/__tests__/apex-file-reader.spec.ts +0 -87
- package/src/application/apex-file-reader.ts +0 -55
- package/src/application/file-system.ts +0 -69
- package/src/application/file-writer.ts +0 -43
- package/src/application/generators/markdown.ts +0 -45
- package/src/application/generators/openapi.ts +0 -71
- package/src/cli/args.ts +0 -46
- package/src/cli/commands/markdown.ts +0 -51
- package/src/cli/commands/openapi.ts +0 -36
- package/src/cli/generate.ts +0 -16
- package/src/core/__test__/manifest.spec.ts +0 -16
- package/src/core/manifest.ts +0 -90
- package/src/core/markdown/__test__/expect-extensions.ts +0 -32
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +0 -605
- package/src/core/markdown/__test__/generating-docs.spec.ts +0 -111
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -321
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -397
- package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -180
- package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
- package/src/core/markdown/__test__/test-helpers.ts +0 -23
- package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
- package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -148
- package/src/core/markdown/adapters/__tests__/link-generator.spec.ts +0 -130
- package/src/core/markdown/adapters/__tests__/references.spec.ts +0 -136
- package/src/core/markdown/adapters/apex-types.ts +0 -238
- package/src/core/markdown/adapters/documentables.ts +0 -115
- package/src/core/markdown/adapters/fields-and-properties.ts +0 -45
- package/src/core/markdown/adapters/generate-link.ts +0 -82
- package/src/core/markdown/adapters/inline.ts +0 -143
- package/src/core/markdown/adapters/methods-and-constructors.ts +0 -133
- package/src/core/markdown/adapters/reference-guide.ts +0 -37
- package/src/core/markdown/adapters/renderable-bundle.ts +0 -61
- package/src/core/markdown/adapters/renderable-to-page-data.ts +0 -89
- package/src/core/markdown/adapters/type-utils.ts +0 -13
- package/src/core/markdown/adapters/types.d.ts +0 -180
- package/src/core/markdown/generate-docs.ts +0 -212
- package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +0 -306
- package/src/core/markdown/reflection/filter-scope.ts +0 -13
- package/src/core/markdown/reflection/inheritance-chain-expanion.ts +0 -22
- package/src/core/markdown/reflection/inheritance-chain.ts +0 -23
- package/src/core/markdown/reflection/inherited-member-expansion.ts +0 -105
- package/src/core/markdown/reflection/reflect-source.ts +0 -123
- package/src/core/markdown/reflection/sort-members.ts +0 -59
- package/src/core/markdown/templates/class-template.ts +0 -75
- package/src/core/markdown/templates/constructors-partial-template.ts +0 -32
- package/src/core/markdown/templates/documentable-partial-template.ts +0 -26
- package/src/core/markdown/templates/enum-template.ts +0 -12
- package/src/core/markdown/templates/fieldsPartialTemplate.ts +0 -23
- package/src/core/markdown/templates/grouped-members-partial-template.ts +0 -6
- package/src/core/markdown/templates/hookable.ts +0 -7
- package/src/core/markdown/templates/interface-template.ts +0 -16
- package/src/core/markdown/templates/methods-partial-template.ts +0 -43
- package/src/core/markdown/templates/reference-guide.ts +0 -14
- package/src/core/markdown/templates/template.ts +0 -114
- package/src/core/markdown/templates/type-doc-partial.ts +0 -27
- package/src/core/markdown/utils.ts +0 -3
- package/src/core/openApiSettings.ts +0 -41
- package/src/core/openapi/__tests__/manifest-factory.spec.ts +0 -16
- package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +0 -56
- package/src/core/openapi/__tests__/open-api.spec.ts +0 -22
- package/src/core/openapi/apex-doc-types.ts +0 -26
- package/src/core/openapi/apex-type-wrappers/ClassMirrorWrapper.ts +0 -12
- package/src/core/openapi/apex-type-wrappers/MethodMirrorWrapper.ts +0 -11
- package/src/core/openapi/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +0 -15
- package/src/core/openapi/file-container.ts +0 -13
- package/src/core/openapi/manifest-factory.ts +0 -16
- package/src/core/openapi/open-api-docs-processor.ts +0 -93
- package/src/core/openapi/open-api-types.ts +0 -119
- package/src/core/openapi/open-api.ts +0 -45
- package/src/core/openapi/openapi-type-file.ts +0 -12
- package/src/core/openapi/parser.ts +0 -160
- package/src/core/openapi/parsers/Builder.ts +0 -40
- package/src/core/openapi/parsers/MethodParser.ts +0 -249
- package/src/core/openapi/parsers/ParameterObjectBuilder.ts +0 -13
- package/src/core/openapi/parsers/ReferenceBuilder.ts +0 -299
- package/src/core/openapi/parsers/RequestBodyBuilder.ts +0 -19
- package/src/core/openapi/parsers/ResponsesBuilder.ts +0 -21
- package/src/core/openapi/parsers/__tests__/MethodParser.spec.ts +0 -44
- package/src/core/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +0 -68
- package/src/core/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +0 -751
- package/src/core/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +0 -64
- package/src/core/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +0 -55
- package/src/core/openapi/transpiler.ts +0 -17
- package/src/core/openapi/types-repository.ts +0 -54
- package/src/core/parse-apex-metadata.ts +0 -30
- package/src/core/shared/types.d.ts +0 -148
- package/src/core/shared/utils.ts +0 -5
- package/src/defaults.ts +0 -9
- package/src/index.ts +0 -49
- package/src/test-helpers/AnnotationBuilder.ts +0 -29
- package/src/test-helpers/ClassMirrorBuilder.ts +0 -69
- package/src/test-helpers/DocCommentAnnotationBuilder.ts +0 -24
- package/src/test-helpers/DocCommentBuilder.ts +0 -36
- package/src/test-helpers/FieldMirrorBuilder.ts +0 -59
- package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -39
- package/src/test-helpers/MethodMirrorBuilder.ts +0 -77
- package/src/test-helpers/SettingsBuilder.ts +0 -17
- package/src/util/error-logger.ts +0 -92
- package/src/util/fp.ts +0 -3
- package/src/util/logger.ts +0 -44
- package/src/util/string-utils.ts +0 -7
- package/tsconfig.json +0 -25
- package/tslint.json +0 -6
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { adaptDescribable } from '../documentables';
|
|
2
|
-
|
|
3
|
-
function linkGenerator(typeName: string) {
|
|
4
|
-
return typeName;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
describe('describable', () => {
|
|
8
|
-
it('returns undefined if describable is undefined', () => {
|
|
9
|
-
const result = adaptDescribable(undefined, linkGenerator);
|
|
10
|
-
|
|
11
|
-
expect(result).toEqual({
|
|
12
|
-
description: undefined,
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('returns an empty array if describable is an empty array', () => {
|
|
17
|
-
const result = adaptDescribable([], linkGenerator);
|
|
18
|
-
|
|
19
|
-
expect(result).toEqual({
|
|
20
|
-
description: [],
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('returns a string if describable contains a string', () => {
|
|
25
|
-
const describable = ['This is a test'];
|
|
26
|
-
|
|
27
|
-
const result = adaptDescribable(describable, linkGenerator);
|
|
28
|
-
|
|
29
|
-
expect(result).toEqual({
|
|
30
|
-
description: ['This is a test'],
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('separates strings with an empty line', () => {
|
|
35
|
-
const describable = ['This is a test', 'This is another test'];
|
|
36
|
-
|
|
37
|
-
const result = adaptDescribable(describable, linkGenerator);
|
|
38
|
-
|
|
39
|
-
expect(result).toEqual({
|
|
40
|
-
description: ['This is a test', { __type: 'empty-line' }, 'This is another test'],
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('returns a code block if describable contains code', () => {
|
|
45
|
-
const describable = ['```typescript', 'const a = 1;', '```'];
|
|
46
|
-
|
|
47
|
-
const result = adaptDescribable(describable, linkGenerator);
|
|
48
|
-
|
|
49
|
-
expect(result).toEqual({
|
|
50
|
-
description: [
|
|
51
|
-
{
|
|
52
|
-
__type: 'code-block',
|
|
53
|
-
language: 'typescript',
|
|
54
|
-
content: ['const a = 1;'],
|
|
55
|
-
},
|
|
56
|
-
],
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('sets the code blocks language to apex if one is not provided', () => {
|
|
61
|
-
const describable = ['```', 'const a = 1;', '```'];
|
|
62
|
-
|
|
63
|
-
const result = adaptDescribable(describable, linkGenerator);
|
|
64
|
-
|
|
65
|
-
expect(result).toEqual({
|
|
66
|
-
description: [
|
|
67
|
-
{
|
|
68
|
-
__type: 'code-block',
|
|
69
|
-
language: 'apex',
|
|
70
|
-
content: ['const a = 1;'],
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('returns a code block followed by an empty line and then whatever content is in the describable', () => {
|
|
77
|
-
const describable = ['```typescript', 'const a = 1;', '```', 'This is a test'];
|
|
78
|
-
|
|
79
|
-
const result = adaptDescribable(describable, linkGenerator);
|
|
80
|
-
|
|
81
|
-
expect(result).toEqual({
|
|
82
|
-
description: [
|
|
83
|
-
{
|
|
84
|
-
__type: 'code-block',
|
|
85
|
-
language: 'typescript',
|
|
86
|
-
content: ['const a = 1;'],
|
|
87
|
-
},
|
|
88
|
-
{ __type: 'empty-line' },
|
|
89
|
-
'This is a test',
|
|
90
|
-
],
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('returns a code block even when there is no closing tag', () => {
|
|
95
|
-
const describable = ['```typescript', 'const a = 1;'];
|
|
96
|
-
|
|
97
|
-
const result = adaptDescribable(describable, linkGenerator);
|
|
98
|
-
|
|
99
|
-
expect(result).toEqual({
|
|
100
|
-
description: [
|
|
101
|
-
{
|
|
102
|
-
__type: 'code-block',
|
|
103
|
-
language: 'typescript',
|
|
104
|
-
content: ['const a = 1;'],
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import { typeToRenderable } from '../apex-types';
|
|
2
|
-
import { InterfaceMirrorBuilder } from '../../../../test-helpers/InterfaceMirrorBuilder';
|
|
3
|
-
import { AnnotationBuilder } from '../../../../test-helpers/AnnotationBuilder';
|
|
4
|
-
import { MethodMirrorBuilder, ParameterBuilder } from '../../../../test-helpers/MethodMirrorBuilder';
|
|
5
|
-
import { MarkdownGeneratorConfig } from '../../generate-docs';
|
|
6
|
-
|
|
7
|
-
function linkGenerator(type: string): string {
|
|
8
|
-
return type;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const defaultMarkdownGeneratorConfig: MarkdownGeneratorConfig = {
|
|
12
|
-
targetDir: '',
|
|
13
|
-
scope: ['global', 'public'],
|
|
14
|
-
namespace: '',
|
|
15
|
-
defaultGroupName: 'Miscellaneous',
|
|
16
|
-
referenceGuideTemplate: '',
|
|
17
|
-
sortMembersAlphabetically: false,
|
|
18
|
-
linkingStrategy: 'relative',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
describe('Conversion from InterfaceMirror to InterfaceSource understandable by the templating engine', () => {
|
|
22
|
-
it('converts the name', () => {
|
|
23
|
-
const interfaceMirror = new InterfaceMirrorBuilder().withName('SampleInterface').build();
|
|
24
|
-
const interfaceSource = typeToRenderable(
|
|
25
|
-
{
|
|
26
|
-
source: {
|
|
27
|
-
filePath: '',
|
|
28
|
-
type: 'interface',
|
|
29
|
-
name: 'SampleInterface',
|
|
30
|
-
},
|
|
31
|
-
type: interfaceMirror,
|
|
32
|
-
},
|
|
33
|
-
linkGenerator,
|
|
34
|
-
defaultMarkdownGeneratorConfig,
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
expect(interfaceSource.name).toBe('SampleInterface');
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
it('converts the access modifier', () => {
|
|
41
|
-
const interfaceMirror = new InterfaceMirrorBuilder().build();
|
|
42
|
-
const interfaceSource = typeToRenderable(
|
|
43
|
-
{
|
|
44
|
-
source: {
|
|
45
|
-
filePath: '',
|
|
46
|
-
type: 'interface',
|
|
47
|
-
name: 'SampleInterface',
|
|
48
|
-
},
|
|
49
|
-
type: interfaceMirror,
|
|
50
|
-
},
|
|
51
|
-
linkGenerator,
|
|
52
|
-
defaultMarkdownGeneratorConfig,
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
expect(interfaceSource.meta.accessModifier).toBe('public');
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it('converts annotations', () => {
|
|
59
|
-
const interfaceMirror = new InterfaceMirrorBuilder()
|
|
60
|
-
.addAnnotation(new AnnotationBuilder().withName('MyAnnotation').build())
|
|
61
|
-
.build();
|
|
62
|
-
const interfaceSource = typeToRenderable(
|
|
63
|
-
{
|
|
64
|
-
source: {
|
|
65
|
-
filePath: '',
|
|
66
|
-
type: 'interface',
|
|
67
|
-
name: 'SampleInterface',
|
|
68
|
-
},
|
|
69
|
-
type: interfaceMirror,
|
|
70
|
-
},
|
|
71
|
-
linkGenerator,
|
|
72
|
-
defaultMarkdownGeneratorConfig,
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
expect(interfaceSource.doc.annotations).toEqual(['MYANNOTATION']);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('converts method declarations. Method with no parameters', () => {
|
|
79
|
-
const interfaceMirror = new InterfaceMirrorBuilder()
|
|
80
|
-
.addMethod(
|
|
81
|
-
new MethodMirrorBuilder()
|
|
82
|
-
.withName('sampleMethod')
|
|
83
|
-
.withTypeReference({
|
|
84
|
-
type: 'String',
|
|
85
|
-
rawDeclaration: 'String',
|
|
86
|
-
})
|
|
87
|
-
.build(),
|
|
88
|
-
)
|
|
89
|
-
.build();
|
|
90
|
-
|
|
91
|
-
const interfaceSource = typeToRenderable(
|
|
92
|
-
{
|
|
93
|
-
source: {
|
|
94
|
-
filePath: '',
|
|
95
|
-
type: 'interface',
|
|
96
|
-
name: 'SampleInterface',
|
|
97
|
-
},
|
|
98
|
-
type: interfaceMirror,
|
|
99
|
-
},
|
|
100
|
-
linkGenerator,
|
|
101
|
-
defaultMarkdownGeneratorConfig,
|
|
102
|
-
);
|
|
103
|
-
|
|
104
|
-
expect(interfaceSource.methods.value).toHaveLength(1);
|
|
105
|
-
expect(interfaceSource.methods.value[0].signature.value.content[0]).toBe('public String sampleMethod()');
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
it('converts method declarations. Method with parameters', () => {
|
|
109
|
-
const interfaceMirror = new InterfaceMirrorBuilder()
|
|
110
|
-
.addMethod(
|
|
111
|
-
new MethodMirrorBuilder()
|
|
112
|
-
.withName('sampleMethod')
|
|
113
|
-
.withTypeReference({
|
|
114
|
-
type: 'String',
|
|
115
|
-
rawDeclaration: 'String',
|
|
116
|
-
})
|
|
117
|
-
.addParameter(
|
|
118
|
-
new ParameterBuilder()
|
|
119
|
-
.withName('param1')
|
|
120
|
-
.withTypeReference({
|
|
121
|
-
type: 'String',
|
|
122
|
-
rawDeclaration: 'String',
|
|
123
|
-
})
|
|
124
|
-
.build(),
|
|
125
|
-
)
|
|
126
|
-
.build(),
|
|
127
|
-
)
|
|
128
|
-
.build();
|
|
129
|
-
|
|
130
|
-
const interfaceSource = typeToRenderable(
|
|
131
|
-
{
|
|
132
|
-
source: {
|
|
133
|
-
filePath: '',
|
|
134
|
-
type: 'interface',
|
|
135
|
-
name: 'SampleInterface',
|
|
136
|
-
},
|
|
137
|
-
type: interfaceMirror,
|
|
138
|
-
},
|
|
139
|
-
linkGenerator,
|
|
140
|
-
defaultMarkdownGeneratorConfig,
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
expect(interfaceSource.methods.value).toHaveLength(1);
|
|
144
|
-
expect(interfaceSource.methods.value[0].signature.value.content[0]).toBe(
|
|
145
|
-
'public String sampleMethod(String param1)',
|
|
146
|
-
);
|
|
147
|
-
});
|
|
148
|
-
});
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { generateLink } from '../generate-link';
|
|
2
|
-
|
|
3
|
-
describe('Generates links', () => {
|
|
4
|
-
describe('relative', () => {
|
|
5
|
-
it('generates relative links from the base when found', () => {
|
|
6
|
-
const references = {
|
|
7
|
-
referenceName: {
|
|
8
|
-
referencePath: 'referencePath',
|
|
9
|
-
displayName: 'displayName',
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
const from = '__base__';
|
|
13
|
-
const referenceName = 'referenceName';
|
|
14
|
-
|
|
15
|
-
const result = generateLink('relative')(references, from, referenceName);
|
|
16
|
-
|
|
17
|
-
expect(result).toEqual({
|
|
18
|
-
__type: 'link',
|
|
19
|
-
title: 'displayName',
|
|
20
|
-
url: 'referencePath',
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('returns the name of the reference when not found', () => {
|
|
25
|
-
const references = {};
|
|
26
|
-
const from = '__base__';
|
|
27
|
-
const referenceName = 'referenceName';
|
|
28
|
-
|
|
29
|
-
const result = generateLink('relative')(references, from, referenceName);
|
|
30
|
-
|
|
31
|
-
expect(result).toEqual('referenceName');
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('returns a relative path when linking from a file', () => {
|
|
35
|
-
const references = {
|
|
36
|
-
referenceName: {
|
|
37
|
-
referencePath: 'a/referencePath',
|
|
38
|
-
displayName: 'displayName',
|
|
39
|
-
},
|
|
40
|
-
from: {
|
|
41
|
-
referencePath: 'b/fromPath',
|
|
42
|
-
displayName: 'fromName',
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
const from = 'from';
|
|
46
|
-
const referenceName = 'referenceName';
|
|
47
|
-
|
|
48
|
-
const result = generateLink('relative')(references, from, referenceName);
|
|
49
|
-
|
|
50
|
-
expect(result).toEqual({
|
|
51
|
-
__type: 'link',
|
|
52
|
-
title: 'displayName',
|
|
53
|
-
url: '../a/referencePath',
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it('returns the display name when the from reference is not found', () => {
|
|
58
|
-
const references = {
|
|
59
|
-
referenceName: {
|
|
60
|
-
referencePath: 'a/referencePath',
|
|
61
|
-
displayName: 'displayName',
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
const from = 'from';
|
|
65
|
-
const referenceName = 'referenceName';
|
|
66
|
-
|
|
67
|
-
const result = generateLink('relative')(references, from, referenceName);
|
|
68
|
-
|
|
69
|
-
expect(result).toEqual('displayName');
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('no-link', () => {
|
|
74
|
-
it('returns the name of the reference when the reference is not found', () => {
|
|
75
|
-
const references = {};
|
|
76
|
-
const from = '__base__';
|
|
77
|
-
const referenceName = 'referenceName';
|
|
78
|
-
|
|
79
|
-
const result = generateLink('no-link')(references, from, referenceName);
|
|
80
|
-
|
|
81
|
-
expect(result).toEqual('referenceName');
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it('returns the display name of the reference when the reference is found', () => {
|
|
85
|
-
const references = {
|
|
86
|
-
referenceName: {
|
|
87
|
-
referencePath: 'referencePath',
|
|
88
|
-
displayName: 'displayName',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
const from = '__base__';
|
|
92
|
-
const referenceName = 'referenceName';
|
|
93
|
-
|
|
94
|
-
const result = generateLink('no-link')(references, from, referenceName);
|
|
95
|
-
|
|
96
|
-
expect(result).toEqual('displayName');
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
describe('none', () => {
|
|
101
|
-
it('returns the path as is when the reference is found', () => {
|
|
102
|
-
const references = {
|
|
103
|
-
referenceName: {
|
|
104
|
-
referencePath: 'referencePath',
|
|
105
|
-
displayName: 'displayName',
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
const from = '__base__';
|
|
109
|
-
const referenceName = 'referenceName';
|
|
110
|
-
|
|
111
|
-
const result = generateLink('none')(references, from, referenceName);
|
|
112
|
-
|
|
113
|
-
expect(result).toEqual({
|
|
114
|
-
__type: 'link',
|
|
115
|
-
title: 'displayName',
|
|
116
|
-
url: 'referencePath',
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('returns the name of the reference when the reference is not found', () => {
|
|
121
|
-
const references = {};
|
|
122
|
-
const from = '__base__';
|
|
123
|
-
const referenceName = 'referenceName';
|
|
124
|
-
|
|
125
|
-
const result = generateLink('none')(references, from, referenceName);
|
|
126
|
-
|
|
127
|
-
expect(result).toEqual('referenceName');
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
});
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { replaceInlineReferences } from '../inline';
|
|
2
|
-
import { Link } from '../types';
|
|
3
|
-
|
|
4
|
-
function getFileLink(typeName: string): Link {
|
|
5
|
-
return {
|
|
6
|
-
__type: 'link' as const,
|
|
7
|
-
title: typeName,
|
|
8
|
-
url: `/api/${typeName}.html`,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function getEmailLink(typeName: string) {
|
|
13
|
-
return {
|
|
14
|
-
__type: 'link' as const,
|
|
15
|
-
title: typeName,
|
|
16
|
-
url: `mailto:${typeName}`,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
describe('reference utilities', () => {
|
|
21
|
-
it('returns a RenderableContent array with the full string when there are no links', () => {
|
|
22
|
-
const text = 'This is a test';
|
|
23
|
-
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
24
|
-
|
|
25
|
-
const expected = ['This is a test'];
|
|
26
|
-
|
|
27
|
-
expect(result).toEqual(expected);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe('replace inline code', () => {
|
|
31
|
-
it('replaces inline code with InlineCode', () => {
|
|
32
|
-
const text = 'This is a test `ClassName`.';
|
|
33
|
-
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
34
|
-
|
|
35
|
-
const expected = ['This is a test ', { __type: 'inline-code', content: 'ClassName' }, '.'];
|
|
36
|
-
|
|
37
|
-
expect(result).toEqual(expected);
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
describe('replace inline links', () => {
|
|
42
|
-
it('replaces links in the format of <<ClassName>>', () => {
|
|
43
|
-
const text = 'This is a test <<ClassName>>.';
|
|
44
|
-
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
45
|
-
|
|
46
|
-
const expected = [
|
|
47
|
-
'This is a test ',
|
|
48
|
-
{
|
|
49
|
-
__type: 'link',
|
|
50
|
-
title: 'ClassName',
|
|
51
|
-
url: '/api/ClassName.html',
|
|
52
|
-
},
|
|
53
|
-
'.',
|
|
54
|
-
];
|
|
55
|
-
|
|
56
|
-
expect(result).toEqual(expected);
|
|
57
|
-
});
|
|
58
|
-
it('replaces links in the format of {@link ClassName}', () => {
|
|
59
|
-
function getFileLinkByTypeName(typeName: string): Link {
|
|
60
|
-
return {
|
|
61
|
-
__type: 'link' as const,
|
|
62
|
-
title: typeName,
|
|
63
|
-
url: `/api/${typeName}.html`,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const text = 'This is a test {@link ClassName}';
|
|
68
|
-
const result = replaceInlineReferences(text, getFileLinkByTypeName, getEmailLink);
|
|
69
|
-
|
|
70
|
-
const expected = [
|
|
71
|
-
'This is a test ',
|
|
72
|
-
{
|
|
73
|
-
__type: 'link',
|
|
74
|
-
title: 'ClassName',
|
|
75
|
-
url: '/api/ClassName.html',
|
|
76
|
-
},
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
expect(result).toEqual(expected);
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('replace inline emails', () => {
|
|
84
|
-
it('replaces emails in the format of {@email email-address}', () => {
|
|
85
|
-
function getLinkByTypeName(typeName: string) {
|
|
86
|
-
return {
|
|
87
|
-
__type: 'link' as const,
|
|
88
|
-
title: typeName,
|
|
89
|
-
url: `mailto:${typeName}`,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const text = 'This is an email {@email example@example.com}';
|
|
94
|
-
const result = replaceInlineReferences(text, getFileLink, getLinkByTypeName);
|
|
95
|
-
|
|
96
|
-
const expected = [
|
|
97
|
-
'This is an email ',
|
|
98
|
-
{
|
|
99
|
-
__type: 'link',
|
|
100
|
-
title: 'example@example.com',
|
|
101
|
-
url: 'mailto:example@example.com',
|
|
102
|
-
},
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
expect(result).toEqual(expected);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
it('replaces both links and emails in the same string', () => {
|
|
110
|
-
const text = 'This is a test <<ClassName>>, and {@link AnotherClass}, and an email {@email testerson}';
|
|
111
|
-
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
112
|
-
|
|
113
|
-
const expected = [
|
|
114
|
-
'This is a test ',
|
|
115
|
-
{
|
|
116
|
-
__type: 'link',
|
|
117
|
-
title: 'ClassName',
|
|
118
|
-
url: '/api/ClassName.html',
|
|
119
|
-
},
|
|
120
|
-
', and ',
|
|
121
|
-
{
|
|
122
|
-
__type: 'link',
|
|
123
|
-
title: 'AnotherClass',
|
|
124
|
-
url: '/api/AnotherClass.html',
|
|
125
|
-
},
|
|
126
|
-
', and an email ',
|
|
127
|
-
{
|
|
128
|
-
__type: 'link',
|
|
129
|
-
title: 'testerson',
|
|
130
|
-
url: 'mailto:testerson',
|
|
131
|
-
},
|
|
132
|
-
];
|
|
133
|
-
|
|
134
|
-
expect(result).toEqual(expected);
|
|
135
|
-
});
|
|
136
|
-
});
|