@cparra/apexdocs 2.3.0 → 2.5.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.
Files changed (53) hide show
  1. package/README.md +48 -113
  2. package/docs/{Misc → API}/SampleClassWithoutModifier.md +0 -0
  3. package/docs/Main/GroupedClass.md +10 -0
  4. package/docs/{Sample-Classes → Main}/SampleClass.md +5 -1
  5. package/docs/README.md +4 -5
  6. package/docs/index.html +22 -0
  7. package/examples/force-app/main/default/classes/GroupedClass.cls +1 -1
  8. package/examples/force-app/main/default/classes/SampleClass.cls +1 -1
  9. package/lib/application/Apexdocs.js +2 -1
  10. package/lib/application/Apexdocs.js.map +1 -1
  11. package/lib/cli/generate.js +9 -3
  12. package/lib/cli/generate.js.map +1 -1
  13. package/lib/model/markdown-file.js +1 -0
  14. package/lib/model/markdown-file.js.map +1 -1
  15. package/lib/model/markdown-generation-util/method-declaration-util.js +7 -3
  16. package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -1
  17. package/lib/service/state.d.ts +9 -0
  18. package/lib/service/state.js +20 -0
  19. package/lib/service/state.js.map +1 -0
  20. package/lib/settings.d.ts +4 -1
  21. package/lib/settings.js +14 -2
  22. package/lib/settings.js.map +1 -1
  23. package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +1 -0
  24. package/lib/transpiler/markdown/class-file-generatorHelper.js +28 -3
  25. package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
  26. package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +2 -0
  27. package/lib/transpiler/markdown/docsify/docsify-docs-processor.js +3 -0
  28. package/lib/transpiler/markdown/docsify/docsify-docs-processor.js.map +1 -1
  29. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +2 -0
  30. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +3 -0
  31. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -1
  32. package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +6 -0
  33. package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +14 -0
  34. package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +1 -0
  35. package/lib/transpiler/processor-type-transpiler.d.ts +2 -0
  36. package/lib/transpiler/processor-type-transpiler.js.map +1 -1
  37. package/lib/transpiler/transpiler.js +2 -0
  38. package/lib/transpiler/transpiler.js.map +1 -1
  39. package/package.json +2 -2
  40. package/src/application/Apexdocs.ts +9 -1
  41. package/src/cli/generate.ts +9 -3
  42. package/src/model/markdown-file.ts +1 -0
  43. package/src/model/markdown-generation-util/method-declaration-util.ts +6 -1
  44. package/src/service/state.ts +24 -0
  45. package/src/settings.ts +18 -3
  46. package/src/transpiler/markdown/class-file-generatorHelper.ts +30 -3
  47. package/src/transpiler/markdown/docsify/docsify-docs-processor.ts +5 -0
  48. package/src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts +5 -0
  49. package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +12 -0
  50. package/src/transpiler/processor-type-transpiler.ts +4 -0
  51. package/src/transpiler/transpiler.ts +2 -0
  52. package/docs/Misc/SampleClass.md +0 -168
  53. package/docs/Utils/GroupedClass.md +0 -10
