@cparra/apexdocs 3.0.0 → 3.1.1
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 +11 -5
- package/dist/cli/generate.js +1 -1
- package/dist/index.js +1 -1
- package/dist/logger-BATX7-be.js +3278 -0
- package/package.json +4 -1
- 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/README.md +0 -5
- package/examples/docsify/README.md +0 -17
- package/examples/docsify/apexdocs.config.ts +0 -13
- package/examples/docsify/classes/ASampleClass.cls +0 -57
- package/examples/docsify/classes/CodeControl.cls +0 -19
- package/examples/docsify/classes/SampleClass.cls +0 -95
- package/examples/docsify/classes/SampleInterface.cls +0 -17
- package/examples/docsify/classes/SomeDto.cls +0 -122
- package/examples/docsify/docs/.nojekyll +0 -0
- package/examples/docsify/docs/README.md +0 -25
- package/examples/docsify/docs/_config.yml +0 -1
- package/examples/docsify/docs/index.html +0 -22
- package/examples/docsify/docs/miscellaneous/ASampleClass.md +0 -88
- package/examples/docsify/docs/miscellaneous/CodeControl.md +0 -107
- package/examples/docsify/docs/miscellaneous/SomeDto.md +0 -244
- package/examples/docsify/docs/sample-classes/SampleClass.md +0 -171
- package/examples/docsify/docs/sample-interfaces/SampleInterface.md +0 -36
- package/examples/docsify/package-lock.json +0 -2459
- package/examples/docsify/package.json +0 -14
- package/examples/imported/.forceignore +0 -12
- package/examples/imported/README.md +0 -6
- package/examples/imported/config/project-scratch-def.json +0 -5
- package/examples/imported/docs/index.md +0 -109
- package/examples/imported/docs/miscellaneous/BaseClass.md +0 -13
- package/examples/imported/docs/miscellaneous/MultiInheritanceClass.md +0 -69
- package/examples/imported/docs/miscellaneous/ParentInterface.md +0 -12
- package/examples/imported/docs/miscellaneous/ReferencedEnum.md +0 -5
- package/examples/imported/docs/miscellaneous/SampleException.md +0 -21
- package/examples/imported/docs/miscellaneous/SampleInterface.md +0 -113
- package/examples/imported/docs/miscellaneous/Url.md +0 -308
- package/examples/imported/docs/sample-enums/SampleEnum.md +0 -33
- package/examples/imported/docs/samplegroup/SampleClass.md +0 -167
- package/examples/imported/force-app/classes/BaseClass.cls +0 -3
- package/examples/imported/force-app/classes/MultiInheritanceClass.cls +0 -1
- package/examples/imported/force-app/classes/ParentInterface.cls +0 -3
- package/examples/imported/force-app/classes/ReferencedEnum.cls +0 -3
- package/examples/imported/force-app/classes/SampleClass.cls +0 -72
- package/examples/imported/force-app/classes/SampleEnum.cls +0 -30
- package/examples/imported/force-app/classes/SampleException.cls +0 -17
- package/examples/imported/force-app/classes/SampleInterface.cls +0 -50
- package/examples/imported/force-app/classes/Url.cls +0 -196
- package/examples/imported/package-lock.json +0 -665
- package/examples/imported/package.json +0 -6
- package/examples/imported/scripts/process-docs.mjs +0 -16
- package/examples/imported/sfdx-project.json +0 -12
- package/examples/markdown/.forceignore +0 -12
- package/examples/markdown/README.md +0 -7
- 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/README.md +0 -9
- package/examples/markdown-jsconfig/apexdocs.config.mjs +0 -22
- 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/README.md +0 -5
- package/examples/open-api/config/project-scratch-def.json +0 -13
- package/examples/open-api/docs/openapi.json +0 -14
- 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/README.md +0 -25
- package/examples/vitepress/apexdocs.config.ts +0 -113
- 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/Url.cls +0 -198
- package/examples/vitepress/force-app/main/default/classes/feature-a/SampleClass.cls +0 -73
- package/examples/vitepress/force-app/main/default/classes/feature-a/SampleEnum.cls +0 -30
- package/examples/vitepress/force-app/main/default/classes/feature-a/SampleException.cls +0 -17
- package/examples/vitepress/force-app/main/default/classes/feature-a/SampleInterface.cls +0 -46
- 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 -69
- package/src/application/__tests__/apex-file-reader.spec.ts +0 -128
- package/src/application/apex-file-reader.ts +0 -56
- 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 -75
- package/src/cli/args.ts +0 -55
- package/src/cli/commands/markdown.ts +0 -56
- package/src/cli/commands/openapi.ts +0 -36
- package/src/cli/generate.ts +0 -32
- 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 -362
- package/src/core/markdown/__test__/generating-docs.spec.ts +0 -378
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -61
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -169
- package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -196
- package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
- package/src/core/markdown/__test__/test-helpers.ts +0 -25
- package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
- package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -150
- 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 -91
- 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 -210
- package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +0 -290
- package/src/core/markdown/reflection/__test__/helpers.ts +0 -18
- package/src/core/markdown/reflection/__test__/remove-excluded-tags.spec.ts +0 -200
- 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/remove-excluded-tags.ts +0 -168
- package/src/core/markdown/reflection/sort-types-and-members.ts +0 -61
- 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 -59
- 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 -163
- 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 -150
- package/src/core/shared/utils.ts +0 -5
- package/src/defaults.ts +0 -21
- package/src/index.ts +0 -110
- 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 -51
- package/src/util/string-utils.ts +0 -7
- package/tsconfig.json +0 -25
- package/tslint.json +0 -6
|
@@ -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
|
-
});
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { ClassMirror, EnumMirror, InterfaceMirror, Type } from '@cparra/apex-reflection';
|
|
2
|
-
import {
|
|
3
|
-
RenderableType,
|
|
4
|
-
RenderableClass,
|
|
5
|
-
RenderableEnum,
|
|
6
|
-
RenderableInterface,
|
|
7
|
-
RenderableSection,
|
|
8
|
-
GroupedMember,
|
|
9
|
-
ClassMirrorWithInheritanceChain,
|
|
10
|
-
FieldMirrorWithInheritance,
|
|
11
|
-
PropertyMirrorWithInheritance,
|
|
12
|
-
GetRenderableContentByTypeName,
|
|
13
|
-
} from './types';
|
|
14
|
-
import { adaptDescribable, adaptDocumentable } from './documentables';
|
|
15
|
-
import { adaptConstructor, adaptMethod } from './methods-and-constructors';
|
|
16
|
-
import { adaptFieldOrProperty } from './fields-and-properties';
|
|
17
|
-
import { MarkdownGeneratorConfig } from '../generate-docs';
|
|
18
|
-
import { SourceFileMetadata } from '../../shared/types';
|
|
19
|
-
|
|
20
|
-
type GetReturnRenderable<T extends Type> = T extends InterfaceMirror
|
|
21
|
-
? RenderableInterface
|
|
22
|
-
: T extends ClassMirror
|
|
23
|
-
? RenderableClass
|
|
24
|
-
: RenderableEnum;
|
|
25
|
-
|
|
26
|
-
export function typeToRenderable<T extends Type>(
|
|
27
|
-
parsedFile: { source: SourceFileMetadata; type: T },
|
|
28
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
29
|
-
config: MarkdownGeneratorConfig,
|
|
30
|
-
): GetReturnRenderable<T> & { filePath: string; namespace?: string } {
|
|
31
|
-
function getRenderable(): RenderableInterface | RenderableClass | RenderableEnum {
|
|
32
|
-
const { type } = parsedFile;
|
|
33
|
-
switch (type.type_name) {
|
|
34
|
-
case 'enum':
|
|
35
|
-
return enumTypeToEnumSource(type as EnumMirror, linkGenerator) as RenderableEnum;
|
|
36
|
-
case 'interface':
|
|
37
|
-
return interfaceTypeToInterfaceSource(type as InterfaceMirror, linkGenerator) as RenderableInterface;
|
|
38
|
-
case 'class':
|
|
39
|
-
return classTypeToClassSource(type as ClassMirrorWithInheritanceChain, linkGenerator) as RenderableClass;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return {
|
|
44
|
-
...(getRenderable() as GetReturnRenderable<T>),
|
|
45
|
-
filePath: parsedFile.source.filePath,
|
|
46
|
-
namespace: config.namespace,
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function baseTypeAdapter(
|
|
51
|
-
type: EnumMirror | InterfaceMirror | ClassMirror,
|
|
52
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
53
|
-
baseHeadingLevel: number,
|
|
54
|
-
): RenderableType {
|
|
55
|
-
function getHeading(type: Type): string {
|
|
56
|
-
const suffixMap = {
|
|
57
|
-
class: 'Class',
|
|
58
|
-
interface: 'Interface',
|
|
59
|
-
enum: 'Enum',
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return `${type.name} ${suffixMap[type.type_name]}`;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return {
|
|
66
|
-
headingLevel: baseHeadingLevel,
|
|
67
|
-
heading: getHeading(type),
|
|
68
|
-
doc: adaptDocumentable(type, linkGenerator, baseHeadingLevel + 1),
|
|
69
|
-
name: type.name,
|
|
70
|
-
meta: {
|
|
71
|
-
accessModifier: type.access_modifier,
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function enumTypeToEnumSource(
|
|
77
|
-
enumType: EnumMirror,
|
|
78
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
79
|
-
baseHeadingLevel: number = 1,
|
|
80
|
-
): RenderableEnum {
|
|
81
|
-
return {
|
|
82
|
-
type: 'enum',
|
|
83
|
-
...baseTypeAdapter(enumType, linkGenerator, baseHeadingLevel),
|
|
84
|
-
values: {
|
|
85
|
-
headingLevel: baseHeadingLevel + 1,
|
|
86
|
-
heading: 'Values',
|
|
87
|
-
value: enumType.values.map((value) => ({
|
|
88
|
-
...adaptDescribable(value.docComment?.descriptionLines, linkGenerator),
|
|
89
|
-
value: value.name,
|
|
90
|
-
})),
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function interfaceTypeToInterfaceSource(
|
|
96
|
-
interfaceType: InterfaceMirror,
|
|
97
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
98
|
-
baseHeadingLevel: number = 1,
|
|
99
|
-
): RenderableInterface {
|
|
100
|
-
return {
|
|
101
|
-
type: 'interface',
|
|
102
|
-
...baseTypeAdapter(interfaceType, linkGenerator, baseHeadingLevel),
|
|
103
|
-
extends: interfaceType.extended_interfaces.map(linkGenerator),
|
|
104
|
-
methods: {
|
|
105
|
-
headingLevel: baseHeadingLevel + 1,
|
|
106
|
-
heading: 'Methods',
|
|
107
|
-
value: interfaceType.methods.map((method) => adaptMethod(method, linkGenerator, baseHeadingLevel + 2)),
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function classTypeToClassSource(
|
|
113
|
-
classType: ClassMirrorWithInheritanceChain,
|
|
114
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
115
|
-
baseHeadingLevel: number = 1,
|
|
116
|
-
): RenderableClass {
|
|
117
|
-
return {
|
|
118
|
-
type: 'class',
|
|
119
|
-
...baseTypeAdapter(classType, linkGenerator, baseHeadingLevel),
|
|
120
|
-
classModifier: classType.classModifier,
|
|
121
|
-
sharingModifier: classType.sharingModifier,
|
|
122
|
-
implements: classType.implemented_interfaces.map(linkGenerator),
|
|
123
|
-
extends: classType.inheritanceChain.map(linkGenerator),
|
|
124
|
-
methods: adaptMembers('Methods', classType.methods, adaptMethod, linkGenerator, baseHeadingLevel + 1),
|
|
125
|
-
constructors: adaptMembers(
|
|
126
|
-
'Constructors',
|
|
127
|
-
classType.constructors,
|
|
128
|
-
(constructor, linkGenerator, baseHeadingLevel) =>
|
|
129
|
-
adaptConstructor(classType.name, constructor, linkGenerator, baseHeadingLevel),
|
|
130
|
-
linkGenerator,
|
|
131
|
-
baseHeadingLevel + 1,
|
|
132
|
-
),
|
|
133
|
-
fields: adaptMembers(
|
|
134
|
-
'Fields',
|
|
135
|
-
classType.fields as FieldMirrorWithInheritance[],
|
|
136
|
-
adaptFieldOrProperty,
|
|
137
|
-
linkGenerator,
|
|
138
|
-
baseHeadingLevel + 1,
|
|
139
|
-
),
|
|
140
|
-
properties: adaptMembers(
|
|
141
|
-
'Properties',
|
|
142
|
-
classType.properties as PropertyMirrorWithInheritance[],
|
|
143
|
-
adaptFieldOrProperty,
|
|
144
|
-
linkGenerator,
|
|
145
|
-
baseHeadingLevel + 1,
|
|
146
|
-
),
|
|
147
|
-
innerClasses: {
|
|
148
|
-
headingLevel: baseHeadingLevel + 1,
|
|
149
|
-
heading: 'Classes',
|
|
150
|
-
value: classType.classes.map((innerClass) =>
|
|
151
|
-
classTypeToClassSource({ ...innerClass, inheritanceChain: [] }, linkGenerator, baseHeadingLevel + 2),
|
|
152
|
-
),
|
|
153
|
-
},
|
|
154
|
-
innerEnums: {
|
|
155
|
-
headingLevel: baseHeadingLevel + 1,
|
|
156
|
-
heading: 'Enums',
|
|
157
|
-
value: classType.enums.map((innerEnum) => enumTypeToEnumSource(innerEnum, linkGenerator, baseHeadingLevel + 2)),
|
|
158
|
-
},
|
|
159
|
-
innerInterfaces: {
|
|
160
|
-
headingLevel: baseHeadingLevel + 1,
|
|
161
|
-
heading: 'Interfaces',
|
|
162
|
-
value: classType.interfaces.map((innerInterface) =>
|
|
163
|
-
interfaceTypeToInterfaceSource(innerInterface, linkGenerator, baseHeadingLevel + 2),
|
|
164
|
-
),
|
|
165
|
-
},
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
type Groupable = { group?: string; groupDescription?: string };
|
|
170
|
-
|
|
171
|
-
function adaptMembers<T extends Groupable, K>(
|
|
172
|
-
heading: string,
|
|
173
|
-
members: T[],
|
|
174
|
-
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
175
|
-
linkFromTypeNameGenerator: GetRenderableContentByTypeName,
|
|
176
|
-
headingLevel: number,
|
|
177
|
-
): RenderableSection<K[] | GroupedMember<K>[]> & { isGrouped: boolean } {
|
|
178
|
-
return {
|
|
179
|
-
headingLevel,
|
|
180
|
-
heading,
|
|
181
|
-
isGrouped: hasGroup(members),
|
|
182
|
-
value: hasGroup(members)
|
|
183
|
-
? toGroupedMembers(members, adapter, linkFromTypeNameGenerator, headingLevel + 1)
|
|
184
|
-
: toFlat(members, adapter, linkFromTypeNameGenerator, headingLevel + 1),
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function hasGroup(members: Groupable[]): boolean {
|
|
189
|
-
return members.some((member) => member.group);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function toFlat<T extends Groupable, K>(
|
|
193
|
-
members: T[],
|
|
194
|
-
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
195
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
196
|
-
baseHeadingLevel: number,
|
|
197
|
-
): K[] {
|
|
198
|
-
return members.map((member) => adapter(member, linkGenerator, baseHeadingLevel));
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function toGroupedMembers<T extends Groupable, K>(
|
|
202
|
-
members: T[],
|
|
203
|
-
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
204
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
205
|
-
baseHeadingLevel: number,
|
|
206
|
-
): GroupedMember<K>[] {
|
|
207
|
-
const groupedMembers = groupByGroupName(members);
|
|
208
|
-
return Object.entries(groupedMembers).map(([groupName, members]) =>
|
|
209
|
-
singleGroup(baseHeadingLevel, groupName, adapter, members, linkGenerator),
|
|
210
|
-
);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
function groupByGroupName<T extends Groupable>(members: T[]): Record<string, T[]> {
|
|
214
|
-
return members.reduce(
|
|
215
|
-
(acc, member) => {
|
|
216
|
-
const groupName = member.group ?? 'Other';
|
|
217
|
-
acc[groupName] = acc[groupName] ?? [];
|
|
218
|
-
acc[groupName].push(member);
|
|
219
|
-
return acc;
|
|
220
|
-
},
|
|
221
|
-
{} as Record<string, T[]>,
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function singleGroup<T extends Groupable, K>(
|
|
226
|
-
headingLevel: number,
|
|
227
|
-
groupName: string,
|
|
228
|
-
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
229
|
-
members: T[],
|
|
230
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
231
|
-
): GroupedMember<K> {
|
|
232
|
-
return {
|
|
233
|
-
headingLevel: headingLevel,
|
|
234
|
-
heading: groupName,
|
|
235
|
-
groupDescription: members[0].groupDescription, // All fields in the group have the same description
|
|
236
|
-
value: toFlat(members, adapter, linkGenerator, headingLevel + 1),
|
|
237
|
-
};
|
|
238
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { CustomTag, RenderableDocumentation, RenderableContent } from './types';
|
|
2
|
-
import { Describable, Documentable, GetRenderableContentByTypeName } from './types';
|
|
3
|
-
import { replaceInlineReferences } from './inline';
|
|
4
|
-
import { isEmptyLine } from './type-utils';
|
|
5
|
-
|
|
6
|
-
export function adaptDescribable(
|
|
7
|
-
describable: Describable,
|
|
8
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
9
|
-
): {
|
|
10
|
-
description?: RenderableContent[];
|
|
11
|
-
} {
|
|
12
|
-
return {
|
|
13
|
-
description: describableToRenderableContent(describable, linkGenerator),
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function describableToRenderableContent(
|
|
18
|
-
describable: Describable,
|
|
19
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
20
|
-
): RenderableContent[] | undefined {
|
|
21
|
-
if (!describable) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let content: RenderableContent[] = [];
|
|
26
|
-
for (let i = 0; i < describable.length; i++) {
|
|
27
|
-
const line = describable[i];
|
|
28
|
-
// The language might or might not be present after ```
|
|
29
|
-
const codeBlockMatch = line.match(/^```([a-zA-Z]*)$/);
|
|
30
|
-
if (codeBlockMatch) {
|
|
31
|
-
// Check if the language is present, if not, fallback to "apex"
|
|
32
|
-
const language = codeBlockMatch[1] || 'apex';
|
|
33
|
-
const codeBlockLines: string[] = [];
|
|
34
|
-
i++;
|
|
35
|
-
while (i < describable.length) {
|
|
36
|
-
const currentLine = describable[i];
|
|
37
|
-
if (currentLine.trim() === '```') {
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
codeBlockLines.push(currentLine);
|
|
41
|
-
i++;
|
|
42
|
-
}
|
|
43
|
-
content = [
|
|
44
|
-
...content,
|
|
45
|
-
{
|
|
46
|
-
__type: 'code-block',
|
|
47
|
-
language,
|
|
48
|
-
content: codeBlockLines,
|
|
49
|
-
},
|
|
50
|
-
{ __type: 'empty-line' },
|
|
51
|
-
];
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
content = [
|
|
56
|
-
...content,
|
|
57
|
-
...replaceInlineReferences(line, linkGenerator),
|
|
58
|
-
{
|
|
59
|
-
__type: 'empty-line',
|
|
60
|
-
},
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
return (
|
|
64
|
-
content
|
|
65
|
-
// If the last element is an empty line, remove it
|
|
66
|
-
.filter((line, index, lines) => !(isEmptyLine(line) && index === lines.length - 1))
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function adaptDocumentable(
|
|
71
|
-
documentable: Documentable,
|
|
72
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
73
|
-
subHeadingLevel: number,
|
|
74
|
-
): RenderableDocumentation {
|
|
75
|
-
function extractCustomTags(type: Documentable): CustomTag[] {
|
|
76
|
-
const baseTags = ['description', 'group', 'author', 'date', 'see', 'example', 'throws', 'exception'];
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
type.docComment?.annotations
|
|
80
|
-
.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase()))
|
|
81
|
-
.map<CustomTag>((currentAnnotation) => ({
|
|
82
|
-
...adaptDescribable(currentAnnotation.bodyLines, linkGenerator),
|
|
83
|
-
name: currentAnnotation.name,
|
|
84
|
-
})) ?? []
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function extractAnnotationBody(type: Documentable, annotationName: string): string | undefined {
|
|
89
|
-
return type.docComment?.annotations.find(
|
|
90
|
-
(currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName,
|
|
91
|
-
)?.body;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function extractSeeAnnotations(type: Documentable): string[] {
|
|
95
|
-
return (
|
|
96
|
-
type.docComment?.annotations
|
|
97
|
-
.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === 'see')
|
|
98
|
-
.map((currentAnnotation) => currentAnnotation.body) ?? []
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
...adaptDescribable(documentable.docComment?.descriptionLines, linkGenerator),
|
|
103
|
-
annotations: documentable.annotations.map((annotation) => annotation.type.toUpperCase()),
|
|
104
|
-
customTags: extractCustomTags(documentable),
|
|
105
|
-
example: {
|
|
106
|
-
headingLevel: subHeadingLevel,
|
|
107
|
-
heading: 'Example',
|
|
108
|
-
value: describableToRenderableContent(documentable.docComment?.exampleAnnotation?.bodyLines, linkGenerator),
|
|
109
|
-
},
|
|
110
|
-
group: extractAnnotationBody(documentable, 'group'),
|
|
111
|
-
author: extractAnnotationBody(documentable, 'author'),
|
|
112
|
-
date: extractAnnotationBody(documentable, 'date'),
|
|
113
|
-
sees: extractSeeAnnotations(documentable).map(linkGenerator),
|
|
114
|
-
};
|
|
115
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CodeBlock,
|
|
3
|
-
FieldMirrorWithInheritance,
|
|
4
|
-
PropertyMirrorWithInheritance,
|
|
5
|
-
RenderableField,
|
|
6
|
-
GetRenderableContentByTypeName,
|
|
7
|
-
} from './types';
|
|
8
|
-
import { adaptDocumentable } from './documentables';
|
|
9
|
-
|
|
10
|
-
export function adaptFieldOrProperty(
|
|
11
|
-
field: FieldMirrorWithInheritance | PropertyMirrorWithInheritance,
|
|
12
|
-
linkGenerator: GetRenderableContentByTypeName,
|
|
13
|
-
baseHeadingLevel: number,
|
|
14
|
-
): RenderableField {
|
|
15
|
-
function buildSignature(): CodeBlock {
|
|
16
|
-
const { access_modifier, name } = field;
|
|
17
|
-
const memberModifiers = field.memberModifiers.join(' ');
|
|
18
|
-
const codeContents = `${access_modifier} ${memberModifiers} ${name}`
|
|
19
|
-
// remove double spaces
|
|
20
|
-
.replace(/ {2}/g, ' ');
|
|
21
|
-
return {
|
|
22
|
-
__type: 'code-block',
|
|
23
|
-
language: 'apex',
|
|
24
|
-
content: [codeContents],
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
headingLevel: baseHeadingLevel,
|
|
30
|
-
doc: adaptDocumentable(field, linkGenerator, baseHeadingLevel + 1),
|
|
31
|
-
heading: field.name,
|
|
32
|
-
type: {
|
|
33
|
-
headingLevel: baseHeadingLevel + 1,
|
|
34
|
-
heading: 'Type',
|
|
35
|
-
value: linkGenerator(field.typeReference.rawDeclaration),
|
|
36
|
-
},
|
|
37
|
-
inherited: field.inherited,
|
|
38
|
-
accessModifier: field.access_modifier,
|
|
39
|
-
signature: {
|
|
40
|
-
headingLevel: baseHeadingLevel + 1,
|
|
41
|
-
heading: 'Signature',
|
|
42
|
-
value: buildSignature(),
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { StringOrLink } from './types';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { LinkingStrategy } from '../../shared/types';
|
|
4
|
-
|
|
5
|
-
export type LinkingStrategyFn = (
|
|
6
|
-
references: Record<string, { referencePath: string; displayName: string } | undefined>,
|
|
7
|
-
from: string,
|
|
8
|
-
referenceName: string,
|
|
9
|
-
) => StringOrLink;
|
|
10
|
-
|
|
11
|
-
export const generateLink = (strategy: LinkingStrategy): LinkingStrategyFn => {
|
|
12
|
-
switch (strategy) {
|
|
13
|
-
case 'relative':
|
|
14
|
-
return generateRelativeLink;
|
|
15
|
-
case 'no-link':
|
|
16
|
-
return generateNoLink;
|
|
17
|
-
case 'none':
|
|
18
|
-
return returnReferenceAsIs;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const generateRelativeLink = (
|
|
23
|
-
references: Record<string, { referencePath: string; displayName: string } | undefined>,
|
|
24
|
-
from: string, // The name of the file for which the reference is being generated
|
|
25
|
-
referenceName: string,
|
|
26
|
-
): StringOrLink => {
|
|
27
|
-
function getRelativePath(fromPath: string, toPath: string) {
|
|
28
|
-
return path.relative(path.parse(path.join('/', fromPath)).dir, path.join('/', toPath));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const referenceTo = references[referenceName];
|
|
32
|
-
if (!referenceTo) {
|
|
33
|
-
return referenceName;
|
|
34
|
-
}
|
|
35
|
-
// When linking from the base path (e.g. the reference guide/index page), the reference path is the same as the output
|
|
36
|
-
// path.
|
|
37
|
-
if (referenceTo && from === '__base__') {
|
|
38
|
-
return {
|
|
39
|
-
__type: 'link',
|
|
40
|
-
title: referenceTo.displayName,
|
|
41
|
-
url: getRelativePath('', referenceTo.referencePath),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const referenceFrom = references[from];
|
|
46
|
-
|
|
47
|
-
if (!referenceFrom) {
|
|
48
|
-
return referenceTo.displayName;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
__type: 'link',
|
|
53
|
-
title: referenceTo.displayName,
|
|
54
|
-
url: getRelativePath(referenceFrom.referencePath, referenceTo.referencePath),
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const generateNoLink = (
|
|
59
|
-
references: Record<string, { referencePath: string; displayName: string } | undefined>,
|
|
60
|
-
_from: string,
|
|
61
|
-
referenceName: string,
|
|
62
|
-
): StringOrLink => {
|
|
63
|
-
const referenceTo = references[referenceName];
|
|
64
|
-
return referenceTo ? referenceTo.displayName : referenceName;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const returnReferenceAsIs = (
|
|
68
|
-
references: Record<string, { referencePath: string; displayName: string } | undefined>,
|
|
69
|
-
_from: string,
|
|
70
|
-
referenceName: string,
|
|
71
|
-
): StringOrLink => {
|
|
72
|
-
const referenceTo = references[referenceName];
|
|
73
|
-
if (!referenceTo) {
|
|
74
|
-
return referenceName;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return {
|
|
78
|
-
__type: 'link',
|
|
79
|
-
title: referenceTo.displayName,
|
|
80
|
-
url: referenceTo.referencePath,
|
|
81
|
-
};
|
|
82
|
-
};
|