@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
package/src/cli/generate.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { Apexdocs } from '../application/Apexdocs';
|
|
3
|
-
import { extractArgs } from './args';
|
|
4
|
-
import { StdOutLogger } from '#utils/logger';
|
|
5
|
-
import * as E from 'fp-ts/Either';
|
|
6
|
-
|
|
7
|
-
const logger = new StdOutLogger();
|
|
8
|
-
|
|
9
|
-
function main() {
|
|
10
|
-
function parseResult(result: E.Either<unknown, string>) {
|
|
11
|
-
E.match(
|
|
12
|
-
(error) => {
|
|
13
|
-
logger.error(`❌ An error occurred while generating the documentation: ${error}`);
|
|
14
|
-
process.exit(1);
|
|
15
|
-
},
|
|
16
|
-
(successMessage: string) => {
|
|
17
|
-
logger.logSingle(successMessage);
|
|
18
|
-
},
|
|
19
|
-
)(result);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function catchUnexpectedError(error: Error) {
|
|
23
|
-
logger.error(`❌ An unexpected error occurred: ${error.message}`);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
extractArgs()
|
|
28
|
-
.then((config) => Apexdocs.generate(config, logger).then(parseResult))
|
|
29
|
-
.catch(catchUnexpectedError);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
main();
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Manifest from '../manifest';
|
|
2
|
-
import { EnumMirror } from '@cparra/apex-reflection';
|
|
3
|
-
|
|
4
|
-
const sampleEnum: EnumMirror = {
|
|
5
|
-
annotations: [],
|
|
6
|
-
name: 'SampleEnum',
|
|
7
|
-
type_name: 'enum',
|
|
8
|
-
access_modifier: 'public',
|
|
9
|
-
values: [],
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
it('holds a list of types', () => {
|
|
13
|
-
const types = [sampleEnum];
|
|
14
|
-
const manifest = new Manifest(types);
|
|
15
|
-
expect(manifest.types).toBe(types);
|
|
16
|
-
});
|
package/src/core/manifest.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Annotation,
|
|
3
|
-
ClassMirror,
|
|
4
|
-
DocComment,
|
|
5
|
-
DocCommentAnnotation,
|
|
6
|
-
EnumMirror,
|
|
7
|
-
InterfaceMirror,
|
|
8
|
-
Type,
|
|
9
|
-
} from '@cparra/apex-reflection';
|
|
10
|
-
|
|
11
|
-
type AccessAndDocAware = { access_modifier: string; annotations: Annotation[]; docComment?: DocComment };
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Represents the full library of Apex top-level types (classes, enums, and interface) for a Salesforce project.
|
|
15
|
-
*/
|
|
16
|
-
export default class Manifest {
|
|
17
|
-
/**
|
|
18
|
-
* Constructs a new Manifest object.
|
|
19
|
-
* @param types List of types to be wrapped by this object.
|
|
20
|
-
* @param isForInnerTypes Whether this manifest represent an inner type or not.
|
|
21
|
-
*/
|
|
22
|
-
constructor(
|
|
23
|
-
public types: Type[],
|
|
24
|
-
public isForInnerTypes: boolean = false,
|
|
25
|
-
) {}
|
|
26
|
-
|
|
27
|
-
filteredByAccessModifierAndAnnotations(modifiers: string[]): Type[] {
|
|
28
|
-
const filteredTypes = Manifest.filterAccessibleModifier(this.types, modifiers);
|
|
29
|
-
const typesToReturn: Type[] = [];
|
|
30
|
-
for (const filteredType of filteredTypes) {
|
|
31
|
-
typesToReturn.push(Manifest.filterSingleType(filteredType, modifiers, this.isForInnerTypes));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return typesToReturn;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
static filterSingleType(currentType: Type, modifiers: string[], isForInnerTypes: boolean): Type {
|
|
38
|
-
if (currentType.type_name === 'enum') {
|
|
39
|
-
// Ignoring enum values is not supported.
|
|
40
|
-
return currentType;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (currentType.type_name === 'interface') {
|
|
44
|
-
const currentInterface = currentType as InterfaceMirror;
|
|
45
|
-
return {
|
|
46
|
-
...currentType,
|
|
47
|
-
methods: this.filterAccessibleModifier(currentInterface.methods, modifiers),
|
|
48
|
-
} as InterfaceMirror;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const currentClass = currentType as ClassMirror;
|
|
52
|
-
const filteredClass = {
|
|
53
|
-
...currentType,
|
|
54
|
-
methods: this.filterAccessibleModifier(currentClass.methods, modifiers),
|
|
55
|
-
properties: this.filterAccessibleModifier(currentClass.properties, modifiers),
|
|
56
|
-
fields: this.filterAccessibleModifier(currentClass.fields, modifiers),
|
|
57
|
-
constructors: this.filterAccessibleModifier(currentClass.constructors, modifiers),
|
|
58
|
-
} as ClassMirror;
|
|
59
|
-
|
|
60
|
-
if (!isForInnerTypes) {
|
|
61
|
-
return {
|
|
62
|
-
...filteredClass,
|
|
63
|
-
enums: this.filterAccessibleModifier(currentClass.enums, modifiers) as EnumMirror[],
|
|
64
|
-
interfaces: this.filterAccessibleModifier(currentClass.interfaces, modifiers) as InterfaceMirror[],
|
|
65
|
-
classes: new Manifest(currentClass.classes, true).filteredByAccessModifierAndAnnotations(
|
|
66
|
-
modifiers,
|
|
67
|
-
) as ClassMirror[],
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return filteredClass;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static filterAccessibleModifier<T extends AccessAndDocAware>(accessAndDocAware: T[], modifiers: string[]): T[] {
|
|
75
|
-
return accessAndDocAware.filter((type) => this.shouldFilterType(type, modifiers));
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static shouldFilterType(accessAndDocAware: AccessAndDocAware, modifiers: string[]) {
|
|
79
|
-
const hasIgnoreDocAnnotation = accessAndDocAware.docComment?.annotations.some(
|
|
80
|
-
(annotation: DocCommentAnnotation) => annotation.name.toLowerCase() === 'ignore',
|
|
81
|
-
);
|
|
82
|
-
if (hasIgnoreDocAnnotation) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return (
|
|
86
|
-
modifiers.includes(accessAndDocAware.access_modifier) ||
|
|
87
|
-
accessAndDocAware.annotations.some((annotation: Annotation) => modifiers.includes(annotation.type.toLowerCase()))
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import * as E from 'fp-ts/Either';
|
|
2
|
-
import { DocumentationBundle } from '../../shared/types';
|
|
3
|
-
|
|
4
|
-
export function extendExpect() {
|
|
5
|
-
expect.extend({
|
|
6
|
-
documentationBundleHasLength(received: E.Either<string[], DocumentationBundle>, length: number) {
|
|
7
|
-
return {
|
|
8
|
-
pass: E.isRight(received) && received.right.docs.length === length,
|
|
9
|
-
message: () => `Expected documentation bundle to have length ${length}`,
|
|
10
|
-
};
|
|
11
|
-
},
|
|
12
|
-
firstDocContains(doc: DocumentationBundle, content: string) {
|
|
13
|
-
return {
|
|
14
|
-
pass: doc.docs[0].content.includes(content),
|
|
15
|
-
message: () => `Expected documentation to contain ${content}. Got ${doc.docs[0].content}`,
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
firstDocContainsNot(doc: DocumentationBundle, content: string) {
|
|
19
|
-
return {
|
|
20
|
-
pass: !doc.docs[0].content.includes(content),
|
|
21
|
-
message: () => `Expected documentation to not contain ${content}. Got ${doc.docs[0].content}`,
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function assertEither<T, U>(result: E.Either<T, U>, assertion: (data: U) => void): void {
|
|
28
|
-
E.match<T, U, void>(
|
|
29
|
-
(error) => fail(error),
|
|
30
|
-
(data) => assertion(data),
|
|
31
|
-
)(result);
|
|
32
|
-
}
|
|
@@ -1,362 +0,0 @@
|
|
|
1
|
-
import { assertEither, extendExpect } from './expect-extensions';
|
|
2
|
-
import { apexBundleFromRawString, generateDocs } from './test-helpers';
|
|
3
|
-
|
|
4
|
-
describe('When generating documentation for a class', () => {
|
|
5
|
-
beforeAll(() => {
|
|
6
|
-
extendExpect();
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
describe('member information', () => {
|
|
10
|
-
it('displays the Method heading', async () => {
|
|
11
|
-
const input = `
|
|
12
|
-
public class MyClass {
|
|
13
|
-
public void myMethod() {}
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
18
|
-
expect(result).documentationBundleHasLength(1);
|
|
19
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Methods'));
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('sorts methods when sorting members alphabetically', async () => {
|
|
23
|
-
const input = `
|
|
24
|
-
public class MyClass {
|
|
25
|
-
public void zMethod() {}
|
|
26
|
-
public void aMethod() {}
|
|
27
|
-
}
|
|
28
|
-
`;
|
|
29
|
-
|
|
30
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
31
|
-
expect(result).documentationBundleHasLength(1);
|
|
32
|
-
assertEither(result, (data) => {
|
|
33
|
-
const aMethodIndex = data.docs[0].content.indexOf('aMethod');
|
|
34
|
-
const zMethodIndex = data.docs[0].content.indexOf('zMethod');
|
|
35
|
-
expect(aMethodIndex).toBeLessThan(zMethodIndex);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('does not sort methods when not sorting members alphabetically', async () => {
|
|
40
|
-
const input = `
|
|
41
|
-
public class MyClass {
|
|
42
|
-
public void zMethod() {}
|
|
43
|
-
public void aMethod() {}
|
|
44
|
-
}
|
|
45
|
-
`;
|
|
46
|
-
|
|
47
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
48
|
-
expect(result).documentationBundleHasLength(1);
|
|
49
|
-
assertEither(result, (data) => {
|
|
50
|
-
const aMethodIndex = data.docs[0].content.indexOf('aMethod');
|
|
51
|
-
const zMethodIndex = data.docs[0].content.indexOf('zMethod');
|
|
52
|
-
expect(aMethodIndex).toBeGreaterThan(zMethodIndex);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('displays the Property heading', async () => {
|
|
57
|
-
const input = `
|
|
58
|
-
public class MyClass {
|
|
59
|
-
public String myProperty { get; set; }
|
|
60
|
-
}
|
|
61
|
-
`;
|
|
62
|
-
|
|
63
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
64
|
-
expect(result).documentationBundleHasLength(1);
|
|
65
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Properties'));
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('sorts properties when sorting members alphabetically', async () => {
|
|
69
|
-
const input = `
|
|
70
|
-
public class MyClass {
|
|
71
|
-
public String zProperty { get; set; }
|
|
72
|
-
public String aProperty { get; set; }
|
|
73
|
-
}
|
|
74
|
-
`;
|
|
75
|
-
|
|
76
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
77
|
-
expect(result).documentationBundleHasLength(1);
|
|
78
|
-
assertEither(result, (data) => {
|
|
79
|
-
const aPropertyIndex = data.docs[0].content.indexOf('aProperty');
|
|
80
|
-
const zPropertyIndex = data.docs[0].content.indexOf('zProperty');
|
|
81
|
-
expect(aPropertyIndex).toBeLessThan(zPropertyIndex);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('does not sort properties when not sorting members alphabetically', async () => {
|
|
86
|
-
const input = `
|
|
87
|
-
public class MyClass {
|
|
88
|
-
public String zProperty { get; set; }
|
|
89
|
-
public String aProperty { get; set; }
|
|
90
|
-
}
|
|
91
|
-
`;
|
|
92
|
-
|
|
93
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
94
|
-
expect(result).documentationBundleHasLength(1);
|
|
95
|
-
assertEither(result, (data) => {
|
|
96
|
-
const aPropertyIndex = data.docs[0].content.indexOf('aProperty');
|
|
97
|
-
const zPropertyIndex = data.docs[0].content.indexOf('zProperty');
|
|
98
|
-
expect(aPropertyIndex).toBeGreaterThan(zPropertyIndex);
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('displays the Field heading', async () => {
|
|
103
|
-
const input = `
|
|
104
|
-
public class MyClass {
|
|
105
|
-
public String myField;
|
|
106
|
-
}
|
|
107
|
-
`;
|
|
108
|
-
|
|
109
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
110
|
-
expect(result).documentationBundleHasLength(1);
|
|
111
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Fields'));
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('sort fields when sorting members alphabetically', async () => {
|
|
115
|
-
const input = `
|
|
116
|
-
public class MyClass {
|
|
117
|
-
public String zField;
|
|
118
|
-
public String aField;
|
|
119
|
-
}
|
|
120
|
-
`;
|
|
121
|
-
|
|
122
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
123
|
-
expect(result).documentationBundleHasLength(1);
|
|
124
|
-
assertEither(result, (data) => {
|
|
125
|
-
const aFieldIndex = data.docs[0].content.indexOf('aField');
|
|
126
|
-
const zFieldIndex = data.docs[0].content.indexOf('zField');
|
|
127
|
-
expect(aFieldIndex).toBeLessThan(zFieldIndex);
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('does not sort fields when not sorting members alphabetically', async () => {
|
|
132
|
-
const input = `
|
|
133
|
-
public class MyClass {
|
|
134
|
-
public String zField;
|
|
135
|
-
public String aField;
|
|
136
|
-
}
|
|
137
|
-
`;
|
|
138
|
-
|
|
139
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
140
|
-
expect(result).documentationBundleHasLength(1);
|
|
141
|
-
assertEither(result, (data) => {
|
|
142
|
-
const aFieldIndex = data.docs[0].content.indexOf('aField');
|
|
143
|
-
const zFieldIndex = data.docs[0].content.indexOf('zField');
|
|
144
|
-
expect(aFieldIndex).toBeGreaterThan(zFieldIndex);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('displays the Constructor heading', async () => {
|
|
149
|
-
const input = `
|
|
150
|
-
public class MyClass {
|
|
151
|
-
public MyClass() {}
|
|
152
|
-
}
|
|
153
|
-
`;
|
|
154
|
-
|
|
155
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
156
|
-
expect(result).documentationBundleHasLength(1);
|
|
157
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Constructors'));
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('displays the Inner Class heading', async () => {
|
|
161
|
-
const input = `
|
|
162
|
-
public class MyClass {
|
|
163
|
-
public class InnerClass {}
|
|
164
|
-
}
|
|
165
|
-
`;
|
|
166
|
-
|
|
167
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
168
|
-
expect(result).documentationBundleHasLength(1);
|
|
169
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Classes'));
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('sorts inner classes when sorting members alphabetically', async () => {
|
|
173
|
-
const input = `
|
|
174
|
-
public class MyClass {
|
|
175
|
-
public class ZInnerClass {}
|
|
176
|
-
public class AInnerClass {}
|
|
177
|
-
}
|
|
178
|
-
`;
|
|
179
|
-
|
|
180
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
181
|
-
expect(result).documentationBundleHasLength(1);
|
|
182
|
-
assertEither(result, (data) => {
|
|
183
|
-
const aInnerClassIndex = data.docs[0].content.indexOf('AInnerClass');
|
|
184
|
-
const zInnerClassIndex = data.docs[0].content.indexOf('ZInnerClass');
|
|
185
|
-
expect(aInnerClassIndex).toBeLessThan(zInnerClassIndex);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('does not sort inner classes when not sorting members alphabetically', async () => {
|
|
190
|
-
const input = `
|
|
191
|
-
public class MyClass {
|
|
192
|
-
public class ZInnerClass {}
|
|
193
|
-
public class AInnerClass {}
|
|
194
|
-
}
|
|
195
|
-
`;
|
|
196
|
-
|
|
197
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
198
|
-
expect(result).documentationBundleHasLength(1);
|
|
199
|
-
assertEither(result, (data) => {
|
|
200
|
-
const aInnerClassIndex = data.docs[0].content.indexOf('AInnerClass');
|
|
201
|
-
const zInnerClassIndex = data.docs[0].content.indexOf('ZInnerClass');
|
|
202
|
-
expect(aInnerClassIndex).toBeGreaterThan(zInnerClassIndex);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('displays the Inner Interface heading', async () => {
|
|
207
|
-
const input = `
|
|
208
|
-
public class MyClass {
|
|
209
|
-
public interface InnerInterface {}
|
|
210
|
-
}
|
|
211
|
-
`;
|
|
212
|
-
|
|
213
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
214
|
-
expect(result).documentationBundleHasLength(1);
|
|
215
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Interfaces'));
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it('sorts inner interfaces when sorting members alphabetically', async () => {
|
|
219
|
-
const input = `
|
|
220
|
-
public class MyClass {
|
|
221
|
-
public interface ZInnerInterface {}
|
|
222
|
-
public interface AInnerInterface {}
|
|
223
|
-
}
|
|
224
|
-
`;
|
|
225
|
-
|
|
226
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
227
|
-
expect(result).documentationBundleHasLength(1);
|
|
228
|
-
assertEither(result, (data) => {
|
|
229
|
-
const aInnerInterfaceIndex = data.docs[0].content.indexOf('AInnerInterface');
|
|
230
|
-
const zInnerInterfaceIndex = data.docs[0].content.indexOf('ZInnerInterface');
|
|
231
|
-
expect(aInnerInterfaceIndex).toBeLessThan(zInnerInterfaceIndex);
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
it('does not sort inner interfaces when not sorting members alphabetically', async () => {
|
|
236
|
-
const input = `
|
|
237
|
-
public class MyClass {
|
|
238
|
-
public interface ZInnerInterface {}
|
|
239
|
-
public interface AInnerInterface {}
|
|
240
|
-
}
|
|
241
|
-
`;
|
|
242
|
-
|
|
243
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
244
|
-
expect(result).documentationBundleHasLength(1);
|
|
245
|
-
assertEither(result, (data) => {
|
|
246
|
-
const aInnerInterfaceIndex = data.docs[0].content.indexOf('AInnerInterface');
|
|
247
|
-
const zInnerInterfaceIndex = data.docs[0].content.indexOf('ZInnerInterface');
|
|
248
|
-
expect(aInnerInterfaceIndex).toBeGreaterThan(zInnerInterfaceIndex);
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('displays the Inner Enum heading', async () => {
|
|
253
|
-
const input = `
|
|
254
|
-
public class MyClass {
|
|
255
|
-
public enum InnerEnum {}
|
|
256
|
-
}
|
|
257
|
-
`;
|
|
258
|
-
|
|
259
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
260
|
-
expect(result).documentationBundleHasLength(1);
|
|
261
|
-
assertEither(result, (data) => expect(data).firstDocContains('## Enums'));
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it('sort inner enums when sorting members alphabetically', async () => {
|
|
265
|
-
const input = `
|
|
266
|
-
public class MyClass {
|
|
267
|
-
public enum ZInnerEnum {}
|
|
268
|
-
public enum AInnerEnum {}
|
|
269
|
-
}
|
|
270
|
-
`;
|
|
271
|
-
|
|
272
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: true })();
|
|
273
|
-
expect(result).documentationBundleHasLength(1);
|
|
274
|
-
assertEither(result, (data) => {
|
|
275
|
-
const aInnerEnumIndex = data.docs[0].content.indexOf('AInnerEnum');
|
|
276
|
-
const zInnerEnumIndex = data.docs[0].content.indexOf('ZInnerEnum');
|
|
277
|
-
expect(aInnerEnumIndex).toBeLessThan(zInnerEnumIndex);
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it('does not sort inner enums when not sorting members alphabetically', async () => {
|
|
282
|
-
const input = `
|
|
283
|
-
public class MyClass {
|
|
284
|
-
public enum ZInnerEnum {}
|
|
285
|
-
public enum AInnerEnum {}
|
|
286
|
-
}
|
|
287
|
-
`;
|
|
288
|
-
|
|
289
|
-
const result = await generateDocs([apexBundleFromRawString(input)], { sortAlphabetically: false })();
|
|
290
|
-
expect(result).documentationBundleHasLength(1);
|
|
291
|
-
assertEither(result, (data) => {
|
|
292
|
-
const aInnerEnumIndex = data.docs[0].content.indexOf('AInnerEnum');
|
|
293
|
-
const zInnerEnumIndex = data.docs[0].content.indexOf('ZInnerEnum');
|
|
294
|
-
expect(aInnerEnumIndex).toBeGreaterThan(zInnerEnumIndex);
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it('supports having mermaid diagrams in descriptions', async () => {
|
|
299
|
-
const input = `
|
|
300
|
-
public class MyClass {
|
|
301
|
-
/**
|
|
302
|
-
* @mermaid
|
|
303
|
-
* \`\`\`mermaid
|
|
304
|
-
* graph TD
|
|
305
|
-
* A[Square Rect] -- Link text --> B((Circle))
|
|
306
|
-
* A --> C(Round Rect)
|
|
307
|
-
* B --> D{Rhombus}
|
|
308
|
-
* C --> D
|
|
309
|
-
* \`\`\`
|
|
310
|
-
*/
|
|
311
|
-
public void myMethod() {}
|
|
312
|
-
}
|
|
313
|
-
`;
|
|
314
|
-
|
|
315
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
316
|
-
expect(result).documentationBundleHasLength(1);
|
|
317
|
-
assertEither(result, (data) => expect(data).firstDocContains('```mermaid'));
|
|
318
|
-
assertEither(result, (data) => expect(data).firstDocContains('graph TD'));
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
it('supports having example code blocks in method descriptions', async () => {
|
|
322
|
-
const input = `
|
|
323
|
-
public class MyClass {
|
|
324
|
-
/**
|
|
325
|
-
* @example
|
|
326
|
-
* public class MyClass {
|
|
327
|
-
* public void myMethod() {
|
|
328
|
-
* System.debug('Hello, World!');
|
|
329
|
-
* }
|
|
330
|
-
* }
|
|
331
|
-
*/
|
|
332
|
-
public void myMethod() {}
|
|
333
|
-
}
|
|
334
|
-
`;
|
|
335
|
-
|
|
336
|
-
const result = await generateDocs([apexBundleFromRawString(input)])();
|
|
337
|
-
expect(result).documentationBundleHasLength(1);
|
|
338
|
-
assertEither(result, (data) => expect(data).firstDocContains('```apex'));
|
|
339
|
-
assertEither(result, (data) => expect(data).firstDocContains('public class MyClass'));
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
it('displays an "inherited" tag if the method was inherited from a different interface', async () => {
|
|
343
|
-
const input1 = `
|
|
344
|
-
public virtual class MyClass {
|
|
345
|
-
public void myMethod() {}
|
|
346
|
-
}
|
|
347
|
-
`;
|
|
348
|
-
|
|
349
|
-
const input2 = `
|
|
350
|
-
public class AnotherClass extends MyClass {}
|
|
351
|
-
`;
|
|
352
|
-
|
|
353
|
-
const result = await generateDocs([apexBundleFromRawString(input1), apexBundleFromRawString(input2)])();
|
|
354
|
-
expect(result).documentationBundleHasLength(2);
|
|
355
|
-
assertEither(result, (data) =>
|
|
356
|
-
expect(data.docs.find((doc) => doc.source.name === 'AnotherClass')?.content).toContain('Inherited'),
|
|
357
|
-
);
|
|
358
|
-
});
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
|
|
362
|
-
// TODO: Skips tags at the member level
|