@@ -1,12 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const types_repository_1 = require("../../model/types-repository");
4
+ const settings_1 = require("../../settings");
5
+ const state_1 = require("../../service/state");
4
6
  class ClassFileGeneratorHelper {
5
7
  static getSanitizedGroup(classModel) {
6
8
  return this.getClassGroup(classModel).replace(/ /g, '-').replace('.', '');
7
9
  }
8
10
  static getFileLink(classModel) {
9
- return `[${classModel.name}](/${this.getSanitizedGroup(classModel)}/${classModel.name}.md)`;
11
+ const directoryRoot = this.getDirectoryRoot(classModel);
12
+ return `[${classModel.name}](${directoryRoot}${classModel.name}.md)`;
10
13
  }
11
14
  static getFileLinkByTypeName(typeName) {
12
15
  const type = types_repository_1.TypesRepository.getInstance().getByName(typeName);
@@ -16,10 +19,32 @@ class ClassFileGeneratorHelper {
16
19
  }
17
20
  return this.getFileLink(type);
18
21
  }
22
+ static getDirectoryRoot(classModel) {
23
+ // root-relative links start from the root by using a leading '/'
24
+ if (settings_1.Settings.getInstance().typeTranspiler.getLinkingStrategy() === 'root-relative') {
25
+ return `/${this.getSanitizedGroup(classModel)}/`;
26
+ }
27
+ // path-relative links traverse the directory structure
28
+ const typeBeingProcessed = state_1.default.getInstance().getTypeBeingProcessed();
29
+ if (typeBeingProcessed) {
30
+ if (this.getClassGroup(typeBeingProcessed) === this.getClassGroup(classModel)) {
31
+ // If the types the same groups then we simply link directly to that file
32
+ return './';
33
+ }
34
+ else {
35
+ // If the types have different groups then we have to go up a directory
36
+ return `../${this.getSanitizedGroup(classModel)}/`;
37
+ }
38
+ }
39
+ else {
40
+ // If nothing is being processed then we assume we are at the root and links should include the groups
41
+ return `./${this.getSanitizedGroup(classModel)}/`;
42
+ }
43
+ }
19
44
  static getClassGroup(classModel) {
20
45
  var _a, _b;
21
- const groupAnnotation = (_a = classModel.docComment) === null || _a === void 0 ? void 0 : _a.annotations.find((annotation) => annotation.name === 'group');
22
- return (_b = groupAnnotation === null || groupAnnotation === void 0 ? void 0 : groupAnnotation.body) !== null && _b !== void 0 ? _b : 'Misc';
46
+ const groupAnnotation = (_a = classModel.docComment) === null || _a === void 0 ? void 0 : _a.annotations.find((annotation) => annotation.name.toLowerCase() === 'group');
47
+ return (_b = groupAnnotation === null || groupAnnotation === void 0 ? void 0 : groupAnnotation.body) !== null && _b !== void 0 ? _b : settings_1.Settings.getInstance().getDefaultGroupName();
23
48
  }
24
49
  }
25
50
  exports.default = ClassFileGeneratorHelper;
@@ -1 +1 @@
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,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AAC;IAEO,MAAM,CAAC,aAAa,CAAC,UAAgB;;QAC3C,MAAM,eAAe,SAAG,UAAU,CAAC,UAAU,0CAAE,WAAW,CAAC,IAAI,CAC7D,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,OAAO,CAC1D,CAAC;QACF,aAAO,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,mCAAI,mBAAQ,CAAC,WAAW,EAAE,CAAC,mBAAmB,EAAE,CAAC;IAC/E,CAAC;CACF;AAhDD,2CAgDC"}
@@ -1,4 +1,6 @@
1
1
  import { MarkdownTranspilerBase } from '../markdown-transpiler-base';
2
+ import { LinkingStrategy } from '../../processor-type-transpiler';
2
3
  export default class DocsifyDocsProcessor extends MarkdownTranspilerBase {
3
4
  homeFileName(): string;
5
+ getLinkingStrategy(): LinkingStrategy;
4
6
  }
@@ -5,6 +5,9 @@ class DocsifyDocsProcessor extends markdown_transpiler_base_1.MarkdownTranspiler
5
5
  homeFileName() {
6
6
  return 'README';
7
7
  }
8
+ getLinkingStrategy() {
9
+ return 'root-relative';
10
+ }
8
11
  }
9
12
  exports.default = DocsifyDocsProcessor;
10
13
  //# sourceMappingURL=docsify-docs-processor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"docsify-docs-processor.js","sourceRoot":"","sources":["../../../../src/transpiler/markdown/docsify/docsify-docs-processor.ts"],"names":[],"mappings":";;AAAA,0EAAqE;AAErE,MAAqB,oBAAqB,SAAQ,iDAAsB;IACtE,YAAY;QACV,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AAJD,uCAIC"}
1
+ {"version":3,"file":"docsify-docs-processor.js","sourceRoot":"","sources":["../../../../src/transpiler/markdown/docsify/docsify-docs-processor.ts"],"names":[],"mappings":";;AAAA,0EAAqE;AAGrE,MAAqB,oBAAqB,SAAQ,iDAAsB;IACtE,YAAY;QACV,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,kBAAkB;QAChB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AARD,uCAQC"}
@@ -1,8 +1,10 @@
1
1
  import { MarkdownTranspilerBase } from '../markdown-transpiler-base';
