@cparra/apexdocs 2.25.0-alpha.4 → 2.25.0-alpha.6
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/dist/cli/generate.js +2745 -39
- package/dist/defaults-DUwru49Q.js +12 -0
- package/dist/defaults-SH0Rsi5E.js +11 -0
- package/dist/index.d.ts +62 -2
- package/dist/index.js +36 -1
- package/examples/plain-markdown/docs/Miscellaneous/ns.BaseClass.md +1 -1
- package/examples/plain-markdown/docs/Miscellaneous/ns.MultiInheritanceClass.md +1 -1
- package/examples/plain-markdown/docs/Miscellaneous/ns.ParentInterface.md +1 -1
- package/examples/plain-markdown/docs/Miscellaneous/ns.ReferencedEnum.md +1 -1
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleException.md +1 -1
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleInterface.md +1 -1
- package/examples/plain-markdown/docs/Miscellaneous/ns.Url.md +1 -1
- package/examples/plain-markdown/docs/Sample-Enums/ns.SampleEnum.md +1 -1
- package/examples/plain-markdown/docs/SampleGroup/ns.SampleClass.md +1 -1
- package/examples/plain-markdown/docs/index.md +1 -1
- package/examples/plain-markdown/package.json +3 -4
- package/examples/vitepress/.forceignore +12 -0
- package/examples/vitepress/apexdocs.config.ts +108 -0
- package/examples/vitepress/config/project-scratch-def.json +13 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +259 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +40 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +11474 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +9172 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/package.json +3 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4339 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +567 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +323 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/config.mts +21 -0
- package/examples/vitepress/docs/.vitepress/sidebar.json +119 -0
- package/examples/vitepress/docs/Miscellaneous/apexdocs.BaseClass.md +20 -0
- package/examples/vitepress/docs/Miscellaneous/apexdocs.MultiInheritanceClass.md +78 -0
- package/examples/vitepress/docs/Miscellaneous/apexdocs.ParentInterface.md +19 -0
- package/examples/vitepress/docs/Miscellaneous/apexdocs.ReferencedEnum.md +15 -0
- package/examples/vitepress/docs/Miscellaneous/apexdocs.SampleException.md +28 -0
- package/examples/vitepress/docs/Miscellaneous/apexdocs.SampleInterface.md +122 -0
- package/examples/vitepress/docs/Miscellaneous/apexdocs.Url.md +318 -0
- package/examples/vitepress/docs/Sample-Enums/apexdocs.SampleEnum.md +41 -0
- package/examples/vitepress/docs/SampleGroup/apexdocs.SampleClass.md +178 -0
- package/examples/vitepress/docs/api-examples.md +49 -0
- package/examples/vitepress/docs/index-frontmatter.md +16 -0
- package/examples/vitepress/docs/index.md +127 -0
- package/examples/vitepress/docs/markdown-examples.md +85 -0
- package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +3 -0
- package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +1 -0
- package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +3 -0
- package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +5 -0
- package/examples/vitepress/force-app/main/default/classes/SampleClass.cls +72 -0
- package/examples/vitepress/force-app/main/default/classes/SampleEnum.cls +30 -0
- package/examples/vitepress/force-app/main/default/classes/SampleException.cls +17 -0
- package/examples/vitepress/force-app/main/default/classes/SampleInterface.cls +46 -0
- package/examples/vitepress/force-app/main/default/classes/Url.cls +195 -0
- package/examples/vitepress/package-lock.json +2574 -0
- package/examples/vitepress/package.json +18 -0
- package/examples/vitepress/sfdx-project.json +12 -0
- package/jest.config.js +1 -0
- package/package.json +11 -10
- package/src/application/Apexdocs.ts +16 -104
- package/src/application/__tests__/apex-file-reader.spec.ts +104 -0
- package/src/application/apex-file-reader.ts +42 -0
- package/src/application/file-writer.ts +25 -0
- package/src/application/generators/markdown.ts +53 -0
- package/src/application/generators/openapi.ts +56 -0
- package/src/cli/args.ts +17 -112
- package/src/cli/commands/markdown.ts +58 -0
- package/src/cli/generate.ts +7 -5
- package/src/{model/__tests__ → core/__test__}/manifest.spec.ts +1 -1
- package/src/core/manifest.ts +57 -51
- package/src/{__spec__/core → core/markdown/__test__}/expect-extensions.ts +5 -5
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +727 -0
- package/src/{__spec__/core → core/markdown/__test__}/generating-enum-docs.spec.ts +82 -59
- package/src/{__spec__/core → core/markdown/__test__}/generating-interface-docs.spec.ts +94 -75
- package/src/core/markdown/__test__/generating-reference-guide.spec.ts +184 -0
- package/src/core/{__test__ → markdown/__test__}/inheritance-chain.test.ts +2 -2
- package/src/core/markdown/__test__/test-helpers.ts +22 -0
- package/src/core/{adapters → markdown/adapters}/__tests__/interface-adapter.spec.ts +38 -8
- package/src/core/{adapters → markdown/adapters}/apex-types.ts +7 -4
- package/src/core/{adapters → markdown/adapters}/inline.ts +1 -1
- package/src/core/markdown/adapters/renderable-bundle.ts +144 -0
- package/src/core/markdown/adapters/renderable-to-page-data.ts +92 -0
- package/src/core/{adapters → markdown/adapters}/types.d.ts +16 -2
- package/src/core/markdown/generate-docs.ts +158 -0
- package/src/core/markdown/reflection/error-handling.ts +37 -0
- package/src/core/markdown/reflection/filter-scope.ts +13 -0
- package/src/core/markdown/reflection/inheritance-chain-expanion.ts +22 -0
- package/src/core/markdown/reflection/inherited-member-expansion.ts +105 -0
- package/src/core/markdown/reflection/reflect-source.ts +41 -0
- package/src/core/markdown/reflection/sort-members.ts +59 -0
- package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/class-template.ts +2 -0
- package/src/core/markdown/templates/hookable.ts +7 -0
- package/src/core/{template.ts → markdown/templates/template.ts} +12 -12
- package/src/core/markdown/utils.ts +3 -0
- package/src/{transpiler → core}/openapi/__tests__/open-api-docs-processor.spec.ts +1 -1
- package/src/{model → core/openapi}/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +3 -3
- package/src/core/openapi/file-container.ts +13 -0
- package/src/{service → core/openapi}/manifest-factory.ts +3 -3
- package/src/{transpiler → core}/openapi/open-api-docs-processor.ts +9 -10
- package/src/core/openapi/openapi-type-file.ts +14 -0
- package/src/{service → core/openapi}/parser.ts +8 -8
- package/src/{transpiler → core}/openapi/parsers/Builder.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/MethodParser.ts +5 -5
- package/src/{transpiler → core}/openapi/parsers/ParameterObjectBuilder.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/ReferenceBuilder.ts +3 -3
- package/src/{transpiler → core}/openapi/parsers/RequestBodyBuilder.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/ResponsesBuilder.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/__tests__/MethodParser.spec.ts +1 -1
- package/src/{transpiler → core}/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +1 -1
- package/src/{transpiler → core/openapi}/transpiler.ts +2 -6
- package/src/{model → core/openapi}/types-repository.ts +0 -9
- package/src/core/parse-apex-metadata.ts +14 -0
- package/src/core/settings.ts +56 -0
- package/src/core/shared/types.d.ts +92 -0
- package/src/core/shared/utils.ts +5 -0
- package/src/defaults.ts +8 -0
- package/src/index.ts +34 -2
- package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -5
- package/src/test-helpers/SettingsBuilder.ts +1 -3
- package/src/util/logger.ts +2 -2
- package/src/util/string-utils.ts +0 -4
- package/tsconfig.json +5 -1
- package/apexdocs.config.ts +0 -13
- package/examples/plain-markdown/template.md +0 -3
- package/src/__spec__/core/generating-class-docs.spec.ts +0 -531
- package/src/__spec__/core/generating-reference-guide.spec.ts +0 -164
- package/src/__spec__/core/test-helpers.ts +0 -9
- package/src/application/generators/generate-markdown-files.ts +0 -53
- package/src/core/apex-bundle.ts +0 -3
- package/src/core/generate-docs.ts +0 -432
- package/src/model/markdown-file.ts +0 -122
- package/src/model/markdown-generation-util/doc-comment-annotation-util.ts +0 -50
- package/src/model/markdown-generation-util/field-declaration-util.ts +0 -71
- package/src/model/markdown-generation-util/index.ts +0 -3
- package/src/model/markdown-generation-util/method-declaration-util.ts +0 -166
- package/src/model/markdown-generation-util/type-declaration-util.ts +0 -91
- package/src/model/markdown-home-file.ts +0 -58
- package/src/model/markdown-type-file.ts +0 -169
- package/src/model/openapi/openapi-type-file.ts +0 -14
- package/src/model/outputFile.ts +0 -20
- package/src/service/__tests__/apex-file-reader.spec.ts +0 -93
- package/src/service/apex-file-reader.ts +0 -47
- package/src/service/file-writer.ts +0 -34
- package/src/service/metadata-processor.ts +0 -16
- package/src/service/state.ts +0 -24
- package/src/service/walkers/class-walker.ts +0 -30
- package/src/service/walkers/enum-walker.ts +0 -7
- package/src/service/walkers/interface-walker.ts +0 -12
- package/src/service/walkers/walker-factory.ts +0 -19
- package/src/service/walkers/walker.ts +0 -42
- package/src/settings.ts +0 -143
- package/src/transpiler/factory.ts +0 -31
- package/src/transpiler/file-container.ts +0 -13
- package/src/transpiler/generator-choices.ts +0 -1
- package/src/transpiler/markdown/class-file-generatorHelper.ts +0 -61
- package/src/transpiler/markdown/docsify/docsify-docs-processor.ts +0 -12
- package/src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts +0 -50
- package/src/transpiler/markdown/markdown-transpiler-base.ts +0 -28
- package/src/transpiler/processor-type-transpiler.ts +0 -18
- /package/src/{service → application}/file-system.ts +0 -0
- /package/src/core/{adapters → markdown/adapters}/__tests__/documentables.spec.ts +0 -0
- /package/src/core/{adapters → markdown/adapters}/__tests__/references.spec.ts +0 -0
- /package/src/core/{adapters → markdown/adapters}/documentables.ts +0 -0
- /package/src/core/{adapters → markdown/adapters}/fields-and-properties.ts +0 -0
- /package/src/core/{adapters → markdown/adapters}/methods-and-constructors.ts +0 -0
- /package/src/core/{adapters → markdown/adapters}/type-utils.ts +0 -0
- /package/src/core/{inheritance-chain.ts → markdown/reflection/inheritance-chain.ts} +0 -0
- /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/constructors-partial-template.ts +0 -0
- /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/documentable-partial-template.ts +0 -0
- /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/enum-template.ts +0 -0
- /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/fieldsPartialTemplate.ts +0 -0
- /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/grouped-members-partial-template.ts +0 -0
- /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/interface-template.ts +0 -0
- /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/methods-partial-template.ts +0 -0
- /package/src/core/{templates → markdown/templates}/reference-guide.ts +0 -0
- /package/src/{transpiler/markdown/plain-markdown → core/markdown/templates}/type-doc-partial.ts +0 -0
- /package/src/{service → core/openapi}/__tests__/manifest-factory.spec.ts +0 -0
- /package/src/{model → core}/openapi/__tests__/open-api.spec.ts +0 -0
- /package/src/{model → core}/openapi/apex-doc-types.ts +0 -0
- /package/src/{model → core/openapi}/apex-type-wrappers/ClassMirrorWrapper.ts +0 -0
- /package/src/{model → core/openapi}/apex-type-wrappers/MethodMirrorWrapper.ts +0 -0
- /package/src/{model → core}/openapi/open-api-types.ts +0 -0
- /package/src/{model → core}/openapi/open-api.ts +0 -0
package/src/cli/args.ts
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
import { Settings } from '../settings';
|
|
2
1
|
import { cosmiconfig, CosmiconfigResult } from 'cosmiconfig';
|
|
3
2
|
import * as yargs from 'yargs';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
onBeforeFileWrite: Settings['onBeforeFileWrite'];
|
|
8
|
-
frontMatterHeader: Settings['frontMatterHeader'];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type YargsArgs = ReturnType<typeof _extractYargs>;
|
|
12
|
-
|
|
13
|
-
type ConfigurableThroughFile = YargsArgs & OnlyConfigurableThroughFile;
|
|
14
|
-
|
|
15
|
-
export type AllConfigurableOptions = Partial<ConfigurableThroughFile> & YargsArgs;
|
|
3
|
+
import { UserDefinedMarkdownConfig } from '../core/shared/types';
|
|
4
|
+
import { TypeScriptLoader } from 'cosmiconfig-typescript-loader';
|
|
5
|
+
import { markdownOptions } from './commands/markdown';
|
|
16
6
|
|
|
17
7
|
/**
|
|
18
8
|
* Extracts configuration from a configuration file or the package.json
|
|
19
9
|
* through cosmiconfig.
|
|
20
10
|
*/
|
|
21
11
|
function _extractConfig(): Promise<CosmiconfigResult> {
|
|
22
|
-
return cosmiconfig('apexdocs'
|
|
12
|
+
return cosmiconfig('apexdocs', {
|
|
13
|
+
loaders: {
|
|
14
|
+
'.ts': TypeScriptLoader(),
|
|
15
|
+
},
|
|
16
|
+
}).search();
|
|
23
17
|
}
|
|
24
18
|
|
|
25
19
|
/**
|
|
@@ -29,110 +23,21 @@ function _extractConfig(): Promise<CosmiconfigResult> {
|
|
|
29
23
|
function _extractYargs(config?: CosmiconfigResult) {
|
|
30
24
|
return yargs
|
|
31
25
|
.config(config?.config)
|
|
32
|
-
.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
describe: 'The directory location which contains your apex .cls classes.',
|
|
38
|
-
},
|
|
39
|
-
targetDir: {
|
|
40
|
-
type: 'string',
|
|
41
|
-
alias: 't',
|
|
42
|
-
default: './docs/',
|
|
43
|
-
describe: 'The directory location where documentation will be generated to.',
|
|
44
|
-
},
|
|
45
|
-
recursive: {
|
|
46
|
-
type: 'boolean',
|
|
47
|
-
alias: 'r',
|
|
48
|
-
default: true,
|
|
49
|
-
deprecated: 'This option is no longer needed as the recursive search is always on.',
|
|
50
|
-
describe: 'Whether .cls classes will be searched for recursively in the directory provided.',
|
|
51
|
-
},
|
|
52
|
-
scope: {
|
|
53
|
-
type: 'string',
|
|
54
|
-
array: true,
|
|
55
|
-
alias: 'p',
|
|
56
|
-
default: ['global'],
|
|
57
|
-
describe:
|
|
58
|
-
'A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. ' +
|
|
59
|
-
'Annotations are supported and should be passed lowercased and without the @ symbol, e.g. namespaceaccessible auraenabled. ' +
|
|
60
|
-
'Note that this setting is ignored if generating an OpenApi REST specification since that looks for classes annotated with @RestResource.',
|
|
61
|
-
},
|
|
62
|
-
targetGenerator: {
|
|
63
|
-
type: 'string',
|
|
64
|
-
alias: 'g',
|
|
65
|
-
default: 'jekyll',
|
|
66
|
-
choices: ['jekyll', 'docsify', 'plain-markdown', 'openapi'],
|
|
67
|
-
describe:
|
|
68
|
-
'Define the static file generator for which the documents will be created. ' +
|
|
69
|
-
'Currently supports jekyll, docsify, plain markdown, and OpenAPI v3.1.0.',
|
|
70
|
-
},
|
|
71
|
-
indexOnly: {
|
|
72
|
-
type: 'boolean',
|
|
73
|
-
default: false,
|
|
74
|
-
describe: 'Defines whether only the index file should be generated.',
|
|
75
|
-
},
|
|
76
|
-
defaultGroupName: {
|
|
77
|
-
type: 'string',
|
|
78
|
-
default: 'Miscellaneous',
|
|
79
|
-
describe: 'Defines the @group name to be used when a file does not specify it.',
|
|
80
|
-
},
|
|
81
|
-
sanitizeHtml: {
|
|
82
|
-
type: 'boolean',
|
|
83
|
-
default: true,
|
|
84
|
-
deprecated: 'This option is no longer needed as the sanitization is always on.',
|
|
85
|
-
describe:
|
|
86
|
-
'When on, any special character within your ApexDocs is converted into its HTML code representation. ' +
|
|
87
|
-
'This is specially useful when generic objects are described within the docs, e.g. "List< Foo>", "Map<Foo, Bar>" ' +
|
|
88
|
-
'because otherwise the content within < and > would be treated as HTML tags and not shown in the output. ' +
|
|
89
|
-
'Content in @example blocks are never sanitized.',
|
|
90
|
-
},
|
|
91
|
-
openApiTitle: {
|
|
92
|
-
type: 'string',
|
|
93
|
-
default: 'Apex REST Api',
|
|
94
|
-
describe: 'If using "openapi" as the target generator, this allows you to specify the OpenApi title value.',
|
|
95
|
-
},
|
|
96
|
-
title: {
|
|
97
|
-
type: 'string',
|
|
98
|
-
describe: "Allows you to specify the title of the generated documentation's home file.",
|
|
99
|
-
default: 'Classes',
|
|
100
|
-
},
|
|
101
|
-
namespace: {
|
|
102
|
-
type: 'string',
|
|
103
|
-
describe:
|
|
104
|
-
'The package namespace, if any. If this value is provided the namespace will be added as a prefix to all of the parsed files. ' +
|
|
105
|
-
"If generating an OpenApi definition, it will be added to the file's Server Url.",
|
|
106
|
-
},
|
|
107
|
-
openApiFileName: {
|
|
108
|
-
type: 'string',
|
|
109
|
-
describe: 'If using "openapi" as the target generator, this allows you to specify the name of the output file.',
|
|
110
|
-
default: 'openapi',
|
|
111
|
-
},
|
|
112
|
-
sortMembersAlphabetically: {
|
|
113
|
-
type: 'boolean',
|
|
114
|
-
describe: 'Whether to sort members alphabetically.',
|
|
115
|
-
default: false,
|
|
116
|
-
},
|
|
117
|
-
includeMetadata: {
|
|
118
|
-
type: 'boolean',
|
|
119
|
-
describe: "Whether to include the file's meta.xml information: Whether it is active and and the API version",
|
|
120
|
-
default: false,
|
|
121
|
-
},
|
|
122
|
-
documentationRootDir: {
|
|
123
|
-
type: 'string',
|
|
124
|
-
describe:
|
|
125
|
-
'Allows you to specify the root documentation directory where the files are being generated. This can be helpful when embedding the generated docs into an existing site so that the links are generated correctly.',
|
|
126
|
-
},
|
|
127
|
-
})
|
|
26
|
+
.command('markdown', 'Generate documentation from Apex classes as a Markdown site.', (yargs) =>
|
|
27
|
+
yargs.options(markdownOptions),
|
|
28
|
+
)
|
|
29
|
+
.command('openapi', 'Generate an OpenApi REST specification from Apex classes.')
|
|
30
|
+
.demandCommand()
|
|
128
31
|
.parseSync();
|
|
129
32
|
}
|
|
130
33
|
|
|
131
34
|
/**
|
|
132
35
|
* Combines the extracted configuration and arguments.
|
|
133
36
|
*/
|
|
134
|
-
export async function extractArgs(): Promise<
|
|
37
|
+
export async function extractArgs(): Promise<UserDefinedMarkdownConfig> {
|
|
135
38
|
const config = await _extractConfig();
|
|
136
39
|
const cliArgs = _extractYargs(config);
|
|
137
|
-
|
|
40
|
+
const commandName = cliArgs._[0];
|
|
41
|
+
|
|
42
|
+
return { ...config?.config, ...cliArgs, targetGenerator: commandName as 'markdown' | 'openapi' };
|
|
138
43
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Options } from 'yargs';
|
|
2
|
+
import { defaults } from '../../defaults';
|
|
3
|
+
|
|
4
|
+
export const markdownOptions: { [key: string]: Options } = {
|
|
5
|
+
sourceDir: {
|
|
6
|
+
type: 'string',
|
|
7
|
+
alias: 's',
|
|
8
|
+
demandOption: true,
|
|
9
|
+
describe: 'The directory location which contains your apex .cls classes.',
|
|
10
|
+
},
|
|
11
|
+
targetDir: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
alias: 't',
|
|
14
|
+
default: defaults.targetDir,
|
|
15
|
+
describe: 'The directory location where documentation will be generated to.',
|
|
16
|
+
},
|
|
17
|
+
scope: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
array: true,
|
|
20
|
+
alias: 'p',
|
|
21
|
+
default: defaults.scope,
|
|
22
|
+
describe:
|
|
23
|
+
'A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. ' +
|
|
24
|
+
'Annotations are supported and should be passed lowercased and without the @ symbol, e.g. namespaceaccessible auraenabled. ' +
|
|
25
|
+
'Note that this setting is ignored if generating an OpenApi REST specification since that looks for classes annotated with @RestResource.',
|
|
26
|
+
},
|
|
27
|
+
defaultGroupName: {
|
|
28
|
+
type: 'string',
|
|
29
|
+
default: defaults.defaultGroupName,
|
|
30
|
+
describe: 'Defines the @group name to be used when a file does not specify it.',
|
|
31
|
+
},
|
|
32
|
+
openApiTitle: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
default: 'Apex REST Api',
|
|
35
|
+
describe: 'If using "openapi" as the target generator, this allows you to specify the OpenApi title value.',
|
|
36
|
+
},
|
|
37
|
+
namespace: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
describe:
|
|
40
|
+
'The package namespace, if any. If this value is provided the namespace will be added as a prefix to all of the parsed files. ' +
|
|
41
|
+
"If generating an OpenApi definition, it will be added to the file's Server Url.",
|
|
42
|
+
},
|
|
43
|
+
openApiFileName: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
describe: 'If using "openapi" as the target generator, this allows you to specify the name of the output file.',
|
|
46
|
+
default: 'openapi',
|
|
47
|
+
},
|
|
48
|
+
sortMembersAlphabetically: {
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
describe: 'Whether to sort members alphabetically.',
|
|
51
|
+
default: defaults.sortMembersAlphabetically,
|
|
52
|
+
},
|
|
53
|
+
includeMetadata: {
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
describe: "Whether to include the file's meta.xml information: Whether it is active and and the API version",
|
|
56
|
+
default: defaults.includeMetadata,
|
|
57
|
+
},
|
|
58
|
+
};
|
package/src/cli/generate.ts
CHANGED
|
@@ -3,12 +3,14 @@ import { Apexdocs } from '../application/Apexdocs';
|
|
|
3
3
|
import { extractArgs } from './args';
|
|
4
4
|
|
|
5
5
|
function main() {
|
|
6
|
+
function cathError(error: Error) {
|
|
7
|
+
console.error(error);
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
extractArgs()
|
|
7
|
-
.then((config) => Apexdocs.generate(config))
|
|
8
|
-
.catch(
|
|
9
|
-
console.error(error);
|
|
10
|
-
process.exit(1);
|
|
11
|
-
});
|
|
12
|
+
.then((config) => Apexdocs.generate(config).catch(cathError))
|
|
13
|
+
.catch(cathError);
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
main();
|
package/src/core/manifest.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Annotation,
|
|
2
3
|
ClassMirror,
|
|
4
|
+
DocComment,
|
|
5
|
+
DocCommentAnnotation,
|
|
3
6
|
EnumMirror,
|
|
4
7
|
InterfaceMirror,
|
|
5
8
|
Type,
|
|
6
|
-
Annotation,
|
|
7
|
-
DocComment,
|
|
8
|
-
DocCommentAnnotation,
|
|
9
9
|
} from '@cparra/apex-reflection';
|
|
10
10
|
|
|
11
11
|
type AccessAndDocAware = { access_modifier: string; annotations: Annotation[]; docComment?: DocComment };
|
|
@@ -19,66 +19,72 @@ export default class Manifest {
|
|
|
19
19
|
* @param types List of types to be wrapped by this object.
|
|
20
20
|
* @param isForInnerTypes Whether this manifest represent an inner type or not.
|
|
21
21
|
*/
|
|
22
|
-
constructor(
|
|
22
|
+
constructor(
|
|
23
|
+
public types: Type[],
|
|
24
|
+
public isForInnerTypes: boolean = false,
|
|
25
|
+
) {}
|
|
23
26
|
|
|
24
27
|
filteredByAccessModifierAndAnnotations(modifiers: string[]): Type[] {
|
|
25
|
-
const filteredTypes =
|
|
28
|
+
const filteredTypes = Manifest.filterAccessibleModifier(this.types, modifiers);
|
|
26
29
|
const typesToReturn: Type[] = [];
|
|
27
30
|
for (const filteredType of filteredTypes) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
31
|
+
typesToReturn.push(Manifest.filterSingleType(filteredType, modifiers, this.isForInnerTypes));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return typesToReturn;
|
|
35
|
+
}
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
} as InterfaceMirror);
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
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
|
+
}
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
if (currentType.type_name === 'interface') {
|
|
44
|
+
const currentInterface = currentType as InterfaceMirror;
|
|
45
|
+
return {
|
|
46
46
|
...currentType,
|
|
47
|
-
methods: this.filterAccessibleModifier(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
constructors: this.filterAccessibleModifier(currentClass.constructors, modifiers),
|
|
51
|
-
} as ClassMirror;
|
|
47
|
+
methods: this.filterAccessibleModifier(currentInterface.methods, modifiers),
|
|
48
|
+
} as InterfaceMirror;
|
|
49
|
+
}
|
|
52
50
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
}
|
|
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;
|
|
63
59
|
|
|
64
|
-
|
|
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
|
+
};
|
|
65
69
|
}
|
|
66
70
|
|
|
67
|
-
return
|
|
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));
|
|
68
76
|
}
|
|
69
77
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
);
|
|
82
|
-
});
|
|
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
|
+
);
|
|
83
89
|
}
|
|
84
90
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as E from 'fp-ts/Either';
|
|
2
|
-
import { DocumentationBundle } from '../../
|
|
2
|
+
import { DocumentationBundle } from '../../shared/types';
|
|
3
3
|
|
|
4
4
|
export function extendExpect() {
|
|
5
5
|
expect.extend({
|
|
@@ -11,14 +11,14 @@ export function extendExpect() {
|
|
|
11
11
|
},
|
|
12
12
|
firstDocContains(doc: DocumentationBundle, content: string) {
|
|
13
13
|
return {
|
|
14
|
-
pass: doc.docs[0].
|
|
15
|
-
message: () => `Expected documentation to contain ${content}. Got ${doc.docs[0].
|
|
14
|
+
pass: doc.docs[0].content.includes(content),
|
|
15
|
+
message: () => `Expected documentation to contain ${content}. Got ${doc.docs[0].content}`,
|
|
16
16
|
};
|
|
17
17
|
},
|
|
18
18
|
firstDocContainsNot(doc: DocumentationBundle, content: string) {
|
|
19
19
|
return {
|
|
20
|
-
pass: !doc.docs[0].
|
|
21
|
-
message: () => `Expected documentation to not contain ${content}. Got ${doc.docs[0].
|
|
20
|
+
pass: !doc.docs[0].content.includes(content),
|
|
21
|
+
message: () => `Expected documentation to not contain ${content}. Got ${doc.docs[0].content}`,
|
|
22
22
|
};
|
|
23
23
|
},
|
|
24
24
|
});
|