@cparra/apexdocs 1.13.4 → 2.0.0-alpha.14
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/.eslintrc.js +12 -0
- package/.prettierrc.js +7 -0
- package/README.md +344 -277
- package/ROADMAP.md +18 -0
- package/docs/Gemfile.lock +1 -1
- package/docs/Sample-Classes/SampleClass.md +138 -30
- package/docs/Sample-Interfaces/SampleInterface.md +21 -4
- package/docs/index.md +1 -9
- package/examples/apex/SampleClass.cls +31 -6
- package/examples/apex/SampleInterface.cls +3 -2
- package/lib/application/Apexdocs.d.ts +11 -0
- package/lib/application/Apexdocs.js +41 -0
- package/lib/application/Apexdocs.js.map +1 -0
- package/lib/cli/generate.js +17 -21
- package/lib/cli/generate.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -0
- package/lib/model/file.d.ts +10 -0
- package/lib/model/file.js +23 -0
- package/lib/model/file.js.map +1 -0
- package/lib/model/manifest.d.ts +22 -0
- package/lib/model/manifest.js +41 -0
- package/lib/model/manifest.js.map +1 -0
- package/lib/model/markdown-file.d.ts +10 -0
- package/lib/model/markdown-file.js +52 -0
- package/lib/model/markdown-file.js.map +1 -0
- package/lib/model/markdown-generation-util/field-declaration-util.d.ts +3 -0
- package/lib/model/markdown-generation-util/field-declaration-util.js +33 -0
- package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -0
- package/lib/model/markdown-generation-util/index.d.ts +3 -0
- package/lib/model/markdown-generation-util/index.js +9 -0
- package/lib/model/markdown-generation-util/index.js.map +1 -0
- package/lib/model/markdown-generation-util/method-declaration-util.d.ts +3 -0
- package/lib/model/markdown-generation-util/method-declaration-util.js +97 -0
- package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -0
- package/lib/model/markdown-generation-util/type-declaration-util.d.ts +3 -0
- package/lib/model/markdown-generation-util/type-declaration-util.js +25 -0
- package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -0
- package/lib/model/markdown-home-file.d.ts +11 -0
- package/lib/model/markdown-home-file.js +50 -0
- package/lib/model/markdown-home-file.js.map +1 -0
- package/lib/model/markdown-type-file.d.ts +17 -0
- package/lib/model/markdown-type-file.js +62 -0
- package/lib/model/markdown-type-file.js.map +1 -0
- package/lib/service/apex-file-reader.d.ts +13 -0
- package/lib/service/apex-file-reader.js +39 -0
- package/lib/service/apex-file-reader.js.map +1 -0
- package/lib/service/file-system.d.ts +12 -0
- package/lib/service/file-system.js +21 -0
- package/lib/service/file-system.js.map +1 -0
- package/lib/service/file-writer.d.ts +4 -0
- package/lib/service/file-writer.js +25 -0
- package/lib/service/file-writer.js.map +1 -0
- package/lib/service/manifest-factory.d.ts +9 -0
- package/lib/service/manifest-factory.js +13 -0
- package/lib/service/manifest-factory.js.map +1 -0
- package/lib/service/parser.d.ts +9 -0
- package/lib/service/parser.js +17 -0
- package/lib/service/parser.js.map +1 -0
- package/lib/service/walkers/class-walker.d.ts +4 -0
- package/lib/service/walkers/class-walker.js +32 -0
- package/lib/service/walkers/class-walker.js.map +1 -0
- package/lib/service/walkers/enum-walker.d.ts +4 -0
- package/lib/service/walkers/enum-walker.js +10 -0
- package/lib/service/walkers/enum-walker.js.map +1 -0
- package/lib/service/walkers/interface-walker.d.ts +4 -0
- package/lib/service/walkers/interface-walker.js +14 -0
- package/lib/service/walkers/interface-walker.js.map +1 -0
- package/lib/service/walkers/walker-factory.d.ts +5 -0
- package/lib/service/walkers/walker-factory.js +19 -0
- package/lib/service/walkers/walker-factory.js.map +1 -0
- package/lib/service/walkers/walker.d.ts +16 -0
- package/lib/service/walkers/walker.js +9 -0
- package/lib/service/walkers/walker.js.map +1 -0
- package/lib/settings.d.ts +21 -0
- package/lib/settings.js +42 -0
- package/lib/settings.js.map +1 -0
- package/lib/transpiler/file-container.d.ts +6 -0
- package/lib/transpiler/file-container.js +15 -0
- package/lib/transpiler/file-container.js.map +1 -0
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +6 -0
- package/lib/transpiler/markdown/class-file-generatorHelper.js +17 -0
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -0
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +4 -0
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js +10 -0
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js.map +1 -0
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +8 -0
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +24 -0
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -0
- package/lib/transpiler/markdown/markdown-transpiler-base.d.ts +11 -0
- package/lib/transpiler/markdown/markdown-transpiler-base.js +23 -0
- package/lib/transpiler/markdown/markdown-transpiler-base.js.map +1 -0
- package/lib/transpiler/processor-type-transpiler.d.ts +8 -0
- package/lib/transpiler/processor-type-transpiler.js +6 -0
- package/lib/transpiler/processor-type-transpiler.js.map +1 -0
- package/lib/transpiler/transpiler.d.ts +5 -0
- package/lib/transpiler/transpiler.js +21 -0
- package/lib/transpiler/transpiler.js.map +1 -0
- package/lib/util/logger.d.ts +18 -0
- package/lib/util/logger.js +32 -0
- package/lib/util/logger.js.map +1 -0
- package/package.json +22 -11
- package/src/application/Apexdocs.ts +41 -0
- package/src/cli/generate.ts +52 -64
- package/src/index.ts +1 -1
- package/src/model/__tests__/manifest.spec.ts +15 -0
- package/src/model/file.ts +23 -0
- package/src/model/manifest.ts +60 -0
- package/src/model/markdown-file.ts +56 -0
- package/src/model/markdown-generation-util/field-declaration-util.ts +42 -0
- package/src/model/markdown-generation-util/index.ts +3 -0
- package/src/model/markdown-generation-util/method-declaration-util.ts +128 -0
- package/src/model/markdown-generation-util/type-declaration-util.ts +29 -0
- package/src/model/markdown-home-file.ts +48 -0
- package/src/model/markdown-type-file.ts +75 -0
- package/src/service/__tests__/apex-file-reader.spec.ts +79 -0
- package/src/service/__tests__/manifest-factory.spec.ts +16 -0
- package/src/service/apex-file-reader.ts +45 -0
- package/src/service/file-system.ts +28 -0
- package/src/service/file-writer.ts +25 -0
- package/src/service/manifest-factory.ts +12 -0
- package/src/service/parser.ts +18 -0
- package/src/service/walkers/class-walker.ts +31 -0
- package/src/service/walkers/enum-walker.ts +8 -0
- package/src/service/walkers/interface-walker.ts +12 -0
- package/src/service/walkers/walker-factory.ts +18 -0
- package/src/service/walkers/walker.ts +35 -0
- package/src/settings.ts +57 -0
- package/src/transpiler/file-container.ts +13 -0
- package/src/transpiler/markdown/class-file-generatorHelper.ts +16 -0
- package/src/transpiler/markdown/docsify/docsify-docs-processor.ts +7 -0
- package/src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts +22 -0
- package/src/transpiler/markdown/markdown-transpiler-base.ts +28 -0
- package/src/transpiler/processor-type-transpiler.ts +12 -0
- package/src/transpiler/transpiler.ts +18 -0
- package/src/util/logger.ts +31 -0
- package/tsconfig.json +9 -3
- package/.prettierrc +0 -5
- package/examples/config/config.json +0 -5
- package/lib/AsJsDocsProcessor.d.ts +0 -9
- package/lib/AsJsDocsProcessor.js +0 -61
- package/lib/ClassFileGeneratorHelper.d.ts +0 -5
- package/lib/ClassFileGeneratorHelper.js +0 -25
- package/lib/ClassFileGeneratorHelper.test.d.ts +0 -1
- package/lib/ClassFileGeneratorHelper.test.js +0 -32
- package/lib/Configuration.d.ts +0 -34
- package/lib/Configuration.js +0 -37
- package/lib/DocsProcessor.d.ts +0 -6
- package/lib/DocsProcessor.js +0 -9
- package/lib/DocsifyDocsProcessor.d.ts +0 -4
- package/lib/DocsifyDocsProcessor.js +0 -9
- package/lib/DocsifyDocsProcessor.test.d.ts +0 -1
- package/lib/DocsifyDocsProcessor.test.js +0 -7
- package/lib/FileManager.d.ts +0 -6
- package/lib/FileManager.js +0 -28
- package/lib/JekyllDocsProcessor.d.ts +0 -8
- package/lib/JekyllDocsProcessor.js +0 -20
- package/lib/JekyllDocsProcessor.test.d.ts +0 -1
- package/lib/JekyllDocsProcessor.test.js +0 -21
- package/lib/JsHelper.d.ts +0 -12
- package/lib/JsHelper.js +0 -72
- package/lib/MarkdownDocsProcessor.d.ts +0 -22
- package/lib/MarkdownDocsProcessor.js +0 -358
- package/lib/MarkdownHelper.d.ts +0 -13
- package/lib/MarkdownHelper.js +0 -78
- package/lib/Settings.d.ts +0 -22
- package/lib/Settings.js +0 -51
- package/lib/Settings.test.d.ts +0 -1
- package/lib/Settings.test.js +0 -38
- package/lib/command/Generate.d.ts +0 -2
- package/lib/command/Generate.js +0 -54
- package/lib/command/__test__/Generte.test.d.ts +0 -1
- package/lib/command/__test__/Generte.test.js +0 -30
- package/lib/model/ApexModel.d.ts +0 -30
- package/lib/model/ApexModel.js +0 -85
- package/lib/model/ClassModel.d.ts +0 -39
- package/lib/model/ClassModel.js +0 -125
- package/lib/model/EnumModel.d.ts +0 -6
- package/lib/model/EnumModel.js +0 -28
- package/lib/model/MethodModel.d.ts +0 -18
- package/lib/model/MethodModel.js +0 -74
- package/lib/model/PropertyModel.d.ts +0 -6
- package/lib/model/PropertyModel.js +0 -40
- package/lib/model/__test__/ClassModel.test.d.ts +0 -1
- package/lib/model/__test__/ClassModel.test.js +0 -79
- package/lib/model/__test__/MethodModel.test.d.ts +0 -1
- package/lib/model/__test__/MethodModel.test.js +0 -55
- package/lib/model/__test__/PropertyModel.test.d.ts +0 -1
- package/lib/model/__test__/PropertyModel.test.js +0 -25
- package/lib/parser/ClassParser.d.ts +0 -5
- package/lib/parser/ClassParser.js +0 -79
- package/lib/parser/EnumParser.d.ts +0 -5
- package/lib/parser/EnumParser.js +0 -45
- package/lib/parser/FileParser.d.ts +0 -8
- package/lib/parser/FileParser.js +0 -210
- package/lib/parser/MethodParser.d.ts +0 -5
- package/lib/parser/MethodParser.js +0 -109
- package/lib/parser/PropertyParser.d.ts +0 -5
- package/lib/parser/PropertyParser.js +0 -46
- package/lib/parser/__test__/ClassParser.test.d.ts +0 -1
- package/lib/parser/__test__/ClassParser.test.js +0 -52
- package/lib/parser/__test__/FileParser.test.d.ts +0 -1
- package/lib/parser/__test__/FileParser.test.js +0 -12
- package/lib/parser/__test__/MethodParser.test.d.ts +0 -1
- package/lib/parser/__test__/MethodParser.test.js +0 -69
- package/lib/parser/__test__/PropertyParser.test.d.ts +0 -1
- package/lib/parser/__test__/PropertyParser.test.js +0 -14
- package/lib/parser/__test__/testFileContents.d.ts +0 -1
- package/lib/parser/__test__/testFileContents.js +0 -82
- package/lib/utils.d.ts +0 -12
- package/lib/utils.js +0 -49
- package/lib/utils.test.d.ts +0 -1
- package/lib/utils.test.js +0 -35
- package/src/AsJsDocsProcessor.ts +0 -67
- package/src/ClassFileGeneratorHelper.test.ts +0 -44
- package/src/ClassFileGeneratorHelper.ts +0 -26
- package/src/Configuration.ts +0 -69
- package/src/DocsProcessor.ts +0 -9
- package/src/DocsifyDocsProcessor.test.ts +0 -6
- package/src/DocsifyDocsProcessor.ts +0 -7
- package/src/FileManager.ts +0 -32
- package/src/JekyllDocsProcessor.test.ts +0 -28
- package/src/JekyllDocsProcessor.ts +0 -22
- package/src/JsHelper.ts +0 -78
- package/src/MarkdownDocsProcessor.ts +0 -420
- package/src/MarkdownHelper.ts +0 -91
- package/src/Settings.test.ts +0 -54
- package/src/Settings.ts +0 -65
- package/src/command/Generate.ts +0 -69
- package/src/command/__test__/Generte.test.ts +0 -39
- package/src/model/ApexModel.ts +0 -102
- package/src/model/ClassModel.ts +0 -140
- package/src/model/EnumModel.ts +0 -27
- package/src/model/MethodModel.ts +0 -80
- package/src/model/PropertyModel.ts +0 -37
- package/src/model/__test__/ClassModel.test.ts +0 -100
- package/src/model/__test__/MethodModel.test.ts +0 -70
- package/src/model/__test__/PropertyModel.test.ts +0 -34
- package/src/parser/ClassParser.ts +0 -83
- package/src/parser/EnumParser.ts +0 -47
- package/src/parser/FileParser.ts +0 -250
- package/src/parser/MethodParser.ts +0 -119
- package/src/parser/PropertyParser.ts +0 -46
- package/src/parser/__test__/ClassParser.test.ts +0 -70
- package/src/parser/__test__/FileParser.test.ts +0 -14
- package/src/parser/__test__/MethodParser.test.ts +0 -90
- package/src/parser/__test__/PropertyParser.test.ts +0 -18
- package/src/parser/__test__/testFileContents.ts +0 -81
- package/src/utils.test.ts +0 -40
- package/src/utils.ts +0 -52
package/src/cli/generate.ts
CHANGED
|
@@ -1,64 +1,52 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import * as yargs from 'yargs';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const argv = yargs.options({
|
|
8
|
-
sourceDir: {
|
|
9
|
-
type: 'string',
|
|
10
|
-
alias: 's',
|
|
11
|
-
demandOption: true,
|
|
12
|
-
describe: 'The directory location which contains your apex .cls classes.',
|
|
13
|
-
},
|
|
14
|
-
targetDir: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
alias: 't',
|
|
17
|
-
default: 'docs',
|
|
18
|
-
describe: 'The directory location where documentation will be generated to.',
|
|
19
|
-
},
|
|
20
|
-
recursive: {
|
|
21
|
-
type: 'boolean',
|
|
22
|
-
alias: 'r',
|
|
23
|
-
default: true,
|
|
24
|
-
describe: 'Whether .cls classes will be searched for recursively in the directory provided.',
|
|
25
|
-
},
|
|
26
|
-
scope: {
|
|
27
|
-
type: 'array',
|
|
28
|
-
alias: 'p',
|
|
29
|
-
default: ['global'
|
|
30
|
-
describe:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}).argv;
|
|
54
|
-
|
|
55
|
-
const generatedClassModels = generate(
|
|
56
|
-
argv.sourceDir,
|
|
57
|
-
argv.recursive,
|
|
58
|
-
argv.scope,
|
|
59
|
-
argv.targetDir,
|
|
60
|
-
argv.targetGenerator,
|
|
61
|
-
argv.configPath,
|
|
62
|
-
argv.group,
|
|
63
|
-
);
|
|
64
|
-
new FileManager(generatedClassModels).generate();
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import * as yargs from 'yargs';
|
|
3
|
+
|
|
4
|
+
import { GeneratorChoices, Settings } from '../settings';
|
|
5
|
+
import { Apexdocs } from '../application/Apexdocs';
|
|
6
|
+
|
|
7
|
+
const argv = yargs.options({
|
|
8
|
+
sourceDir: {
|
|
9
|
+
type: 'string',
|
|
10
|
+
alias: 's',
|
|
11
|
+
demandOption: true,
|
|
12
|
+
describe: 'The directory location which contains your apex .cls classes.',
|
|
13
|
+
},
|
|
14
|
+
targetDir: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
alias: 't',
|
|
17
|
+
default: './docs/',
|
|
18
|
+
describe: 'The directory location where documentation will be generated to.',
|
|
19
|
+
},
|
|
20
|
+
recursive: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
alias: 'r',
|
|
23
|
+
default: true,
|
|
24
|
+
describe: 'Whether .cls classes will be searched for recursively in the directory provided.',
|
|
25
|
+
},
|
|
26
|
+
scope: {
|
|
27
|
+
type: 'array',
|
|
28
|
+
alias: 'p',
|
|
29
|
+
default: ['global'],
|
|
30
|
+
describe:
|
|
31
|
+
'A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. ' +
|
|
32
|
+
'Annotations are supported and should be passed lowercased and without the @ symbol, e.g. namespaceaccessible auraenabled',
|
|
33
|
+
},
|
|
34
|
+
targetGenerator: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
alias: 'g',
|
|
37
|
+
default: 'jekyll',
|
|
38
|
+
choices: ['jekyll', 'docsify'],
|
|
39
|
+
describe:
|
|
40
|
+
'Define the static file generator for which the documents will be created. Currently supports jekyll, and docsify.',
|
|
41
|
+
},
|
|
42
|
+
}).argv;
|
|
43
|
+
|
|
44
|
+
Settings.build({
|
|
45
|
+
sourceDirectory: argv.sourceDir,
|
|
46
|
+
recursive: argv.recursive,
|
|
47
|
+
scope: argv.scope,
|
|
48
|
+
outputDir: argv.targetDir,
|
|
49
|
+
targetGenerator: argv.targetGenerator as GeneratorChoices,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
Apexdocs.generate();
|
package/src/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './service/manifest-factory';
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
};
|
|
10
|
+
|
|
11
|
+
it('holds a list of types', () => {
|
|
12
|
+
const types = [sampleEnum];
|
|
13
|
+
const manifest = new Manifest(types);
|
|
14
|
+
expect(manifest.types).toBe(types);
|
|
15
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { encode } from 'html-entities';
|
|
2
|
+
|
|
3
|
+
export abstract class File {
|
|
4
|
+
_contents = '';
|
|
5
|
+
|
|
6
|
+
constructor(public fileName: string, public dir: string) {}
|
|
7
|
+
|
|
8
|
+
abstract fileExtension(): string;
|
|
9
|
+
|
|
10
|
+
get body() {
|
|
11
|
+
return this._contents;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
addText(text: string, encodeHtml = true) {
|
|
15
|
+
const textToAdd = encodeHtml ? encode(text) : text;
|
|
16
|
+
this._contents += textToAdd;
|
|
17
|
+
this.addBlankLine();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
addBlankLine() {
|
|
21
|
+
this._contents += '\n';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ClassMirror, EnumMirror, InterfaceMirror, Type } from '@cparra/apex-reflection';
|
|
2
|
+
import { Annotation } from '@cparra/apex-reflection/index';
|
|
3
|
+
|
|
4
|
+
type AccessAware = { access_modifier: string } & { annotations: Annotation[] };
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents the full library of Apex top-level types (classes, enums, and interface) for a Salesforce project.
|
|
8
|
+
*/
|
|
9
|
+
export default class Manifest {
|
|
10
|
+
/**
|
|
11
|
+
* Constructs a new Manifest object.
|
|
12
|
+
* @param types List of types to be wrapped by this object.
|
|
13
|
+
*/
|
|
14
|
+
constructor(public types: Type[], public isForInnerTypes: boolean = false) {}
|
|
15
|
+
|
|
16
|
+
filteredByAccessModifierAndAnnotations(modifiers: string[]): Type[] {
|
|
17
|
+
const filteredTypes = this.filterAccessibleModifier(this.types, modifiers);
|
|
18
|
+
const typesToReturn: Type[] = [];
|
|
19
|
+
for (const filteredType of filteredTypes) {
|
|
20
|
+
const currentType = filteredType as Type;
|
|
21
|
+
if (currentType.type_name !== 'class') {
|
|
22
|
+
typesToReturn.push(currentType);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const currentClass = currentType as ClassMirror;
|
|
27
|
+
let filteredClass = {
|
|
28
|
+
...currentType,
|
|
29
|
+
methods: this.filterAccessibleModifier(currentClass.methods, modifiers),
|
|
30
|
+
properties: this.filterAccessibleModifier(currentClass.properties, modifiers),
|
|
31
|
+
fields: this.filterAccessibleModifier(currentClass.fields, modifiers),
|
|
32
|
+
constructors: this.filterAccessibleModifier(currentClass.constructors, modifiers),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
if (!this.isForInnerTypes) {
|
|
36
|
+
filteredClass = {
|
|
37
|
+
...filteredClass,
|
|
38
|
+
enums: this.filterAccessibleModifier(currentClass.enums, modifiers) as EnumMirror[],
|
|
39
|
+
interfaces: this.filterAccessibleModifier(currentClass.interfaces, modifiers) as InterfaceMirror[],
|
|
40
|
+
classes: new Manifest(currentClass.classes, true).filteredByAccessModifierAndAnnotations(
|
|
41
|
+
modifiers,
|
|
42
|
+
) as ClassMirror[],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
typesToReturn.push(filteredClass);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return typesToReturn;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
filterAccessibleModifier(accessAware: AccessAware[], modifiers: string[]) {
|
|
53
|
+
return accessAware.filter((currentType) => {
|
|
54
|
+
return (
|
|
55
|
+
modifiers.includes(currentType.access_modifier) ||
|
|
56
|
+
currentType.annotations.some((annotation: Annotation) => modifiers.includes(annotation.type.toLowerCase()))
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { File } from './file';
|
|
2
|
+
|
|
3
|
+
export class MarkdownFile extends File {
|
|
4
|
+
fileExtension(): string {
|
|
5
|
+
return '.md';
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
addTitle(text: string, level = 1) {
|
|
9
|
+
let title = '';
|
|
10
|
+
for (let i = 0; i < level; i++) {
|
|
11
|
+
title += '#';
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
title += ' ';
|
|
15
|
+
title += text;
|
|
16
|
+
this._contents += title;
|
|
17
|
+
this.addBlankLine();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
startCodeBlock() {
|
|
21
|
+
this._contents += '```';
|
|
22
|
+
const sourceLanguage = 'apex';
|
|
23
|
+
this._contents += sourceLanguage;
|
|
24
|
+
this.addBlankLine();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
endCodeBlock() {
|
|
28
|
+
this._contents += '```';
|
|
29
|
+
this.addBlankLine();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
addHorizontalRule() {
|
|
33
|
+
this._contents += '---';
|
|
34
|
+
this.addBlankLine();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
initializeTable(...headers: string[]) {
|
|
38
|
+
this._contents += '|';
|
|
39
|
+
headers.forEach((header) => {
|
|
40
|
+
this._contents += header + '|';
|
|
41
|
+
});
|
|
42
|
+
this.addBlankLine();
|
|
43
|
+
this._contents += '|';
|
|
44
|
+
headers.forEach((_) => {
|
|
45
|
+
this._contents += '---' + '|';
|
|
46
|
+
});
|
|
47
|
+
this.addBlankLine();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
addTableRow(...columns: string[]) {
|
|
51
|
+
this._contents += '|';
|
|
52
|
+
columns.forEach((column) => {
|
|
53
|
+
this._contents += column + '|';
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { MarkdownFile } from '../markdown-file';
|
|
2
|
+
import { FieldMirror, PropertyMirror } from '@cparra/apex-reflection';
|
|
3
|
+
|
|
4
|
+
export function declareField(
|
|
5
|
+
title: string,
|
|
6
|
+
markdownFile: MarkdownFile,
|
|
7
|
+
fields: FieldMirror[] | PropertyMirror[],
|
|
8
|
+
startingHeadingLevel: number,
|
|
9
|
+
) {
|
|
10
|
+
markdownFile.addTitle(title, startingHeadingLevel + 1);
|
|
11
|
+
markdownFile.addBlankLine();
|
|
12
|
+
fields
|
|
13
|
+
.sort((propA, propB) => {
|
|
14
|
+
if (propA.name < propB.name) return -1;
|
|
15
|
+
if (propA.name > propB.name) return 1;
|
|
16
|
+
return 0;
|
|
17
|
+
})
|
|
18
|
+
.forEach((propertyModel) => {
|
|
19
|
+
addFieldSection(markdownFile, propertyModel, startingHeadingLevel);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
markdownFile.addHorizontalRule();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function addFieldSection(
|
|
26
|
+
markdownFile: MarkdownFile,
|
|
27
|
+
propertyModel: FieldMirror | PropertyMirror,
|
|
28
|
+
startingHeadingLevel: number,
|
|
29
|
+
) {
|
|
30
|
+
markdownFile.addTitle(`\`${propertyModel.name}\` → \`${propertyModel.type}\``, startingHeadingLevel + 2);
|
|
31
|
+
|
|
32
|
+
propertyModel.annotations.forEach((annotation) => {
|
|
33
|
+
markdownFile.addBlankLine();
|
|
34
|
+
markdownFile.addText(`\`${annotation.type.toUpperCase()}\``);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (propertyModel.docComment?.description) {
|
|
38
|
+
markdownFile.addBlankLine();
|
|
39
|
+
markdownFile.addText(propertyModel.docComment.description);
|
|
40
|
+
}
|
|
41
|
+
markdownFile.addBlankLine();
|
|
42
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ConstructorMirror, DocComment, MethodMirror } from '@cparra/apex-reflection';
|
|
2
|
+
import { MarkdownFile } from '../markdown-file';
|
|
3
|
+
import { ParameterMirror } from '@cparra/apex-reflection/index';
|
|
4
|
+
|
|
5
|
+
export function declareMethod(
|
|
6
|
+
title: string,
|
|
7
|
+
markdownFile: MarkdownFile,
|
|
8
|
+
methods: ConstructorMirror[] | MethodMirror[],
|
|
9
|
+
startingHeadingLevel: number,
|
|
10
|
+
className = '',
|
|
11
|
+
): void {
|
|
12
|
+
markdownFile.addTitle(title, startingHeadingLevel + 1);
|
|
13
|
+
methods.forEach((currentMethod) => {
|
|
14
|
+
const signatureName = isMethod(currentMethod) ? (currentMethod as MethodMirror).name : className;
|
|
15
|
+
markdownFile.addTitle(`\`${buildSignature(signatureName, currentMethod)}\``, startingHeadingLevel + 2);
|
|
16
|
+
currentMethod.annotations.forEach((annotation) => {
|
|
17
|
+
markdownFile.addBlankLine();
|
|
18
|
+
markdownFile.addText(`\`${annotation.type.toUpperCase()}\``);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
if (currentMethod.docComment?.description) {
|
|
22
|
+
markdownFile.addBlankLine();
|
|
23
|
+
markdownFile.addText(currentMethod.docComment.description);
|
|
24
|
+
markdownFile.addBlankLine();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (currentMethod.parameters.length) {
|
|
28
|
+
addParameters(markdownFile, currentMethod, startingHeadingLevel);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (isMethod(currentMethod)) {
|
|
32
|
+
addReturns(markdownFile, currentMethod as MethodMirror, startingHeadingLevel);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
addThrowsBlock(markdownFile, currentMethod, startingHeadingLevel);
|
|
36
|
+
|
|
37
|
+
if (currentMethod.docComment?.exampleAnnotation) {
|
|
38
|
+
addExample(markdownFile, currentMethod, startingHeadingLevel);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
markdownFile.addHorizontalRule();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type ParameterAware = {
|
|
46
|
+
parameters: ParameterMirror[];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type DocCommentAware = {
|
|
50
|
+
docComment?: DocComment;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function buildSignature(name: string, parameterAware: ParameterAware): string {
|
|
54
|
+
let signature = `${name}(`;
|
|
55
|
+
if (isMethod(parameterAware) && (parameterAware as MethodMirror).memberModifiers.length) {
|
|
56
|
+
signature = (parameterAware as MethodMirror).memberModifiers.join(' ') + ' ' + signature;
|
|
57
|
+
}
|
|
58
|
+
const signatureParameters = parameterAware.parameters.map((param) => {
|
|
59
|
+
signature += `${param.type} ${param.name}`;
|
|
60
|
+
});
|
|
61
|
+
signature += signatureParameters.join(', ');
|
|
62
|
+
return (signature += ')');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function addParameters(
|
|
66
|
+
markdownFile: MarkdownFile,
|
|
67
|
+
methodModel: MethodMirror | ConstructorMirror,
|
|
68
|
+
startingHeadingLevel: number,
|
|
69
|
+
) {
|
|
70
|
+
markdownFile.addTitle('Parameters', startingHeadingLevel + 3);
|
|
71
|
+
markdownFile.initializeTable('Param', 'Description');
|
|
72
|
+
|
|
73
|
+
methodModel.docComment?.paramAnnotations.forEach((paramAnnotation) => {
|
|
74
|
+
const paramName = paramAnnotation.paramName;
|
|
75
|
+
const paramDescription = paramAnnotation.bodyLines.join(' ');
|
|
76
|
+
markdownFile.addTableRow(`\`${paramName}\``, paramDescription);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
markdownFile.addBlankLine();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function addReturns(markdownFile: MarkdownFile, methodModel: MethodMirror, startingHeadingLevel: number) {
|
|
83
|
+
if (!methodModel.docComment?.returnAnnotation) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
markdownFile.addTitle('Return', startingHeadingLevel + 3);
|
|
88
|
+
markdownFile.addBlankLine();
|
|
89
|
+
markdownFile.addText('**Type**');
|
|
90
|
+
markdownFile.addBlankLine();
|
|
91
|
+
markdownFile.addText(methodModel.type);
|
|
92
|
+
markdownFile.addBlankLine();
|
|
93
|
+
markdownFile.addText('**Description**');
|
|
94
|
+
markdownFile.addBlankLine();
|
|
95
|
+
markdownFile.addText(methodModel.docComment?.returnAnnotation.bodyLines.join(' '));
|
|
96
|
+
markdownFile.addBlankLine();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function addThrowsBlock(markdownFile: MarkdownFile, docCommentAware: DocCommentAware, startingHeadingLevel: number) {
|
|
100
|
+
if (!docCommentAware.docComment?.throwsAnnotations.length) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
markdownFile.addTitle('Throws', startingHeadingLevel + 3);
|
|
104
|
+
markdownFile.initializeTable('Exception', 'Description');
|
|
105
|
+
|
|
106
|
+
docCommentAware.docComment?.throwsAnnotations.forEach((annotation) => {
|
|
107
|
+
const exceptionName = annotation.exceptionName;
|
|
108
|
+
const exceptionDescription = annotation.bodyLines.join(' ');
|
|
109
|
+
|
|
110
|
+
markdownFile.addTableRow(`\`${exceptionName}\``, exceptionDescription);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
markdownFile.addBlankLine();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function addExample(markdownFile: MarkdownFile, docCommentAware: DocCommentAware, startingHeadingLevel: number) {
|
|
117
|
+
markdownFile.addTitle('Example', startingHeadingLevel + 3);
|
|
118
|
+
markdownFile.startCodeBlock();
|
|
119
|
+
docCommentAware.docComment?.exampleAnnotation.bodyLines.forEach((line) => {
|
|
120
|
+
markdownFile.addText(line, false);
|
|
121
|
+
});
|
|
122
|
+
markdownFile.endCodeBlock();
|
|
123
|
+
markdownFile.addBlankLine();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function isMethod(method: MethodMirror | ConstructorMirror | ParameterAware): method is ConstructorMirror {
|
|
127
|
+
return (method as MethodMirror).type !== undefined;
|
|
128
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { MarkdownFile } from '../markdown-file';
|
|
2
|
+
import { Type } from '@cparra/apex-reflection';
|
|
3
|
+
|
|
4
|
+
export function declareType(markdownFile: MarkdownFile, typeMirror: Type, startingHeadingLevel: number): void {
|
|
5
|
+
markdownFile.addTitle(typeMirror.name, startingHeadingLevel);
|
|
6
|
+
|
|
7
|
+
typeMirror.annotations.forEach((currentAnnotation) => {
|
|
8
|
+
markdownFile.addBlankLine();
|
|
9
|
+
markdownFile.addText(`\`${currentAnnotation.type.toUpperCase()}\``);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
if (typeMirror.docComment?.description) {
|
|
13
|
+
markdownFile.addBlankLine();
|
|
14
|
+
markdownFile.addText(typeMirror.docComment.description);
|
|
15
|
+
markdownFile.addBlankLine();
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function capitalizeFirstLetter(text: string) {
|
|
19
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
typeMirror.docComment?.annotations
|
|
23
|
+
.filter((currentAnnotation) => currentAnnotation.name !== 'description')
|
|
24
|
+
.forEach((currentAnnotation) => {
|
|
25
|
+
markdownFile.addBlankLine();
|
|
26
|
+
markdownFile.addText(`**${capitalizeFirstLetter(currentAnnotation.name)}** ${currentAnnotation.body}`);
|
|
27
|
+
markdownFile.addBlankLine();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Type } from '@cparra/apex-reflection';
|
|
2
|
+
import ClassFileGeneratorHelper from '../transpiler/markdown/class-file-generatorHelper';
|
|
3
|
+
import { MarkdownFile } from './markdown-file';
|
|
4
|
+
|
|
5
|
+
export class MarkdownHomeFile extends MarkdownFile {
|
|
6
|
+
constructor(public fileName: string, public types: Type[], headerContent?: string) {
|
|
7
|
+
super(fileName, '');
|
|
8
|
+
if (headerContent) {
|
|
9
|
+
this.addText(headerContent);
|
|
10
|
+
}
|
|
11
|
+
this.addTitle('Classes');
|
|
12
|
+
this.addTypeEntries(types);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private addTypeEntries(types: Type[]) {
|
|
16
|
+
const groupedClasses: Map<string, Type[]> = this.group(types);
|
|
17
|
+
groupedClasses.forEach((value: Type[], key: string) => {
|
|
18
|
+
this.addTitle(key, 2);
|
|
19
|
+
value.forEach((typeMirror) => {
|
|
20
|
+
this.addTypeEntry(typeMirror);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private addTypeEntry(typeMirror: Type) {
|
|
26
|
+
this.addBlankLine();
|
|
27
|
+
this.addTitle(ClassFileGeneratorHelper.getFileLink(typeMirror), 2);
|
|
28
|
+
this.addBlankLine();
|
|
29
|
+
this.addBlankLine();
|
|
30
|
+
this.addText(typeMirror.docComment?.description ?? '');
|
|
31
|
+
this.addBlankLine();
|
|
32
|
+
this.addBlankLine();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private group(classes: Type[]): Map<string, Type[]> {
|
|
36
|
+
return classes.reduce((groups, currentClass) => {
|
|
37
|
+
const key = this.getClassGroup(currentClass);
|
|
38
|
+
const group: Type[] = groups.get(key) || [];
|
|
39
|
+
group.push(currentClass);
|
|
40
|
+
groups.set(key, group);
|
|
41
|
+
return groups;
|
|
42
|
+
}, new Map());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private getClassGroup(classModel: Type): string {
|
|
46
|
+
return classModel.docComment?.annotations.find((annotation) => annotation.name === 'group')?.body ?? '';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClassMirror,
|
|
3
|
+
ConstructorMirror,
|
|
4
|
+
EnumMirror,
|
|
5
|
+
FieldMirror,
|
|
6
|
+
InterfaceMirror,
|
|
7
|
+
MethodMirror,
|
|
8
|
+
PropertyMirror,
|
|
9
|
+
Type,
|
|
10
|
+
} from '@cparra/apex-reflection';
|
|
11
|
+
import { WalkerFactory } from '../service/walkers/walker-factory';
|
|
12
|
+
import { WalkerListener } from '../service/walkers/walker';
|
|
13
|
+
import { MarkdownFile } from './markdown-file';
|
|
14
|
+
import { declareType, declareMethod, declareField } from './markdown-generation-util';
|
|
15
|
+
import ClassFileGeneratorHelper from '../transpiler/markdown/class-file-generatorHelper';
|
|
16
|
+
|
|
17
|
+
export class MarkdownTypeFile extends MarkdownFile implements WalkerListener {
|
|
18
|
+
constructor(public type: Type, public startingHeadingLevel: number = 1, headerContent?: string) {
|
|
19
|
+
super(`${type.name}`, ClassFileGeneratorHelper.getSanitizedGroup(type));
|
|
20
|
+
if (headerContent) {
|
|
21
|
+
this.addText(headerContent);
|
|
22
|
+
}
|
|
23
|
+
const walker = WalkerFactory.get(type);
|
|
24
|
+
walker.walk(this);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public onTypeDeclaration(typeMirror: Type, headingLevel?: 1): void {
|
|
28
|
+
declareType(this, typeMirror, this.startingHeadingLevel);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public onConstructorDeclaration(className: string, constructors: ConstructorMirror[]): void {
|
|
32
|
+
declareMethod('Constructors', this, constructors, this.startingHeadingLevel, className);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public onFieldsDeclaration(fields: FieldMirror[]): void {
|
|
36
|
+
declareField('Fields', this, fields, this.startingHeadingLevel);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public onPropertiesDeclaration(properties: PropertyMirror[]): void {
|
|
40
|
+
declareField('Properties', this, properties, this.startingHeadingLevel);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public onMethodsDeclaration(methods: MethodMirror[]): void {
|
|
44
|
+
declareMethod('Methods', this, methods, this.startingHeadingLevel);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public onInnerEnumsDeclaration(enums: EnumMirror[]): void {
|
|
48
|
+
this.addInnerTypes('Enums', enums);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public onInnerClassesDeclaration(classes: ClassMirror[]): void {
|
|
52
|
+
this.addInnerTypes('Classes', classes);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public onInnerInterfacesDeclaration(interfaces: InterfaceMirror[]): void {
|
|
56
|
+
this.addInnerTypes('Interfaces', interfaces, false);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
private addInnerTypes(title: string, types: Type[], addSeparator = true) {
|
|
60
|
+
this.addTitle(title, this.startingHeadingLevel + 1);
|
|
61
|
+
types
|
|
62
|
+
.sort((typeA, typeB) => {
|
|
63
|
+
if (typeA.name < typeB.name) return -1;
|
|
64
|
+
if (typeA.name > typeB.name) return 1;
|
|
65
|
+
return 0;
|
|
66
|
+
})
|
|
67
|
+
.forEach((currentType) => {
|
|
68
|
+
const innerFile = new MarkdownTypeFile(currentType, this.startingHeadingLevel + 2);
|
|
69
|
+
this.addText(innerFile._contents);
|
|
70
|
+
});
|
|
71
|
+
if (addSeparator) {
|
|
72
|
+
this.addHorizontalRule();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|