2
2
  import { Type } from '@cparra/apex-reflection';
3
+ import { LinkingStrategy } from '../../processor-type-transpiler';
3
4
  export declare class JekyllDocsProcessor extends MarkdownTranspilerBase {
4
5
  homeFileName(): string;
5
6
  onBeforeProcess: (types: Type[]) => void;
6
7
  onProcess(type: Type): void;
7
8
  get frontMatterHeader(): string;
9
+ getLinkingStrategy(): LinkingStrategy;
8
10
  }
@@ -20,6 +20,9 @@ class JekyllDocsProcessor extends markdown_transpiler_base_1.MarkdownTranspilerB
20
20
  get frontMatterHeader() {
21
21
  return '---\nlayout: default\n---';
22
22
  }
23
+ getLinkingStrategy() {
24
+ return 'path-relative';
25
+ }
23
26
  }
24
27
  exports.JekyllDocsProcessor = JekyllDocsProcessor;
25
28
  //# sourceMappingURL=jekyll-docsProcessor.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"jekyll-docsProcessor.js","sourceRoot":"","sources":["../../../../src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts"],"names":[],"mappings":";;;AAAA,0EAAqE;AAErE,0EAAqE;AACrE,0EAAqE;AAGrE,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;IAaJ,CAAC;IAnBC,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;IAED,kBAAkB;QAChB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AApBD,kDAoBC"}
@@ -0,0 +1,6 @@
1
+ import { MarkdownTranspilerBase } from '../markdown-transpiler-base';
2
+ import { LinkingStrategy } from '../../processor-type-transpiler';
3
+ export declare class PlainMarkdownDocsProcessor extends MarkdownTranspilerBase {
4
+ homeFileName(): string;
5
+ getLinkingStrategy(): LinkingStrategy;
6
+ }
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PlainMarkdownDocsProcessor = void 0;
4
+ const markdown_transpiler_base_1 = require("../markdown-transpiler-base");
5
+ class PlainMarkdownDocsProcessor extends markdown_transpiler_base_1.MarkdownTranspilerBase {
6
+ homeFileName() {
7
+ return 'index';
8
+ }
9
+ getLinkingStrategy() {
10
+ return 'path-relative';
11
+ }
12
+ }
13
+ exports.PlainMarkdownDocsProcessor = PlainMarkdownDocsProcessor;
14
+ //# sourceMappingURL=plain-docsProcessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plain-docsProcessor.js","sourceRoot":"","sources":["../../../../src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts"],"names":[],"mappings":";;;AAAA,0EAAqE;AAGrE,MAAa,0BAA2B,SAAQ,iDAAsB;IACpE,YAAY;QACV,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,kBAAkB;QAChB,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;AARD,gEAQC"}
@@ -1,8 +1,10 @@
1
1
  import { Type } from '@cparra/apex-reflection';
2
2
  import { FileContainer } from './file-container';
