@cparra/apexdocs 1.13.8 → 1.16.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/.gitattributes +2 -0
- package/.github/workflows/ci.yml +29 -0
- package/README.md +57 -35
- package/docs/.nojekyll +0 -0
- package/docs/404.html +24 -24
- package/docs/README.md +49 -9
- package/docs/Sample-Classes/SampleClass.md +2 -5
- package/docs/Sample-Classes/SampleClass2.md +2 -5
- package/docs/Sample-Classes/SampleClassMultipleAuthorsAndDates.md +120 -0
- package/docs/Sample-Interfaces/SampleInterface.md +1 -4
- package/docs/_config.yml +40 -40
- package/docs/assets/css/style.css +319 -319
- package/docs/index.html +21 -0
- package/docs/index.md +21 -0
- package/docs/single-file/Sample-Classes/SampleClass.md +115 -115
- package/examples/apex/SampleClassMultipleAuthorsAndDates.cls +100 -0
- package/examples/config/config.json +4 -0
- package/examples/dir1/SampleClass.cls +96 -0
- package/examples/dir2/SampleInterface.cls +17 -0
- package/lib/Command/Generate.d.ts +1 -1
- package/lib/Command/Generate.js +34 -19
- package/lib/Command/__test__/Generte.test.js +3 -3
- package/lib/MarkdownDocsProcessor.js +13 -6
- package/lib/MetadataProcessor.d.ts +3 -0
- package/lib/MetadataProcessor.js +15 -0
- package/lib/Parser/ClassParser.js +30 -19
- package/lib/Parser/MethodParser.js +2 -2
- package/lib/Parser/__test__/ClassParser.test.js +8 -2
- package/lib/Parser/__test__/MethodParser.test.js +3 -2
- package/lib/application/Apexdocs.js +6 -3
- package/lib/application/Apexdocs.js.map +1 -1
- package/lib/cli/generate.js +8 -3
- package/lib/index.js.map +1 -1
- package/lib/model/ApexModel.d.ts +9 -6
- package/lib/model/ApexModel.js +18 -10
- package/lib/model/file.js +1 -0
- package/lib/model/file.js.map +1 -1
- package/lib/model/manifest-diff.d.ts +24 -2
- package/lib/model/manifest-diff.js +61 -2
- package/lib/model/manifest-diff.js.map +1 -1
- package/lib/model/markdown-file.d.ts +2 -0
- package/lib/model/markdown-file.js +29 -0
- package/lib/model/markdown-file.js.map +1 -1
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.d.ts +7 -0
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +24 -0
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -0
- package/lib/model/markdown-generation-util/field-declaration-util.d.ts +1 -1
- package/lib/model/markdown-generation-util/field-declaration-util.js +34 -12
- package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/index.js +13 -6
- package/lib/model/markdown-generation-util/index.js.map +1 -1
- package/lib/model/markdown-generation-util/method-declaration-util.d.ts +1 -1
- package/lib/model/markdown-generation-util/method-declaration-util.js +5 -5
- package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/type-declaration-util.d.ts +1 -1
- package/lib/model/markdown-generation-util/type-declaration-util.js +5 -11
- package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -1
- package/lib/model/markdown-home-file.d.ts +1 -0
- package/lib/model/markdown-home-file.js +7 -5
- package/lib/model/markdown-home-file.js.map +1 -1
- package/lib/model/markdown-type-file.d.ts +10 -3
- package/lib/model/markdown-type-file.js +70 -10
- package/lib/model/markdown-type-file.js.map +1 -1
- package/lib/model/types-repository.d.ts +8 -0
- package/lib/model/types-repository.js +22 -0
- package/lib/model/types-repository.js.map +1 -0
- package/lib/service/apex-file-reader.d.ts +1 -1
- package/lib/service/apex-file-reader.js +5 -4
- package/lib/service/apex-file-reader.js.map +1 -1
- package/lib/service/file-system.js +1 -0
- package/lib/service/file-system.js.map +1 -1
- package/lib/service/file-writer.js +1 -0
- package/lib/service/file-writer.js.map +1 -1
- package/lib/service/manifest-factory.js +1 -0
- package/lib/service/manifest-factory.js.map +1 -1
- package/lib/service/parser.js +1 -0
- package/lib/service/parser.js.map +1 -1
- package/lib/service/walkers/class-walker.js +1 -0
- package/lib/service/walkers/class-walker.js.map +1 -1
- package/lib/service/walkers/enum-walker.js +1 -0
- package/lib/service/walkers/enum-walker.js.map +1 -1
- package/lib/service/walkers/interface-walker.js +1 -0
- package/lib/service/walkers/interface-walker.js.map +1 -1
- package/lib/service/walkers/walker-factory.js +1 -0
- package/lib/service/walkers/walker-factory.js.map +1 -1
- package/lib/service/walkers/walker.js +1 -0
- package/lib/service/walkers/walker.js.map +1 -1
- package/lib/settings.d.ts +3 -0
- package/lib/settings.js +7 -0
- package/lib/settings.js.map +1 -1
- package/lib/transpiler/file-container.js +1 -0
- package/lib/transpiler/file-container.js.map +1 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +1 -0
- package/lib/transpiler/markdown/class-file-generatorHelper.js +9 -0
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +1 -0
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/markdown-transpiler-base.js +1 -0
- package/lib/transpiler/markdown/markdown-transpiler-base.js.map +1 -1
- package/lib/util/logger.js +1 -0
- package/lib/util/logger.js.map +1 -1
- package/package.json +6 -2
- package/src/Command/Generate.ts +40 -19
- package/src/Command/__test__/Generte.test.ts +3 -3
- package/src/MarkdownDocsProcessor.ts +15 -6
- package/src/MetadataProcessor.ts +16 -0
- package/src/Model/ApexModel.ts +21 -10
- package/src/Parser/ClassParser.ts +37 -19
- package/src/Parser/MethodParser.ts +2 -2
- package/src/Parser/__test__/ClassParser.test.ts +8 -2
- package/src/Parser/__test__/MethodParser.test.ts +3 -2
- package/src/Settings.ts +10 -0
- package/src/cli/generate.ts +9 -2
package/lib/settings.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AACA,4FAAwF;AACxF,iGAAwF;AAYxF,MAAa,QAAQ;IAGnB,YAA2B,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;IAAG,CAAC;IAE9C,MAAM,CAAC,KAAK,CAAC,MAAsB;QACxC,QAAQ,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAEM,MAAM,CAAC,WAAW;QACvB,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;SACtD;QACD,OAAO,QAAQ,CAAC,QAAQ,CAAC;IAC3B,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC;IACrC,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;IAC3B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;IAC/B,CAAC;IAED,IAAI,cAAc;QAChB,QAAQ,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE;YACnC,KAAK,QAAQ;gBACX,OAAO,IAAI,0CAAmB,EAAE,CAAC;YACnC,KAAK,SAAS;gBACZ,OAAO,IAAI,gCAAoB,EAAE,CAAC;YACpC;gBACE,MAAM,KAAK,CAAC,0BAA0B,CAAC,CAAC;SAC3C;IACH,CAAC;CACF;AA1CD,4BA0CC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-container.js","sourceRoot":"","sources":["../../src/transpiler/file-container.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"file-container.js","sourceRoot":"","sources":["../../src/transpiler/file-container.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAA1B;QACE,WAAM,GAAW,EAAE,CAAC;IAStB,CAAC;IAPC,KAAK;QACH,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,QAAQ,CAAC,IAAU;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACF;AAVD,sCAUC"}
|
|
@@ -2,5 +2,6 @@ import { Type } from '@cparra/apex-reflection';
|
|
|
2
2
|
export default class ClassFileGeneratorHelper {
|
|
3
3
|
static getSanitizedGroup(classModel: Type): string;
|
|
4
4
|
static getFileLink(classModel: Type): string;
|
|
5
|
+
static getFileLinkByTypeName(typeName: string): string;
|
|
5
6
|
private static getClassGroup;
|
|
6
7
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const types_repository_1 = require("../../model/types-repository");
|
|
3
4
|
class ClassFileGeneratorHelper {
|
|
4
5
|
static getSanitizedGroup(classModel) {
|
|
5
6
|
return this.getClassGroup(classModel).replace(/ /g, '-').replace('.', '');
|
|
@@ -7,6 +8,14 @@ class ClassFileGeneratorHelper {
|
|
|
7
8
|
static getFileLink(classModel) {
|
|
8
9
|
return `[${classModel.name}](/${this.getSanitizedGroup(classModel)}/${classModel.name}.md)`;
|
|
9
10
|
}
|
|
11
|
+
static getFileLinkByTypeName(typeName) {
|
|
12
|
+
const type = types_repository_1.TypesRepository.getInstance().getByName(typeName);
|
|
13
|
+
if (!type) {
|
|
14
|
+
// If the type is not found we simply return the file name we received
|
|
15
|
+
return typeName;
|
|
16
|
+
}
|
|
17
|
+
return this.getFileLink(type);
|
|
18
|
+
}
|
|
10
19
|
static getClassGroup(classModel) {
|
|
11
20
|
var _a, _b;
|
|
12
21
|
const groupAnnotation = (_a = classModel.docComment) === null || _a === void 0 ? void 0 : _a.annotations.find((annotation) => annotation.name === 'group');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-file-generatorHelper.js","sourceRoot":"","sources":["../../../src/transpiler/markdown/class-file-generatorHelper.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"class-file-generatorHelper.js","sourceRoot":"","sources":["../../../src/transpiler/markdown/class-file-generatorHelper.ts"],"names":[],"mappings":";;AACA,mEAA+D;AAE/D,MAAqB,wBAAwB;IACpC,MAAM,CAAC,iBAAiB,CAAC,UAAgB;QAC9C,OAAO,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAC5E,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,UAAgB;QACxC,OAAO,IAAI,UAAU,CAAC,IAAI,MAAM,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,IAAI,MAAM,CAAC;IAC9F,CAAC;IAEM,MAAM,CAAC,qBAAqB,CAAC,QAAgB;QAClD,MAAM,IAAI,GAAG,kCAAe,CAAC,WAAW,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,EAAE;YACT,sEAAsE;YACtE,OAAO,QAAQ,CAAC;SACjB;QAED,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAEO,MAAM,CAAC,aAAa,CAAC,UAAgB;;QAC3C,MAAM,eAAe,SAAG,UAAU,CAAC,UAAU,0CAAE,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;QAC7G,aAAO,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,mCAAI,MAAM,CAAC;IACzC,CAAC;CACF;AAvBD,2CAuBC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JekyllDocsProcessor = void 0;
|
|
3
4
|
const markdown_transpiler_base_1 = require("../markdown-transpiler-base");
|
|
4
5
|
const markdown_home_file_1 = require("../../../model/markdown-home-file");
|
|
5
6
|
const markdown_type_file_1 = require("../../../model/markdown-type-file");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jekyll-docsProcessor.js","sourceRoot":"","sources":["../../../../src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jekyll-docsProcessor.js","sourceRoot":"","sources":["../../../../src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts"],"names":[],"mappings":";;;AAAA,0EAAqE;AAErE,0EAAqE;AACrE,0EAAqE;AAErE,MAAa,mBAAoB,SAAQ,iDAAsB;IAA/D;;QAKE,oBAAe,GAAG,CAAC,KAAa,EAAE,EAAE;YAClC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,qCAAgB,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;QACzG,CAAC,CAAC;IASJ,CAAC;IAfC,YAAY;QACV,OAAO,OAAO,CAAC;IACjB,CAAC;IAMD,SAAS,CAAC,IAAU;QAClB,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,qCAAgB,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,IAAI,iBAAiB;QACnB,OAAO,2BAA2B,CAAC;IACrC,CAAC;CACF;AAhBD,kDAgBC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MarkdownTranspilerBase = void 0;
|
|
3
4
|
const processor_type_transpiler_1 = require("../processor-type-transpiler");
|
|
4
5
|
const file_container_1 = require("../file-container");
|
|
5
6
|
const markdown_home_file_1 = require("../../model/markdown-home-file");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown-transpiler-base.js","sourceRoot":"","sources":["../../../src/transpiler/markdown/markdown-transpiler-base.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown-transpiler-base.js","sourceRoot":"","sources":["../../../src/transpiler/markdown/markdown-transpiler-base.ts"],"names":[],"mappings":";;;AAAA,4EAAmE;AAEnE,sDAAkD;AAClD,uEAAkE;AAClE,uEAAkE;AAElE,MAAsB,sBAAuB,SAAQ,mCAAuB;IAG1E;QACE,KAAK,EAAE,CAAC;QAUV,oBAAe,GAAG,CAAC,KAAa,EAAE,EAAE;YAClC,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,qCAAgB,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC;QACjF,CAAC,CAAC;QAXA,IAAI,CAAC,cAAc,GAAG,IAAI,8BAAa,EAAE,CAAC;IAC5C,CAAC;IAID,WAAW;QACT,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAMD,SAAS,CAAC,IAAU;QAClB,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,qCAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;AArBD,wDAqBC"}
|
package/lib/util/logger.js
CHANGED
package/lib/util/logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/util/logger.ts"],"names":[],"mappings":";;;AAAA,+BAA+B;AAE/B;;GAEG;AACH,MAAa,MAAM;IACjB;;;;OAIG;IACI,MAAM,CAAC,GAAG,CAAC,OAAe,EAAE,GAAG,IAAc;QAClD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,OAAe,EAAE,GAAG,IAAc;QACpD,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEO,MAAM,CAAC,SAAS,CAAC,OAAe;QACtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;IACzF,CAAC;CACF;AAzBD,wBAyBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex",
|
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
"prepare": "npm run build",
|
|
24
24
|
"version": "npm run format && git add -A src",
|
|
25
25
|
"postversion": "git push && git push --tags",
|
|
26
|
-
"
|
|
26
|
+
"docsify:init:docs": "docsify init docs",
|
|
27
|
+
"generage:sample": "node lib/cli/generate.js -s examples -t docs -g docsify -c examples/config/config.json",
|
|
28
|
+
"docs:serve:sample": "docsify serve docs",
|
|
29
|
+
"generage:sample:multiple:directories": "node lib/cli/generate.js -s examples/dir1 examples/dir2 -t docs"
|
|
27
30
|
},
|
|
28
31
|
"author": "Cesar Parra",
|
|
29
32
|
"license": "MIT",
|
|
@@ -63,6 +66,7 @@
|
|
|
63
66
|
]
|
|
64
67
|
},
|
|
65
68
|
"dependencies": {
|
|
69
|
+
"fast-xml-parser": "^4.0.1",
|
|
66
70
|
"html-entities": "^2.3.2",
|
|
67
71
|
"sanitize-filename-ts": "1.0.2",
|
|
68
72
|
"yargs": "^16.0.3"
|
package/src/Command/Generate.ts
CHANGED
|
@@ -8,18 +8,21 @@ import FileParser from '../Parser/FileParser';
|
|
|
8
8
|
import DocsifyDocsProcessor from '../DocsifyDocsProcessor';
|
|
9
9
|
import JekyllDocsProcessor from '../JekyllDocsProcessor';
|
|
10
10
|
import AsJsDocsProcessor from '../AsJsDocsProcessor';
|
|
11
|
+
import MetadataProcessor from '../MetadataProcessor';
|
|
11
12
|
|
|
12
13
|
export function generate(
|
|
13
|
-
|
|
14
|
+
sourceDirectories: (string | number)[],
|
|
14
15
|
recursive: boolean = true,
|
|
15
16
|
scope: string[] = ['global', 'public', 'namespaceaccessible'],
|
|
16
17
|
outputDir: string = 'docs',
|
|
17
18
|
targetGenerator: string = 'jekyll',
|
|
18
19
|
configPath?: string,
|
|
19
20
|
group?: boolean,
|
|
21
|
+
indexOnly : boolean = false
|
|
20
22
|
): ClassModel[] {
|
|
21
23
|
Settings.getInstance().setScope(scope);
|
|
22
24
|
Settings.getInstance().setOutputDir(outputDir);
|
|
25
|
+
Settings.getInstance().setIndexOnly(indexOnly);
|
|
23
26
|
|
|
24
27
|
if (targetGenerator === 'jekyll') {
|
|
25
28
|
Settings.getInstance().setDocsProcessor(new JekyllDocsProcessor());
|
|
@@ -38,32 +41,50 @@ export function generate(
|
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
// TODO: Assert data validation to avoid exposing 'fs' and 'path' errors to callers.
|
|
41
|
-
const classes: ClassModel[] = getClassesFromDirectory(
|
|
44
|
+
const classes: ClassModel[] = getClassesFromDirectory(sourceDirectories, recursive);
|
|
42
45
|
// tslint:disable-next-line:no-console
|
|
43
46
|
console.log(`Processed ${classes.length} files`);
|
|
44
47
|
return classes;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
|
-
function getClassesFromDirectory(
|
|
50
|
+
function getClassesFromDirectory(sourceDirectories: (string | number)[], recursive: boolean) {
|
|
48
51
|
let classes: ClassModel[] = [];
|
|
49
52
|
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
for (const currentDirectory of sourceDirectories) {
|
|
54
|
+
const sourceDirectory = currentDirectory as string;
|
|
55
|
+
const directoryContents = fs.readdirSync(sourceDirectory);
|
|
56
|
+
directoryContents.forEach(currentFile => {
|
|
57
|
+
const currentPath = path.join(sourceDirectory, currentFile);
|
|
58
|
+
if (recursive && fs.statSync(currentPath).isDirectory()) {
|
|
59
|
+
classes = classes.concat(getClassesFromDirectory([currentPath], recursive));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (!currentFile.endsWith('.cls')) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const rawFile = fs.readFileSync(currentPath);
|
|
67
|
+
const response = new FileParser().parseFileContents(rawFile.toString());
|
|
68
|
+
const rawFileMetadata = fs.existsSync(currentPath+'-meta.xml') ? fs.readFileSync(currentPath+'-meta.xml') : null;
|
|
69
|
+
if (!response) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
if(rawFileMetadata != null && response != null){
|
|
75
|
+
let metadataGenericParams = MetadataProcessor.process(rawFileMetadata.toString());
|
|
76
|
+
metadataGenericParams.forEach((value, key) => {
|
|
77
|
+
response.setGeneric(key, value);
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!response) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
classes.push(response);
|
|
85
|
+
});
|
|
86
|
+
}
|
|
56
87
|
|
|
57
|
-
if (!currentFile.endsWith('.cls')) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
88
|
|
|
61
|
-
const rawFile = fs.readFileSync(currentPath);
|
|
62
|
-
const response = new FileParser().parseFileContents(rawFile.toString());
|
|
63
|
-
if (!response) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
classes.push(response);
|
|
67
|
-
});
|
|
68
89
|
return classes;
|
|
69
90
|
}
|
|
@@ -12,7 +12,7 @@ beforeEach(() => {
|
|
|
12
12
|
it('returns an empty list when there are no files', () => {
|
|
13
13
|
(fs.readdirSync as jest.Mock).mockReturnValue([]);
|
|
14
14
|
|
|
15
|
-
const classes = generate('src');
|
|
15
|
+
const classes = generate(['src']);
|
|
16
16
|
|
|
17
17
|
expect(classes.length).toBe(0);
|
|
18
18
|
});
|
|
@@ -20,7 +20,7 @@ it('returns an empty list when there are no files', () => {
|
|
|
20
20
|
it('returns an empty list when there are no files ending in .cls', () => {
|
|
21
21
|
(fs.readdirSync as jest.Mock).mockReturnValue(['file.xml', 'README.md']);
|
|
22
22
|
|
|
23
|
-
const classes = generate('src', false);
|
|
23
|
+
const classes = generate(['src'], false);
|
|
24
24
|
|
|
25
25
|
expect(classes.length).toBe(0);
|
|
26
26
|
});
|
|
@@ -29,7 +29,7 @@ it('returns parsed files when there are .cls files', () => {
|
|
|
29
29
|
(fs.readdirSync as jest.Mock).mockReturnValue(['TestClass.cls', 'README.md']);
|
|
30
30
|
(fs.readFileSync as jest.Mock).mockReturnValue('Raw class data');
|
|
31
31
|
|
|
32
|
-
generate('src', false);
|
|
32
|
+
generate(['src'], false);
|
|
33
33
|
|
|
34
34
|
expect(FileParser).toHaveBeenCalledTimes(1);
|
|
35
35
|
const mockFileParserInstance = (FileParser as jest.Mock).mock.instances[0];
|
|
@@ -80,6 +80,11 @@ export default abstract class MarkdownDocsProcessor extends DocsProcessor {
|
|
|
80
80
|
process(classModel: ClassModel, outputDir: string) {
|
|
81
81
|
const generator = new MarkdownHelper(this.classes);
|
|
82
82
|
this.onBeforeClassFileCreated(generator);
|
|
83
|
+
|
|
84
|
+
if( Settings.getInstance().getIndexOnly() === true ){
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
83
88
|
const startingHeadingLevel = Configuration.getConfig()?.content?.startingHeadingLevel || 1;
|
|
84
89
|
this.generateDocsForClass(generator, classModel, startingHeadingLevel);
|
|
85
90
|
|
|
@@ -123,14 +128,18 @@ export default abstract class MarkdownDocsProcessor extends DocsProcessor {
|
|
|
123
128
|
generator.addBlankLine();
|
|
124
129
|
}
|
|
125
130
|
|
|
126
|
-
if (Configuration.getConfig()?.content?.includeAuthor
|
|
127
|
-
|
|
128
|
-
|
|
131
|
+
if (Configuration.getConfig()?.content?.includeAuthor) {
|
|
132
|
+
for (const currentAuthor of classModel.getAuthors()) {
|
|
133
|
+
generator.addBlankLine();
|
|
134
|
+
generator.addText(`**Author:** ${currentAuthor}`);
|
|
135
|
+
}
|
|
129
136
|
}
|
|
130
137
|
|
|
131
|
-
if (Configuration.getConfig()?.content?.includeDate
|
|
132
|
-
|
|
133
|
-
|
|
138
|
+
if (Configuration.getConfig()?.content?.includeDate) {
|
|
139
|
+
for (const currentDate of classModel.getDates()) {
|
|
140
|
+
generator.addBlankLine();
|
|
141
|
+
generator.addText(`**Date:** ${currentDate}`);
|
|
142
|
+
}
|
|
134
143
|
}
|
|
135
144
|
|
|
136
145
|
if (classModel.getSeeList().length !== 0) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {XMLParser} from 'fast-xml-parser'
|
|
2
|
+
|
|
3
|
+
export default class MetadataProcessor{
|
|
4
|
+
|
|
5
|
+
public static process(input : string){
|
|
6
|
+
let map = new Map<string, string>();
|
|
7
|
+
let xml = new XMLParser().parse(input);
|
|
8
|
+
|
|
9
|
+
let apiVersion = xml.ApexClass.apiVersion;
|
|
10
|
+
map.set('apiVersion',apiVersion !== null ? apiVersion : '');
|
|
11
|
+
|
|
12
|
+
let status = xml.ApexClass.status;
|
|
13
|
+
map.set('status',status !== null ? status : '');
|
|
14
|
+
return map;
|
|
15
|
+
}
|
|
16
|
+
}
|
package/src/Model/ApexModel.ts
CHANGED
|
@@ -4,13 +4,15 @@ export default class ApexModel {
|
|
|
4
4
|
protected nameLine: string = '';
|
|
5
5
|
private nameLineIndex: number | undefined;
|
|
6
6
|
private description: string = '';
|
|
7
|
-
private
|
|
8
|
-
private
|
|
7
|
+
private authors: string[] = [];
|
|
8
|
+
private dates: string[] = [];
|
|
9
9
|
private returns: string = '';
|
|
10
10
|
private example: string = '';
|
|
11
11
|
private scope: string = '';
|
|
12
12
|
private isNamespaceAccessible: boolean = false;
|
|
13
13
|
|
|
14
|
+
private generics = new Map<string, string>();
|
|
15
|
+
|
|
14
16
|
getNameLine() {
|
|
15
17
|
return this.nameLine;
|
|
16
18
|
}
|
|
@@ -33,20 +35,20 @@ export default class ApexModel {
|
|
|
33
35
|
this.description = description;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
return this.
|
|
38
|
+
getAuthors() {
|
|
39
|
+
return this.authors;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
this.author
|
|
42
|
+
addAuthor(author: string) {
|
|
43
|
+
this.authors.push(author);
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
|
|
45
|
-
return this.
|
|
46
|
+
getDates() {
|
|
47
|
+
return this.dates;
|
|
46
48
|
}
|
|
47
49
|
|
|
48
|
-
|
|
49
|
-
this.date
|
|
50
|
+
addDate(date: string) {
|
|
51
|
+
this.dates.push(date);
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
getReturns() {
|
|
@@ -81,6 +83,15 @@ export default class ApexModel {
|
|
|
81
83
|
return this.isNamespaceAccessible;
|
|
82
84
|
}
|
|
83
85
|
|
|
86
|
+
setGeneric(name:string, value:string){
|
|
87
|
+
this.generics.set(name, value);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
getGeneric(name:string){
|
|
91
|
+
let value = this.generics.get(name);
|
|
92
|
+
return value ? value : '';
|
|
93
|
+
}
|
|
94
|
+
|
|
84
95
|
private parseScope() {
|
|
85
96
|
this.scope = '';
|
|
86
97
|
const str = this.getScopeFromSettings(this.nameLine);
|
|
@@ -12,30 +12,36 @@ export default class ClassParser {
|
|
|
12
12
|
private fillClassModel(cModel: ClassModel, name: string, lstComments: string[], iLine: number) {
|
|
13
13
|
cModel.setNameLine(name, iLine);
|
|
14
14
|
if (name.toLowerCase().includes(' interface ')) cModel.setIsInterface(true);
|
|
15
|
+
let multiline = false;
|
|
15
16
|
let inDescription = false;
|
|
17
|
+
let inHistory = false;
|
|
16
18
|
let i = 0;
|
|
19
|
+
|
|
20
|
+
let reAnyAnnotation = new RegExp('@([A-Za-z]*)\s*(.*)')
|
|
21
|
+
|
|
17
22
|
for (let comment of lstComments) {
|
|
18
23
|
i++;
|
|
19
24
|
comment = comment.trim();
|
|
20
25
|
|
|
26
|
+
|
|
21
27
|
let idxStart = comment.toLowerCase().indexOf('@author');
|
|
22
28
|
if (idxStart !== -1) {
|
|
23
|
-
cModel.
|
|
24
|
-
|
|
29
|
+
cModel.addAuthor(comment.substring(idxStart + 7).trim());
|
|
30
|
+
multiline = false;
|
|
25
31
|
continue;
|
|
26
32
|
}
|
|
27
33
|
|
|
28
34
|
idxStart = comment.toLowerCase().indexOf('@date');
|
|
29
35
|
if (idxStart !== -1) {
|
|
30
|
-
cModel.
|
|
31
|
-
|
|
36
|
+
cModel.addDate(comment.substring(idxStart + 5).trim());
|
|
37
|
+
multiline = false;
|
|
32
38
|
continue;
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
idxStart = comment.toLowerCase().indexOf('@see');
|
|
36
42
|
if (idxStart !== -1) {
|
|
37
43
|
cModel.addSee(comment.substring(idxStart + 4).trim());
|
|
38
|
-
|
|
44
|
+
multiline = false;
|
|
39
45
|
continue;
|
|
40
46
|
}
|
|
41
47
|
|
|
@@ -46,40 +52,52 @@ export default class ClassParser {
|
|
|
46
52
|
cModel.setClassGroup(group);
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
multiline = false;
|
|
50
56
|
continue;
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
idxStart = comment.toLowerCase().indexOf('@group-content');
|
|
54
60
|
if (idxStart !== -1) {
|
|
55
61
|
cModel.setClassGroupContent(comment.substring(idxStart + 14).trim());
|
|
56
|
-
|
|
62
|
+
multiline = false;
|
|
57
63
|
continue;
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
idxStart = comment.toLowerCase().indexOf('@description');
|
|
61
|
-
if (idxStart !== -1 || i === 1) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const found = comment.match('\\s');
|
|
66
|
-
if (found && found.index) {
|
|
67
|
-
cModel.setDescription(comment.substring(found.index).trim());
|
|
68
|
-
}
|
|
69
|
-
}
|
|
67
|
+
if (idxStart !== -1 || (i === 1 && !reAnyAnnotation.test(comment) )) {
|
|
68
|
+
cModel.setDescription(comment.substring(idxStart + 12).trim());
|
|
69
|
+
|
|
70
|
+
multiline = true;
|
|
70
71
|
inDescription = true;
|
|
72
|
+
inHistory = false;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
let anyStart = reAnyAnnotation.exec(comment)
|
|
77
|
+
|
|
78
|
+
idxStart = (typeof anyStart?.index !== 'undefined') ? anyStart.index : -1;
|
|
79
|
+
if (idxStart !== -1 && anyStart !== null) {
|
|
80
|
+
let genericName = anyStart[1];
|
|
81
|
+
let genericValue = anyStart[2];
|
|
82
|
+
cModel.setGeneric(genericName, genericValue);
|
|
83
|
+
|
|
84
|
+
multiline = false;
|
|
85
|
+
inDescription = false;
|
|
86
|
+
inHistory = false;
|
|
71
87
|
continue;
|
|
72
88
|
}
|
|
73
89
|
|
|
74
90
|
// handle multiple lines for description.
|
|
75
|
-
if (
|
|
91
|
+
if (multiline === true) {
|
|
76
92
|
let j;
|
|
77
93
|
for (j = 0; j < comment.length; j++) {
|
|
78
94
|
const ch = comment.charAt(j);
|
|
79
95
|
if (ch !== '*' && ch !== ' ') break;
|
|
80
96
|
}
|
|
81
|
-
if (j < comment.length) {
|
|
82
|
-
|
|
97
|
+
if (j < comment.length && !reAnyAnnotation.test(comment)) {
|
|
98
|
+
if(inDescription){
|
|
99
|
+
cModel.setDescription(cModel.getDescription() + ' ' + comment.substring(j));
|
|
100
|
+
}
|
|
83
101
|
}
|
|
84
102
|
continue;
|
|
85
103
|
}
|
|
@@ -23,7 +23,7 @@ export default class MethodParser {
|
|
|
23
23
|
|
|
24
24
|
let idxStart = comment.toLowerCase().indexOf('@author');
|
|
25
25
|
if (idxStart !== -1) {
|
|
26
|
-
mModel.
|
|
26
|
+
mModel.addAuthor(comment.substring(idxStart + 8).trim());
|
|
27
27
|
inDescription = false;
|
|
28
28
|
inExample = false;
|
|
29
29
|
continue;
|
|
@@ -31,7 +31,7 @@ export default class MethodParser {
|
|
|
31
31
|
|
|
32
32
|
idxStart = comment.toLowerCase().indexOf('@date');
|
|
33
33
|
if (idxStart !== -1) {
|
|
34
|
-
mModel.
|
|
34
|
+
mModel.addDate(comment.substring(idxStart + 5).trim());
|
|
35
35
|
inDescription = false;
|
|
36
36
|
inExample = false;
|
|
37
37
|
continue;
|
|
@@ -5,7 +5,9 @@ const commentLines = [
|
|
|
5
5
|
'/**',
|
|
6
6
|
' * @description This is my class description.',
|
|
7
7
|
' * @author John Doe',
|
|
8
|
+
' * @author Jane Doe',
|
|
8
9
|
' * @date 1/1/2020',
|
|
10
|
+
' * @date 2/2/2021',
|
|
9
11
|
' * @group API',
|
|
10
12
|
' * @group-content /example.html',
|
|
11
13
|
' */',
|
|
@@ -26,13 +28,17 @@ test('whether if class is interface was set correctly', () => {
|
|
|
26
28
|
test('that author was set correctly', () => {
|
|
27
29
|
const builtClassModel = new ClassParser().getClass(nameLine, commentLines, 4);
|
|
28
30
|
|
|
29
|
-
expect(builtClassModel.
|
|
31
|
+
expect(builtClassModel.getAuthors()).toHaveLength(2);
|
|
32
|
+
expect(builtClassModel.getAuthors()[0]).toBe('John Doe');
|
|
33
|
+
expect(builtClassModel.getAuthors()[1]).toBe('Jane Doe');
|
|
30
34
|
});
|
|
31
35
|
|
|
32
36
|
test('that date was set correctly', () => {
|
|
33
37
|
const builtClassModel = new ClassParser().getClass(nameLine, commentLines, 4);
|
|
34
38
|
|
|
35
|
-
expect(builtClassModel.
|
|
39
|
+
expect(builtClassModel.getDates()).toHaveLength(2);
|
|
40
|
+
expect(builtClassModel.getDates()[0]).toBe('1/1/2020');
|
|
41
|
+
expect(builtClassModel.getDates()[1]).toBe('2/2/2021');
|
|
36
42
|
});
|
|
37
43
|
|
|
38
44
|
test('that group was set correctly', () => {
|
|
@@ -36,13 +36,14 @@ test('that method is not constructor when class name is the not the same as the
|
|
|
36
36
|
test('that author is set', () => {
|
|
37
37
|
const builtMethodModel = new MethodParser().getMethod('ClassName', nameLine, commentLines, 4);
|
|
38
38
|
|
|
39
|
-
expect(builtMethodModel.
|
|
39
|
+
expect(builtMethodModel.getAuthors()).toHaveLength(1);
|
|
40
|
+
expect(builtMethodModel.getAuthors()[0]).toBe('John Doe');
|
|
40
41
|
});
|
|
41
42
|
|
|
42
43
|
test('that date is set', () => {
|
|
43
44
|
const builtMethodModel = new MethodParser().getMethod('ClassName', nameLine, commentLines, 4);
|
|
44
45
|
|
|
45
|
-
expect(builtMethodModel.
|
|
46
|
+
expect(builtMethodModel.getDates()[0]).toBe('1/1/2020');
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
test('that return is set', () => {
|
package/src/Settings.ts
CHANGED
|
@@ -8,6 +8,8 @@ export default class Settings {
|
|
|
8
8
|
private configPath: string | null = null;
|
|
9
9
|
private shouldGroup: boolean | null = true;
|
|
10
10
|
private processor: DocsProcessor | null = null;
|
|
11
|
+
private indexOnly: boolean = false;
|
|
12
|
+
|
|
11
13
|
|
|
12
14
|
private constructor() {}
|
|
13
15
|
|
|
@@ -58,6 +60,14 @@ export default class Settings {
|
|
|
58
60
|
getShouldGroup() {
|
|
59
61
|
return this.shouldGroup;
|
|
60
62
|
}
|
|
63
|
+
|
|
64
|
+
getIndexOnly(): boolean {
|
|
65
|
+
return this.indexOnly;
|
|
66
|
+
}
|
|
67
|
+
setIndexOnly(value: boolean) {
|
|
68
|
+
this.indexOnly = value;
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
|
|
62
72
|
includeNamespaceAccessible() {
|
|
63
73
|
return this.getScope().includes('namespaceaccessible');
|
package/src/cli/generate.ts
CHANGED
|
@@ -6,10 +6,10 @@ import FileManager from '../FileManager';
|
|
|
6
6
|
|
|
7
7
|
const argv = yargs.options({
|
|
8
8
|
sourceDir: {
|
|
9
|
-
type: '
|
|
9
|
+
type: 'array',
|
|
10
10
|
alias: 's',
|
|
11
11
|
demandOption: true,
|
|
12
|
-
describe: 'The directory location which contains your apex .cls classes.',
|
|
12
|
+
describe: 'The directory or directories location(s) which contains your apex .cls classes.',
|
|
13
13
|
},
|
|
14
14
|
targetDir: {
|
|
15
15
|
type: 'string',
|
|
@@ -50,6 +50,12 @@ const argv = yargs.options({
|
|
|
50
50
|
'Define whether the generated files should be grouped by the @group tag on the top level classes.' +
|
|
51
51
|
'If set to true, a sub directory will be created per group inside of the specified target directory.',
|
|
52
52
|
},
|
|
53
|
+
indexOnly: {
|
|
54
|
+
type: 'boolean',
|
|
55
|
+
default: false,
|
|
56
|
+
describe:
|
|
57
|
+
'Defines whether only the index file should be generated.',
|
|
58
|
+
}
|
|
53
59
|
}).argv;
|
|
54
60
|
|
|
55
61
|
const generatedClassModels = generate(
|
|
@@ -60,5 +66,6 @@ const generatedClassModels = generate(
|
|
|
60
66
|
argv.targetGenerator,
|
|
61
67
|
argv.configPath,
|
|
62
68
|
argv.group,
|
|
69
|
+
argv.indexOnly,
|
|
63
70
|
);
|
|
64
71
|
new FileManager(generatedClassModels).generate();
|