@cparra/apexdocs 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -5
- 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,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vitepress-example",
|
|
3
|
-
"scripts": {
|
|
4
|
-
"docs:clean": "rimraf --glob 'docs/!(.vitepress|index-frontmatter.md|api-examples.md|markdown-examples.md)'",
|
|
5
|
-
"apexdocs:build": "npm run docs:clean && ts-node ../../src/cli/generate.ts markdown",
|
|
6
|
-
"docs:build": "vitepress build docs",
|
|
7
|
-
"docs:gen": "npm run docs:clean && npm run docs:build",
|
|
8
|
-
"docs:dev": "vitepress dev docs",
|
|
9
|
-
"docs:preview": "vitepress preview docs"
|
|
10
|
-
},
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"ts-node": "^10.9.2",
|
|
13
|
-
"vitepress": "^1.3.1"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"rimraf": "^5.0.7"
|
|
17
|
-
}
|
|
18
|
-
}
|
package/jest.config.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
preset: 'ts-jest',
|
|
3
|
-
testEnvironment: 'node',
|
|
4
|
-
modulePathIgnorePatterns: ['<rootDir>/dist/'],
|
|
5
|
-
moduleNameMapper: {
|
|
6
|
-
'^chalk$': '<rootDir>/__mocks__/chalk.js',
|
|
7
|
-
'^log-update$': '<rootDir>/__mocks__/log-update.js',
|
|
8
|
-
'#utils/(.*)$': '<rootDir>/src/util/$1',
|
|
9
|
-
},
|
|
10
|
-
};
|
package/jest.d.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import markdown from './generators/markdown';
|
|
2
|
-
import openApi from './generators/openapi';
|
|
3
|
-
|
|
4
|
-
import { ApexFileReader } from './apex-file-reader';
|
|
5
|
-
import { DefaultFileSystem } from './file-system';
|
|
6
|
-
import { Logger } from '#utils/logger';
|
|
7
|
-
import { UnparsedSourceFile, UserDefinedConfig, UserDefinedMarkdownConfig } from '../core/shared/types';
|
|
8
|
-
import { pipe } from 'fp-ts/function';
|
|
9
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
10
|
-
import * as E from 'fp-ts/Either';
|
|
11
|
-
import { ReflectionError } from '../core/markdown/reflection/reflect-source';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Application entry-point to generate documentation out of Apex source files.
|
|
15
|
-
*/
|
|
16
|
-
export class Apexdocs {
|
|
17
|
-
/**
|
|
18
|
-
* Generates documentation out of Apex source files.
|
|
19
|
-
*/
|
|
20
|
-
static async generate(config: UserDefinedConfig, logger: Logger): Promise<E.Either<unknown[], string>> {
|
|
21
|
-
logger.logSingle(`Generating ${config.targetGenerator} documentation...`);
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
const fileBodies = await ApexFileReader.processFiles(
|
|
25
|
-
new DefaultFileSystem(),
|
|
26
|
-
config.sourceDir,
|
|
27
|
-
config.targetGenerator === 'markdown' ? config.includeMetadata : false,
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
switch (config.targetGenerator) {
|
|
31
|
-
case 'markdown':
|
|
32
|
-
return await generateMarkdownDocumentation(fileBodies, config)();
|
|
33
|
-
case 'openapi':
|
|
34
|
-
await openApi(logger, fileBodies, config);
|
|
35
|
-
return E.right('✔️ Documentation generated successfully!');
|
|
36
|
-
}
|
|
37
|
-
} catch (error) {
|
|
38
|
-
return E.left([error]);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function generateMarkdownDocumentation(
|
|
44
|
-
fileBodies: UnparsedSourceFile[],
|
|
45
|
-
config: UserDefinedMarkdownConfig,
|
|
46
|
-
): TE.TaskEither<unknown[], string> {
|
|
47
|
-
return pipe(
|
|
48
|
-
markdown(fileBodies, config),
|
|
49
|
-
TE.map(() => '✔️ Documentation generated successfully!'),
|
|
50
|
-
TE.mapLeft((error) => {
|
|
51
|
-
if (error._tag === 'HookError') {
|
|
52
|
-
return ['Error(s) occurred while processing hooks. Please review the following issues:', error.error];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (error._tag === 'FileWritingError') {
|
|
56
|
-
return ['Error(s) occurred while writing files. Please review the following issues:', error.error];
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
return [
|
|
60
|
-
'Error(s) occurred while parsing files. Please review the following issues:',
|
|
61
|
-
...error.errors.map(formatReflectionError),
|
|
62
|
-
];
|
|
63
|
-
}),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function formatReflectionError(error: ReflectionError) {
|
|
68
|
-
return `Source file: ${error.file}\n${error.message}\n`;
|
|
69
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { ApexFileReader } from '../apex-file-reader';
|
|
2
|
-
import { FileSystem } from '../file-system';
|
|
3
|
-
|
|
4
|
-
type File = {
|
|
5
|
-
type: 'file';
|
|
6
|
-
path: string;
|
|
7
|
-
content: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
type Directory = {
|
|
11
|
-
type: 'directory';
|
|
12
|
-
path: string;
|
|
13
|
-
files: (File | Directory)[];
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
type Path = File | Directory;
|
|
17
|
-
|
|
18
|
-
class TestFileSystem implements FileSystem {
|
|
19
|
-
constructor(private readonly paths: Path[]) {}
|
|
20
|
-
|
|
21
|
-
async isDirectory(path: string): Promise<boolean> {
|
|
22
|
-
const directory = this.findPath(path);
|
|
23
|
-
return directory ? directory.type === 'directory' : false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
joinPath(...paths: string[]): string {
|
|
27
|
-
return paths.join('/');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
async readDirectory(sourceDirectory: string): Promise<string[]> {
|
|
31
|
-
const directory = this.findPath(sourceDirectory);
|
|
32
|
-
if (!directory || directory.type !== 'directory') {
|
|
33
|
-
throw new Error('Directory not found');
|
|
34
|
-
}
|
|
35
|
-
return directory.files.map((f) => f.path);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
async readFile(path: string): Promise<string> {
|
|
39
|
-
const file = this.findPath(path);
|
|
40
|
-
if (!file || file.type !== 'file') {
|
|
41
|
-
throw new Error('File not found');
|
|
42
|
-
}
|
|
43
|
-
return file.content;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exists(path: string): boolean {
|
|
47
|
-
return this.paths.some((p) => p.path === path);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
findPath(path: string): Path | undefined {
|
|
51
|
-
const splitPath = path.split('/');
|
|
52
|
-
let currentPath = this.paths.find((p) => p.path === splitPath[0]);
|
|
53
|
-
for (let i = 1; i < splitPath.length; i++) {
|
|
54
|
-
if (!currentPath || currentPath.type !== 'directory') {
|
|
55
|
-
return undefined;
|
|
56
|
-
}
|
|
57
|
-
currentPath = currentPath.files.find((f) => f.path === splitPath[i]);
|
|
58
|
-
}
|
|
59
|
-
return currentPath;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
describe('File Reader', () => {
|
|
64
|
-
it('returns an empty list when there are no files in the directory', async () => {
|
|
65
|
-
const fileSystem = new TestFileSystem([
|
|
66
|
-
{
|
|
67
|
-
type: 'directory',
|
|
68
|
-
path: '',
|
|
69
|
-
files: [],
|
|
70
|
-
},
|
|
71
|
-
]);
|
|
72
|
-
|
|
73
|
-
const result = await ApexFileReader.processFiles(fileSystem, '', false);
|
|
74
|
-
|
|
75
|
-
expect(result.length).toBe(0);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('returns an empty list when there are no Apex files in the directory', async () => {
|
|
79
|
-
const fileSystem = new TestFileSystem([
|
|
80
|
-
{
|
|
81
|
-
type: 'directory',
|
|
82
|
-
path: '',
|
|
83
|
-
files: [
|
|
84
|
-
{
|
|
85
|
-
type: 'file',
|
|
86
|
-
path: 'SomeFile.md',
|
|
87
|
-
content: '## Some Markdown',
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
-
},
|
|
91
|
-
]);
|
|
92
|
-
|
|
93
|
-
const result = await ApexFileReader.processFiles(fileSystem, '', false);
|
|
94
|
-
expect(result.length).toBe(0);
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('returns the file contents for all Apex files', async () => {
|
|
98
|
-
const fileSystem = new TestFileSystem([
|
|
99
|
-
{
|
|
100
|
-
type: 'directory',
|
|
101
|
-
path: '',
|
|
102
|
-
files: [
|
|
103
|
-
{
|
|
104
|
-
type: 'file',
|
|
105
|
-
path: 'SomeFile.cls',
|
|
106
|
-
content: 'public class MyClass{}',
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
type: 'directory',
|
|
110
|
-
path: 'subdir',
|
|
111
|
-
files: [
|
|
112
|
-
{
|
|
113
|
-
type: 'file',
|
|
114
|
-
path: 'AnotherFile.cls',
|
|
115
|
-
content: 'public class AnotherClass{}',
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
]);
|
|
122
|
-
|
|
123
|
-
const result = await ApexFileReader.processFiles(fileSystem, '', false);
|
|
124
|
-
expect(result.length).toBe(2);
|
|
125
|
-
expect(result[0].content).toBe('public class MyClass{}');
|
|
126
|
-
expect(result[1].content).toBe('public class AnotherClass{}');
|
|
127
|
-
});
|
|
128
|
-
});
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { FileSystem } from './file-system';
|
|
2
|
-
import { UnparsedSourceFile } from '../core/shared/types';
|
|
3
|
-
|
|
4
|
-
const APEX_FILE_EXTENSION = '.cls';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Reads from .cls files and returns their raw body.
|
|
8
|
-
*/
|
|
9
|
-
export class ApexFileReader {
|
|
10
|
-
/**
|
|
11
|
-
* Reads from .cls files and returns their raw body.
|
|
12
|
-
*/
|
|
13
|
-
static async processFiles(
|
|
14
|
-
fileSystem: FileSystem,
|
|
15
|
-
rootPath: string,
|
|
16
|
-
includeMetadata: boolean,
|
|
17
|
-
): Promise<UnparsedSourceFile[]> {
|
|
18
|
-
const filePaths = await this.getFilePaths(fileSystem, rootPath);
|
|
19
|
-
const apexFilePaths = filePaths.filter((filePath) => this.isApexFile(filePath));
|
|
20
|
-
const filePromises = apexFilePaths.map((filePath) => this.processFile(fileSystem, filePath, includeMetadata));
|
|
21
|
-
return Promise.all(filePromises);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private static async getFilePaths(fileSystem: FileSystem, rootPath: string): Promise<string[]> {
|
|
25
|
-
const directoryContents = await fileSystem.readDirectory(rootPath);
|
|
26
|
-
const paths: string[] = [];
|
|
27
|
-
for (const filePath of directoryContents) {
|
|
28
|
-
const currentPath = fileSystem.joinPath(rootPath, filePath);
|
|
29
|
-
if (await fileSystem.isDirectory(currentPath)) {
|
|
30
|
-
paths.push(...(await this.getFilePaths(fileSystem, currentPath)));
|
|
31
|
-
return paths;
|
|
32
|
-
}
|
|
33
|
-
paths.push(currentPath);
|
|
34
|
-
}
|
|
35
|
-
return paths;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
private static async processFile(
|
|
39
|
-
fileSystem: FileSystem,
|
|
40
|
-
filePath: string,
|
|
41
|
-
includeMetadata: boolean,
|
|
42
|
-
): Promise<UnparsedSourceFile> {
|
|
43
|
-
const rawTypeContent = await fileSystem.readFile(filePath);
|
|
44
|
-
const metadataPath = `${filePath}-meta.xml`;
|
|
45
|
-
let rawMetadataContent = null;
|
|
46
|
-
if (includeMetadata) {
|
|
47
|
-
rawMetadataContent = fileSystem.exists(metadataPath) ? await fileSystem.readFile(metadataPath) : null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return { filePath, content: rawTypeContent, metadataContent: rawMetadataContent };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private static isApexFile(currentFile: string): boolean {
|
|
54
|
-
return currentFile.endsWith(APEX_FILE_EXTENSION);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
|
|
4
|
-
export interface FileSystem {
|
|
5
|
-
isDirectory: (path: string) => Promise<boolean>;
|
|
6
|
-
readDirectory: (sourceDirectory: string) => Promise<string[]>;
|
|
7
|
-
readFile: (path: string) => Promise<string>;
|
|
8
|
-
joinPath: (...paths: string[]) => string;
|
|
9
|
-
exists: (path: string) => boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function stat(path: string): Promise<fs.Stats> {
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
fs.stat(path, (err, stats) => {
|
|
15
|
-
if (err) {
|
|
16
|
-
reject(err);
|
|
17
|
-
} else {
|
|
18
|
-
resolve(stats);
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function readdir(path: string): Promise<string[]> {
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
fs.readdir(path, (err, files) => {
|
|
27
|
-
if (err) {
|
|
28
|
-
reject(err);
|
|
29
|
-
} else {
|
|
30
|
-
resolve(files);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function readFile(path: string): Promise<string> {
|
|
37
|
-
return new Promise((resolve, reject) => {
|
|
38
|
-
fs.readFile(path, (err, data) => {
|
|
39
|
-
if (err) {
|
|
40
|
-
reject(err);
|
|
41
|
-
} else {
|
|
42
|
-
resolve(data.toString());
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export class DefaultFileSystem implements FileSystem {
|
|
49
|
-
async isDirectory(pathToRead: string): Promise<boolean> {
|
|
50
|
-
const stats = await stat(pathToRead);
|
|
51
|
-
return stats.isDirectory();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
readDirectory(sourceDirectory: string): Promise<string[]> {
|
|
55
|
-
return readdir(sourceDirectory);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
readFile(pathToRead: string): Promise<string> {
|
|
59
|
-
return readFile(pathToRead);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
joinPath(...paths: string[]): string {
|
|
63
|
-
return path.join(...paths);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
exists(path: string): boolean {
|
|
67
|
-
return fs.existsSync(path);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import * as TE from 'fp-ts/lib/TaskEither';
|
|
4
|
-
import { PageData } from '../core/shared/types';
|
|
5
|
-
import { pipe } from 'fp-ts/function';
|
|
6
|
-
|
|
7
|
-
const mkdir: (path: fs.PathLike, options: fs.MakeDirectoryOptions) => TE.TaskEither<NodeJS.ErrnoException, void> =
|
|
8
|
-
TE.taskify(fs.mkdir);
|
|
9
|
-
|
|
10
|
-
const writeFile: (
|
|
11
|
-
path: fs.PathOrFileDescriptor,
|
|
12
|
-
data: string,
|
|
13
|
-
options?: fs.WriteFileOptions,
|
|
14
|
-
) => TE.TaskEither<NodeJS.ErrnoException, void> = TE.taskify(fs.writeFile);
|
|
15
|
-
|
|
16
|
-
export function writeFiles(files: PageData[], outputDir: string, onWriteCallback?: (file: PageData) => void) {
|
|
17
|
-
return pipe(
|
|
18
|
-
files,
|
|
19
|
-
TE.traverseArray((file) => writeSingle(file, outputDir, onWriteCallback)),
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function writeSingle(file: PageData, outputDir: string, onWriteCallback?: (file: PageData) => void) {
|
|
24
|
-
const ensureDirectoryExists = ({ outputDocPath }: PageData) =>
|
|
25
|
-
mkdir(path.dirname(outputDocPath), { recursive: true });
|
|
26
|
-
|
|
27
|
-
const writeContents = (file: PageData) => writeFile(file.outputDocPath, file.content, 'utf8');
|
|
28
|
-
|
|
29
|
-
return pipe(
|
|
30
|
-
resolveTargetLocation(file, outputDir),
|
|
31
|
-
(file) => TE.right(file),
|
|
32
|
-
TE.tapIO(ensureDirectoryExists),
|
|
33
|
-
TE.flatMap(writeContents),
|
|
34
|
-
TE.map(() => onWriteCallback?.(file)),
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function resolveTargetLocation(file: PageData, outputDir: string): PageData {
|
|
39
|
-
return {
|
|
40
|
-
...file,
|
|
41
|
-
outputDocPath: path.join(outputDir, file.outputDocPath),
|
|
42
|
-
};
|
|
43
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { generateDocs } from '../../core/markdown/generate-docs';
|
|
2
|
-
import { pipe } from 'fp-ts/function';
|
|
3
|
-
import {
|
|
4
|
-
PageData,
|
|
5
|
-
PostHookDocumentationBundle,
|
|
6
|
-
UnparsedSourceFile,
|
|
7
|
-
UserDefinedMarkdownConfig,
|
|
8
|
-
} from '../../core/shared/types';
|
|
9
|
-
import { referenceGuideTemplate } from '../../core/markdown/templates/reference-guide';
|
|
10
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
11
|
-
import { isSkip } from '../../core/shared/utils';
|
|
12
|
-
import { writeFiles } from '../file-writer';
|
|
13
|
-
|
|
14
|
-
class FileWritingError {
|
|
15
|
-
readonly _tag = 'FileWritingError';
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
public message: string,
|
|
19
|
-
public error: unknown,
|
|
20
|
-
) {}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default function generate(bundles: UnparsedSourceFile[], config: UserDefinedMarkdownConfig) {
|
|
24
|
-
return pipe(
|
|
25
|
-
generateDocumentationBundle(bundles, config),
|
|
26
|
-
TE.flatMap((files) => writeFilesToSystem(files, config.targetDir)),
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function generateDocumentationBundle(bundles: UnparsedSourceFile[], config: UserDefinedMarkdownConfig) {
|
|
31
|
-
return generateDocs(bundles, {
|
|
32
|
-
...config,
|
|
33
|
-
referenceGuideTemplate: referenceGuideTemplate,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function writeFilesToSystem(files: PostHookDocumentationBundle, outputDir: string) {
|
|
38
|
-
return pipe(
|
|
39
|
-
[files.referenceGuide, ...files.docs].filter((file) => !isSkip(file)),
|
|
40
|
-
(files) => writeFiles(files as PageData[], outputDir),
|
|
41
|
-
TE.mapLeft((error) => {
|
|
42
|
-
return new FileWritingError('An error occurred while writing files to the system.', error);
|
|
43
|
-
}),
|
|
44
|
-
);
|
|
45
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { createManifest } from '../../core/openapi/manifest-factory';
|
|
2
|
-
import { RawBodyParser } from '../../core/openapi/parser';
|
|
3
|
-
import { TypesRepository } from '../../core/openapi/types-repository';
|
|
4
|
-
import Transpiler from '../../core/openapi/transpiler';
|
|
5
|
-
import { Logger } from '#utils/logger';
|
|
6
|
-
import ErrorLogger from '#utils/error-logger';
|
|
7
|
-
import { reflect, ReflectionResult } from '@cparra/apex-reflection';
|
|
8
|
-
import Manifest from '../../core/manifest';
|
|
9
|
-
import { PageData, UnparsedSourceFile, UserDefinedOpenApiConfig } from '../../core/shared/types';
|
|
10
|
-
import { OpenApiDocsProcessor } from '../../core/openapi/open-api-docs-processor';
|
|
11
|
-
import { writeFiles } from '../file-writer';
|
|
12
|
-
import { pipe } from 'fp-ts/function';
|
|
13
|
-
import * as TE from 'fp-ts/TaskEither';
|
|
14
|
-
import { OpenApiSettings } from '../../core/openApiSettings';
|
|
15
|
-
import { apply } from '#utils/fp';
|
|
16
|
-
|
|
17
|
-
export default async function openApi(
|
|
18
|
-
logger: Logger,
|
|
19
|
-
fileBodies: UnparsedSourceFile[],
|
|
20
|
-
config: UserDefinedOpenApiConfig,
|
|
21
|
-
) {
|
|
22
|
-
OpenApiSettings.build({
|
|
23
|
-
sourceDirectory: config.sourceDir,
|
|
24
|
-
outputDir: config.targetDir,
|
|
25
|
-
openApiFileName: config.fileName,
|
|
26
|
-
openApiTitle: config.title,
|
|
27
|
-
namespace: config.namespace,
|
|
28
|
-
version: config.apiVersion,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const manifest = createManifest(new RawBodyParser(logger, fileBodies), apply(reflectionWithLogger, logger));
|
|
32
|
-
TypesRepository.getInstance().populateAll(manifest.types);
|
|
33
|
-
const filteredTypes = filterByScopes(logger, manifest);
|
|
34
|
-
const processor = new OpenApiDocsProcessor(logger);
|
|
35
|
-
Transpiler.generate(filteredTypes, processor);
|
|
36
|
-
const generatedFiles = processor.fileBuilder().files();
|
|
37
|
-
|
|
38
|
-
await pipe(
|
|
39
|
-
writeFiles(generatedFiles, config.targetDir, (file: PageData) => {
|
|
40
|
-
logger.logSingle(`${file.outputDocPath} processed.`, 'green');
|
|
41
|
-
}),
|
|
42
|
-
TE.mapError((error) => logger.error(error)),
|
|
43
|
-
)();
|
|
44
|
-
|
|
45
|
-
// Logs any errors that the types might have in their doc comment's error field
|
|
46
|
-
ErrorLogger.logErrors(logger, filteredTypes);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function reflectionWithLogger(logger: Logger, apexBundle: UnparsedSourceFile): ReflectionResult {
|
|
50
|
-
const result = reflect(apexBundle.content);
|
|
51
|
-
if (result.error) {
|
|
52
|
-
logger.error(`${apexBundle.filePath} - Parsing error ${result.error?.message}`);
|
|
53
|
-
}
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function filterByScopes(logger: Logger, manifest: Manifest) {
|
|
58
|
-
// If we are dealing with an OpenApi generator, we ignore the passed in access modifiers, and instead
|
|
59
|
-
// we only keep classes annotated as @RestResource
|
|
60
|
-
const filteredTypes = manifest.filteredByAccessModifierAndAnnotations([
|
|
61
|
-
'restresource',
|
|
62
|
-
'httpdelete',
|
|
63
|
-
'httpget',
|
|
64
|
-
'httppatch',
|
|
65
|
-
'httppost',
|
|
66
|
-
'httpput',
|
|
67
|
-
]);
|
|
68
|
-
const filteredLogMessage = `Filtered ${
|
|
69
|
-
manifest.types.length - filteredTypes.length
|
|
70
|
-
} file(s), only keeping classes annotated as @RestResource.`;
|
|
71
|
-
|
|
72
|
-
logger.logSingle(filteredLogMessage, 'green');
|
|
73
|
-
logger.logSingle(`Creating documentation for ${filteredTypes.length} file(s)`, 'green');
|
|
74
|
-
return filteredTypes;
|
|
75
|
-
}
|
package/src/cli/args.ts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { cosmiconfig, CosmiconfigResult } from 'cosmiconfig';
|
|
2
|
-
import * as yargs from 'yargs';
|
|
3
|
-
import { UserDefinedConfig, UserDefinedMarkdownConfig } from '../core/shared/types';
|
|
4
|
-
import { TypeScriptLoader } from 'cosmiconfig-typescript-loader';
|
|
5
|
-
import { markdownOptions } from './commands/markdown';
|
|
6
|
-
import { openApiOptions } from './commands/openapi';
|
|
7
|
-
|
|
8
|
-
const configOnlyDefaults: Partial<UserDefinedMarkdownConfig> = {
|
|
9
|
-
excludeTags: [],
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Extracts configuration from a configuration file or the package.json
|
|
14
|
-
* through cosmiconfig.
|
|
15
|
-
*/
|
|
16
|
-
function _extractConfig(): Promise<CosmiconfigResult> {
|
|
17
|
-
return cosmiconfig('apexdocs', {
|
|
18
|
-
loaders: {
|
|
19
|
-
'.ts': TypeScriptLoader(),
|
|
20
|
-
},
|
|
21
|
-
}).search();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Extracts arguments from the command line.
|
|
26
|
-
* @param config The configuration object from the configuration file, if any.
|
|
27
|
-
*/
|
|
28
|
-
function _extractYargs(config?: CosmiconfigResult) {
|
|
29
|
-
return yargs
|
|
30
|
-
.config(config?.config)
|
|
31
|
-
.command('markdown', 'Generate documentation from Apex classes as a Markdown site.', (yargs) =>
|
|
32
|
-
yargs.options(markdownOptions),
|
|
33
|
-
)
|
|
34
|
-
.command('openapi', 'Generate an OpenApi REST specification from Apex classes.', () =>
|
|
35
|
-
yargs.options(openApiOptions),
|
|
36
|
-
)
|
|
37
|
-
.demandCommand()
|
|
38
|
-
.parseSync();
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Combines the extracted configuration and arguments.
|
|
43
|
-
*/
|
|
44
|
-
export async function extractArgs(): Promise<UserDefinedConfig> {
|
|
45
|
-
const config = await _extractConfig();
|
|
46
|
-
const cliArgs = _extractYargs(config);
|
|
47
|
-
const commandName = cliArgs._[0];
|
|
48
|
-
|
|
49
|
-
const mergedConfig = { ...config?.config, ...cliArgs, targetGenerator: commandName as 'markdown' | 'openapi' };
|
|
50
|
-
if (mergedConfig.targetGenerator === 'markdown') {
|
|
51
|
-
return { ...configOnlyDefaults, ...mergedConfig };
|
|
52
|
-
} else {
|
|
53
|
-
return mergedConfig;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Options } from 'yargs';
|
|
2
|
-
import { markdownDefaults } 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: markdownDefaults.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: markdownDefaults.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
|
-
},
|
|
26
|
-
defaultGroupName: {
|
|
27
|
-
type: 'string',
|
|
28
|
-
default: markdownDefaults.defaultGroupName,
|
|
29
|
-
describe: 'Defines the @group name to be used when a file does not specify it.',
|
|
30
|
-
},
|
|
31
|
-
namespace: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
describe: 'The package namespace, if any. If provided, it will be added to the generated files.',
|
|
34
|
-
},
|
|
35
|
-
sortAlphabetically: {
|
|
36
|
-
type: 'boolean',
|
|
37
|
-
describe: 'Whether to sort files and members alphabetically.',
|
|
38
|
-
default: markdownDefaults.sortAlphabetically,
|
|
39
|
-
},
|
|
40
|
-
includeMetadata: {
|
|
41
|
-
type: 'boolean',
|
|
42
|
-
describe: "Whether to include the file's meta.xml information: Whether it is active and and the API version",
|
|
43
|
-
default: markdownDefaults.includeMetadata,
|
|
44
|
-
},
|
|
45
|
-
linkingStrategy: {
|
|
46
|
-
type: 'string',
|
|
47
|
-
describe: 'The strategy to use when linking to other documentation pages.',
|
|
48
|
-
choices: ['relative', 'no-link', 'none'],
|
|
49
|
-
default: markdownDefaults.linkingStrategy,
|
|
50
|
-
},
|
|
51
|
-
referenceGuideTitle: {
|
|
52
|
-
type: 'string',
|
|
53
|
-
describe: 'The title of the reference guide.',
|
|
54
|
-
default: markdownDefaults.referenceGuideTitle,
|
|
55
|
-
},
|
|
56
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Options } from 'yargs';
|
|
2
|
-
import { markdownDefaults, openApiDefaults } from '../../defaults';
|
|
3
|
-
|
|
4
|
-
export const openApiOptions: { [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: markdownDefaults.targetDir,
|
|
15
|
-
describe: 'The directory location where the OpenApi file will be generated.',
|
|
16
|
-
},
|
|
17
|
-
fileName: {
|
|
18
|
-
type: 'string',
|
|
19
|
-
default: openApiDefaults.fileName,
|
|
20
|
-
describe: 'The name of the OpenApi file to be generated.',
|
|
21
|
-
},
|
|
22
|
-
namespace: {
|
|
23
|
-
type: 'string',
|
|
24
|
-
describe: 'The package namespace, if any. This will be added to the API file Server Url.',
|
|
25
|
-
},
|
|
26
|
-
title: {
|
|
27
|
-
type: 'string',
|
|
28
|
-
default: openApiDefaults.title,
|
|
29
|
-
describe: 'The title of the OpenApi file.',
|
|
30
|
-
},
|
|
31
|
-
apiVersion: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
default: openApiDefaults.apiVersion,
|
|
34
|
-
describe: 'The version of the OpenApi file.',
|
|
35
|
-
},
|
|
36
|
-
};
|