3
+ export declare type LinkingStrategy = 'root-relative' | 'path-relative';
3
4
  export default abstract class ProcessorTypeTranspiler {
4
5
  onBeforeProcess: ((types: Type[]) => void) | undefined;
5
6
  abstract onProcess(type: Type): void;
6
7
  onAfterProcess: ((types: Type[]) => void) | undefined;
7
8
  abstract fileBuilder(): FileContainer;
9
+ abstract getLinkingStrategy(): LinkingStrategy;
8
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"processor-type-transpiler.js","sourceRoot":"","sources":["../../src/transpiler/processor-type-transpiler.ts"],"names":[],"mappings":";;AAGA,MAA8B,uBAAuB;CAQpD;AARD,0CAQC"}
1
+ {"version":3,"file":"processor-type-transpiler.js","sourceRoot":"","sources":["../../src/transpiler/processor-type-transpiler.ts"],"names":[],"mappings":";;AAKA,MAA8B,uBAAuB;CAUpD;AAVD,0CAUC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const settings_1 = require("../settings");
4
+ const state_1 = require("../service/state");
4
5
  class Transpiler {
5
6
  static generate(types, processor) {
6
7
  var _a, _b;
@@ -16,6 +17,7 @@ class Transpiler {
16
17
  return;
17
18
  }
18
19
  sortedTypes.forEach((currentType) => {
20
+ state_1.default.getInstance().setTypeBeingProcessed(currentType);
19
21
  processor.onProcess(currentType);
20
22
  });
21
23
  (_b = processor.onAfterProcess) === null || _b === void 0 ? void 0 : _b.call(processor, sortedTypes);
@@ -1 +1 @@
1
- {"version":3,"file":"transpiler.js","sourceRoot":"","sources":["../../src/transpiler/transpiler.ts"],"names":[],"mappings":";;AAEA,0CAAuC;AAEvC,MAAqB,UAAU;IAC7B,MAAM,CAAC,QAAQ,CAAC,KAAa,EAAE,SAAkC;;QAC/D,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YACtD,IAAI,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI;gBAAE,OAAO,CAAC,CAAC,CAAC;YAC/C,IAAI,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI;gBAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;QAEH,MAAA,SAAS,CAAC,eAAe,+CAAzB,SAAS,EAAmB,WAAW,EAAE;QAEzC,IAAI,mBAAQ,CAAC,WAAW,EAAE,CAAC,SAAS,KAAK,IAAI,EAAE;YAC7C,OAAO;SACR;QAED,WAAW,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YAClC,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,MAAA,SAAS,CAAC,cAAc,+CAAxB,SAAS,EAAkB,WAAW,EAAE;IAC1C,CAAC;CACF;AAnBD,6BAmBC"}
1
+ {"version":3,"file":"transpiler.js","sourceRoot":"","sources":["../../src/transpiler/transpiler.ts"],"names":[],"mappings":";;AAEA,0CAAuC;AACvC,4CAAqC;AAErC,MAAqB,UAAU;IAC7B,MAAM,CAAC,QAAQ,CAAC,KAAa,EAAE,SAAkC;;QAC/D,MAAM,WAAW,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YACtD,IAAI,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI;gBAAE,OAAO,CAAC,CAAC,CAAC;YAC/C,IAAI,SAAS,CAAC,IAAI,GAAG,SAAS,CAAC,IAAI;gBAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,CAAC,CAAC;QACX,CAAC,CAAC,CAAC;QAEH,MAAA,SAAS,CAAC,eAAe,+CAAzB,SAAS,EAAmB,WAAW,EAAE;QAEzC,IAAI,mBAAQ,CAAC,WAAW,EAAE,CAAC,SAAS,KAAK,IAAI,EAAE;YAC7C,OAAO;SACR;QAED,WAAW,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;YAClC,eAAK,CAAC,WAAW,EAAE,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;YACvD,SAAS,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,MAAA,SAAS,CAAC,cAAc,+CAAxB,SAAS,EAAkB,WAAW,EAAE;IAC1C,CAAC;CACF;AApBD,6BAoBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cparra/apexdocs",
3
- "version": "2.3.0",
3
+ "version": "2.5.0",
4
4
  "description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
5
5
  "keywords": [
6
6
  "apex",
@@ -24,7 +24,7 @@
24
24
  "postversion": "git push && git push --tags",
25
25
  "docs:init": "docsify init docs",
26
26
  "docs:serve": "docsify serve docs",
27
- "execute:example": "node lib/cli/generate.js -s examples/force-app -t docs --scope global public private -g docsify",
27
+ "execute:example": "node lib/cli/generate.js -s examples/force-app -t docs --scope global public private -g docsify --defaultGroupName API",
28
28
  "execute:example:index:only": "node lib/cli/generate.js -s examples/force-app -t docs --scope global public private -g docsify --indexOnly"
29
29
  },
30
30
  "author": "Cesar Parra",
@@ -27,7 +27,15 @@ export class Apexdocs {
27
27
  TypesRepository.getInstance().populate(filteredTypes);
28
28
  Logger.clear();
29
29
 
30
- Logger.logSingle(`Parsed ${filteredTypes.length} files`, false, 'green', false);
30
+ Logger.logSingle(
31
+ `Filtered ${manifest.types.length - filteredTypes.length} file(s) based on scope: ${
32
+ Settings.getInstance().scope
33
+ }`,
34
+ false,
35
+ 'green',
36
+ false,
37
+ );
38
+ Logger.logSingle(`Creating documentation for ${filteredTypes.length} file(s)`, false, 'green', false);
31
39
  const processor = Settings.getInstance().typeTranspiler;
32
40
  Transpiler.generate(filteredTypes, processor);
33
41
  const generatedFiles = processor.fileBuilder().files();
@@ -35,14 +35,19 @@ const argv = yargs.options({
35
35
  type: 'string',
36
36
  alias: 'g',
37
37
  default: 'jekyll',
38
- choices: ['jekyll', 'docsify'],
38
+ choices: ['jekyll', 'docsify', 'plain-markdown'],
39
39
  describe:
40
- 'Define the static file generator for which the documents will be created. Currently supports jekyll, and docsify.',
40
+ 'Define the static file generator for which the documents will be created. Currently supports jekyll, docsify, and plain markdown.',
41
41
  },
42
42
  indexOnly: {
43
43
  type: 'boolean',
44
44
  default: false,
45
- describe: 'Defines whether only the index file should be generated.',
45
+ describe: 'Defines whether only the index file should be generated.',
46
+ },
47
+ defaultGroupName: {
48
+ type: 'string',
49
+ default: 'Miscellaneous',
50
+ describe: 'Defines the @group name to be used when a file does not specify it.',
46
51
  },
47
52
  }).argv;
48
53
 
@@ -53,6 +58,7 @@ Settings.build({
53
58
  outputDir: argv.targetDir,
54
59
  targetGenerator: argv.targetGenerator as GeneratorChoices,
55
60
  indexOnly: argv.indexOnly,
61
+ defaultGroupName: argv.defaultGroupName,
56
62
  });
57
63
 
58
64
  Apexdocs.generate();
@@ -42,6 +42,7 @@ export class MarkdownFile extends File {
42
42
  }
43
43
 
44
44
  initializeTable(...headers: string[]) {
45
+ this.addBlankLine();
45
46
  this._contents += '|';
46
47
  headers.forEach((header) => {
47
48
  this._contents += header + '|';
@@ -58,7 +58,7 @@ function buildSignature(name: string, parameterAware: ParameterAware): string {
58
58
  }
59
59
  const signatureParameters = parameterAware.parameters.map((param) => `${param.type} ${param.name}`);
60
60
  signature += signatureParameters.join(', ');
61
- return (signature += ')');
61
+ return `${signature})`;
62
62
  }
63
63
 
64
64
  function addParameters(
@@ -66,6 +66,11 @@ function addParameters(
66
66
  methodModel: MethodMirror | ConstructorMirror,
67
67
  startingHeadingLevel: number,
68
68
  ) {
69
+ if (!methodModel.docComment?.paramAnnotations.length) {
70
+ // If there are no parameters defined in the docs then we don't want to display this section
71
+ return;
72
+ }
73
+
69
74
  markdownFile.addTitle('Parameters', startingHeadingLevel + 3);
70
75
  markdownFile.initializeTable('Param', 'Description');
71
76
 
@@ -0,0 +1,24 @@
1
+ import { Type } from '@cparra/apex-reflection';
2
+
3
+ export default class State {
4
+ private static instance: State;
5
+ private typeBeingProcessed?: Type;
6
+
7
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
8
+ private constructor() {}
9
+
10
+ public static getInstance(): State {
11
+ if (!State.instance) {
12
+ State.instance = new State();
13
+ }
14
+ return State.instance;
15
+ }
16
+
17
+ public setTypeBeingProcessed(typeToSet: Type): void {
18
+ this.typeBeingProcessed = typeToSet;
19
+ }
20
+
21
+ public getTypeBeingProcessed(): Type | undefined {
22
+ return this.typeBeingProcessed;
23
+ }
24
+ }
package/src/settings.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import ProcessorTypeTranspiler from './transpiler/processor-type-transpiler';
2
2
  import { JekyllDocsProcessor } from './transpiler/markdown/jekyll/jekyll-docsProcessor';
3
3
  import DocsifyDocsProcessor from './transpiler/markdown/docsify/docsify-docs-processor';
4
+ import { PlainMarkdownDocsProcessor } from './transpiler/markdown/plain-markdown/plain-docsProcessor';
4
5
 
5
- export type GeneratorChoices = 'jekyll' | 'docsify';
6
+ export type GeneratorChoices = 'jekyll' | 'docsify' | 'plain-markdown';
6
7
 
7
8
  export interface SettingsConfig {
8
9
  sourceDirectory: string;
@@ -11,6 +12,7 @@ export interface SettingsConfig {
11
12
  outputDir: string;
12
13
  targetGenerator: GeneratorChoices;
13
14
  indexOnly: boolean;
15
+ defaultGroupName: string;
14
16
  }
15
17
 
16
18
  export class Settings {
@@ -45,12 +47,21 @@ export class Settings {
45
47
  return this.config.outputDir;
46
48
  }
47
49
 
50
+ private static typeTranspilerCache?: ProcessorTypeTranspiler;
48
51
  get typeTranspiler(): ProcessorTypeTranspiler {
52
+ if (Settings.typeTranspilerCache) {
53
+ return Settings.typeTranspilerCache;
54
+ }
49
55
  switch (this.config.targetGenerator) {
50
56
  case 'jekyll':
51
- return new JekyllDocsProcessor();
57
+ Settings.typeTranspilerCache = new JekyllDocsProcessor();
58
+ return Settings.typeTranspilerCache;
52
59
  case 'docsify':
53
- return new DocsifyDocsProcessor();
60
+ Settings.typeTranspilerCache = new DocsifyDocsProcessor();
61
+ return Settings.typeTranspilerCache;
62
+ case 'plain-markdown':
63
+ Settings.typeTranspilerCache = new PlainMarkdownDocsProcessor();
64
+ return Settings.typeTranspilerCache;
54
65
  default:
55
66
  throw Error('Invalid target generator');
56
67
  }
@@ -59,4 +70,8 @@ export class Settings {
59
70
  get indexOnly(): boolean {
60
71
  return this.config.indexOnly;
61
72
  }
73
+
74
+ public getDefaultGroupName(): string {
75
+ return this.config.defaultGroupName;
76
+ }
62
77
  }
@@ -1,5 +1,7 @@
1
1
  import { Type } from '@cparra/apex-reflection';
2
2
  import { TypesRepository } from '../../model/types-repository';
3
+ import { Settings } from '../../settings';
4
+ import State from '../../service/state';
3
5
 
4
6
  export default class ClassFileGeneratorHelper {
5
7
  public static getSanitizedGroup(classModel: Type) {
@@ -7,7 +9,8 @@ export default class ClassFileGeneratorHelper {
7
9
  }
8
10
 
9
11
  public static getFileLink(classModel: Type) {
10
- return `[${classModel.name}](/${this.getSanitizedGroup(classModel)}/${classModel.name}.md)`;
12
+ const directoryRoot = this.getDirectoryRoot(classModel);
13
+ return `[${classModel.name}](${directoryRoot}${classModel.name}.md)`;
11
14
  }
12
15
 
13
16
  public static getFileLinkByTypeName(typeName: string) {
@@ -20,8 +23,32 @@ export default class ClassFileGeneratorHelper {
20
23
  return this.getFileLink(type);
21
24
  }
22
25
 
26
+ private static getDirectoryRoot(classModel: Type) {
27
+ // root-relative links start from the root by using a leading '/'
28
+ if (Settings.getInstance().typeTranspiler.getLinkingStrategy() === 'root-relative') {
29
+ return `/${this.getSanitizedGroup(classModel)}/`;
30
+ }
31
+
32
+ // path-relative links traverse the directory structure
33
+ const typeBeingProcessed = State.getInstance().getTypeBeingProcessed();
34
+ if (typeBeingProcessed) {
35
+ if (this.getClassGroup(typeBeingProcessed) === this.getClassGroup(classModel)) {
36
+ // If the types the same groups then we simply link directly to that file
37
+ return './';
38
+ } else {
39
+ // If the types have different groups then we have to go up a directory
40
+ return `../${this.getSanitizedGroup(classModel)}/`;
41
+ }
42
+ } else {
43
+ // If nothing is being processed then we assume we are at the root and links should include the groups
44
+ return `./${this.getSanitizedGroup(classModel)}/`;
45
+ }
46
+ }
47
+
23
48
  private static getClassGroup(classModel: Type): string {
24
- const groupAnnotation = classModel.docComment?.annotations.find((annotation) => annotation.name === 'group');
25
- return groupAnnotation?.body ?? 'Misc';
49
+ const groupAnnotation = classModel.docComment?.annotations.find(
50
+ (annotation) => annotation.name.toLowerCase() === 'group',
51
+ );
52
+ return groupAnnotation?.body ?? Settings.getInstance().getDefaultGroupName();
26
53
  }
27
54
  }
@@ -1,7 +1,12 @@
1
1
  import { MarkdownTranspilerBase } from '../markdown-transpiler-base';
2
+ import { LinkingStrategy } from '../../processor-type-transpiler';
2
3
 
3
4
  export default class DocsifyDocsProcessor extends MarkdownTranspilerBase {
4
5
  homeFileName(): string {
5
6
  return 'README';
6
7
  }
8
+
9
+ getLinkingStrategy(): LinkingStrategy {
10
+ return 'root-relative';
11
+ }
7
12
  }
@@ -2,6 +2,7 @@ import { MarkdownTranspilerBase } from '../markdown-transpiler-base';
2
2
  import { Type } from '@cparra/apex-reflection';
3
3
  import { MarkdownHomeFile } from '../../../model/markdown-home-file';
4
4
  import { MarkdownTypeFile } from '../../../model/markdown-type-file';
5
+ import { LinkingStrategy } from '../../processor-type-transpiler';
5
6
 
6
7
  export class JekyllDocsProcessor extends MarkdownTranspilerBase {
7
8
  homeFileName(): string {
@@ -19,4 +20,8 @@ export class JekyllDocsProcessor extends MarkdownTranspilerBase {
19
20
  get frontMatterHeader(): string {
20
21
  return '---\nlayout: default\n---';
21
22
  }
23
+
24
+ getLinkingStrategy(): LinkingStrategy {
25
+ return 'path-relative';
26
+ }
22
27
  }
@@ -0,0 +1,12 @@
1
+ import { MarkdownTranspilerBase } from '../markdown-transpiler-base';
2
+ import { LinkingStrategy } from '../../processor-type-transpiler';
3
+
4
+ export class PlainMarkdownDocsProcessor extends MarkdownTranspilerBase {
5
+ homeFileName(): string {
6
+ return 'index';
7
+ }
8
+
9
+ getLinkingStrategy(): LinkingStrategy {
10
+ return 'path-relative';
11
+ }
12
+ }
@@ -1,6 +1,8 @@
1
1
  import { Type } from '@cparra/apex-reflection';
2
2
  import { FileContainer } from './file-container';
3
3
 
4
+ export type LinkingStrategy = 'root-relative' | 'path-relative';
5
+
4
6
  export default abstract class ProcessorTypeTranspiler {
5
7
  onBeforeProcess: ((types: Type[]) => void) | undefined;
6
8
 
@@ -9,4 +11,6 @@ export default abstract class ProcessorTypeTranspiler {
9
11
  onAfterProcess: ((types: Type[]) => void) | undefined;
10
12
 
11
13
  abstract fileBuilder(): FileContainer;
14
+
15
+ abstract getLinkingStrategy(): LinkingStrategy;
12
16
  }
@@ -1,6 +1,7 @@
1
1
  import { Type } from '@cparra/apex-reflection';
2
2
  import ProcessorTypeTranspiler from './processor-type-transpiler';
3
3
  import { Settings } from '../settings';
4
+ import State from '../service/state';
4
5
 
5
6
  export default class Transpiler {
6
7
  static generate(types: Type[], processor: ProcessorTypeTranspiler): void {
@@ -17,6 +18,7 @@ export default class Transpiler {
17
18
  }
18
19
 
19
20
  sortedTypes.forEach((currentType) => {
21
+ State.getInstance().setTypeBeingProcessed(currentType);
20
22
  processor.onProcess(currentType);
21
23
  });
22
24
  processor.onAfterProcess?.(sortedTypes);
@@ -1,168 +0,0 @@
1
- # SampleClass
2
-
3
- `NAMESPACEACCESSIBLE`
4
-
5
- `APIVERSION: 54`
6
-
7
- `STATUS: ACTIVE`
8
-
9
- Something
10
-
11
- ## Constructors
12
- ### My Super Group
13
- ##### `SampleClass()`
14
-
15
- `NAMESPACEACCESSIBLE`
16
-
17
- Constructs a SampleClass without any arguments. This relates to [SampleInterface](/Sample-Interfaces/SampleInterface.md)
18
-
19
- ###### Throws
20
- |Exception|Description|
21
- |---|---|
22
- |`ExcName`|some exception|
23
-
24
-
25
- **CustomAnnotation** A Custom method annotation
26
-
27
-
28
- **See** [SampleInterface](/Sample-Interfaces/SampleInterface.md)
29
-
30
- ###### Example
31
- ```apex
32
- // Example
33
- SampleClass sampleInstance = new SampleClass();
34
- ```
35
-
36
- ---
37
- ### Other
38
- ##### `SampleClass(String argument1, String argument2)`
39
-
40
- Constructs a SampleClass with an argument.
41
-
42
- ###### Parameters
43
- |Param|Description|
44
- |---|---|
45
- |`argument1`|Argument1 definition|
46
- |`argument2`|Argument2 definition|
47
-
48
- ---
49
- ## Fields
50
- ### Common Constants
51
-
52
- * `ANOTHER_CONSTANT` → `String`
53
- * `A_CONSTANT` → `String` [`NAMESPACEACCESSIBLE` ] - This is a constant.
54
- ---
55
- ### Other variables
56
-
57
- * `someVariable` → `String`
58
- ---
59
- ## Properties
60
-
61
- ### `AnotherProp` → `Decimal`
62
-
63
- `AURAENABLED`
64
-
65
- This is a Decimal property.
66
-
67
- ### `MyProp` → `String`
68
-
69
- `AURAENABLED`
70
- `DEPRECATED`
71
-
72
- This is a String property.
73
-
74
- ---
75
- ## Methods
76
- ### `static sampleMethod(String argument1, String argument2)`
77
-
78
- `NAMESPACEACCESSIBLE`
79
-
80
- Executes commands based on the passed in argument.
81
-
82
- #### Parameters
83
- |Param|Description|
84
- |---|---|
85
- |`argument1`|Argument1 to debug|
86
- |`argument2`|Argument2 to debug|
87
-
88
- #### Return
89
-
90
- **Type**
91
-
92
- String
93
-
94
- **Description**
95
-
96
- Empty string
97
-
98
- #### Example
99
- ```apex
100
- String result = SampleClass.testMethod();
101
- System.debug(result);
102
- ```
103
-
104
- ### `static anotherSampleMethod(String arg1)`
105
-
106
- Something here
107
-
108
- #### Parameters
109
- |Param|Description|
110
- |---|---|
111
-
112
-
113
- **Arg1** The arg1 description
114
-
115
- ### `static call()`
116
-
117
- Calls the method. This methods allows you to call it.
118
-
119
- ---
120
- ## Enums
121
- ### InnerEnum
122
-
123
- `NAMESPACEACCESSIBLE`
124
-
125
- This is a namespace accessible enum
126
-
127
-
128
- ---
129
- ## Classes
130
- ### AnotherInnerClass
131
-
132
- Inner class belonging to SampleClass.
133
-
134
- #### Properties
135
-
136
- ##### `InnerProp` → `String`
137
-
138
-
139
- Description of the inner property.
140
-
141
- ---
142
- #### Methods
143
- ##### `innerMethod()`
144
-
145
- Executes from the inner class.
146
-
147
- ---
148
-
149
- ### InnerClass
150
-
151
- Inner class belonging to SampleClass.
152
-
153
- #### Properties
154
-
155
- ##### `InnerProp` → `String`
156
-
157
-
158
- Description of the inner property.
159
-
160
- ---
161
- #### Methods
162
- ##### `innerMethod()`
163
-
164
- Executes from the inner class.
165
-
166
- ---
167
-
168
- ---