@cparra/apexdocs 2.19.0-alpha.3 → 2.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,14 +25,11 @@ There are some key differences between ApexDocs and the Java based ApexDoc tool:
25
25
  Markdown like Github Pages or Netlify, and use site generators like Jekyll or Gatsby. This gives you the freedom to
26
26
  decide how to style your site to match your needs.
27
27
 
28
- #### New features
29
-
30
- * All Apex annotations are now supported through the `--scope` CLI parameter, not just `namespaceaccessible`. This means
31
- that scopes like `auraenabled`, `invocablemethod`, `invocablevariable`, `remoteaction`, and all other valid Apex
32
- annotations are supported.
33
- * Just like Javadoc, both `@throws` and `@exception` are supported when referencing an exception thrown by a method or
34
- constructor.
35
- * Any custom annotation defined in the Apexdoc is at the class level are supported, for example the following will be
28
+ #### Features
29
+
30
+ * Custom Annotations
31
+
32
+ Any custom annotation defined in the Apexdoc is at the class level are supported, for example the following will be
36
33
  output to the resulting markdown file:
37
34
 
38
35
  ```apex
@@ -43,7 +40,7 @@ public class MyClass {
43
40
  }
44
41
  ```
45
42
 
46
- * Apex docs blocks can now all be in a single line
43
+ * Single Line ApexDoc Blocks
47
44
 
48
45
  📒 Note: If you wish to have multiple `@` tags in a single line but don't want them to be treated as ApexDoc annotations, you can
49
46
  escape them by adding wrapping the annotation in ticks, for example
@@ -59,6 +56,7 @@ escape them by adding wrapping the annotation in ticks, for example
59
56
  * OpenApi REST specification generation
60
57
  * Support for ignoring files and members from being documented
61
58
  * Namespace support
59
+ * Configuration file support
62
60
  * And much, much more!
63
61
 
64
62
  ### Demo
@@ -120,6 +118,44 @@ The CLI supports the following parameters:
120
118
  | --includeMetadata | N/A | Whether to include the file's meta.xml information: Whether it is active and and the API version | false | No |
121
119
  | --documentationRootDir | N/A | The root directory where the documentation will be generated. This is useful when you want to generate the documentation in a subdirectory of your project. | N/A | No |
122
120
 
121
+ ### Using a configuration file
122
+
123
+ You can also use a configuration file to define the parameters that will be used when generating the documentation. Apexdocs
124
+ uses [cosmiconfig](https://www.npmjs.com/package/cosmiconfig) to load the configuration file, which means it supports
125
+ the following formats:
126
+
127
+ - A `package.json` property, e.g. `{ "apexdocs": { "sourceDir": "src", "targetDir": "docs" } }`
128
+ - A `.apexdocsrc` file, written in YAML or JSON, with optional extensions: `.yaml/.yml/.json/.js`
129
+ - An `apexdocs.config.js` file that exports an object
130
+ - A `apexdocs.config.ts` file that exports an object
131
+
132
+ The configuration file should be placed in the root directory of your project.
133
+
134
+ **Note that when using a configuration file, you can still override any of the parameters by passing them through the CLI.**
135
+
136
+ When defining a `.js` or `.ts` configuration file, your object export can also contain the following functions that will
137
+ allow you to override some of the default behavior:
138
+
139
+ - `onBeforeFileWrite` - A function that will be called before a file is written to disk. It receives a `TargetFile` object
140
+ that contains the file's content, path, and name, etc. It should return a `TargetFile` object with the updated content.
141
+ The full object definition can be imported from `@cparra/apexdocs/lib/settings`
142
+ - `onAfterProcess` - A function that will be called after all files have been processed. It receives a `TargetFile[]` array
143
+ with all of the files that were processed and does not return anything.
144
+
145
+ ```typescript
146
+ import {TargetFile} from "@cparra/apexdocs/lib/settings";
147
+ export default {
148
+ onBeforeFileWrite: (file: TargetFile): TargetFile => {
149
+ console.log('onBefore writing', file);
150
+ return file;
151
+ },
152
+ onAfterProcess: (files: TargetFile[]) => {
153
+ console.log('onAfterProcess files', files);
154
+ },
155
+ };
156
+
157
+ ```
158
+
123
159
  ### Importing to your project
124
160
 
125
161
  If you are just interested in the Apex parsing capabilities, you can use the
@@ -1,17 +1,11 @@
1
- import * as path from 'path';
2
-
3
- type OutputDir = {
4
- baseDir: string;
5
- fileDir: string;
6
- };
1
+ import { TargetFile } from './src/settings';
7
2
 
8
3
  export default {
9
- onBeforeFileWrite: (dir: OutputDir, fileName: string) => {
10
- console.log('onBefore writing', dir, fileName);
11
- const defaultDir = path.join(dir.baseDir, dir.fileDir);
12
- return { dir: defaultDir, fileName };
4
+ onBeforeFileWrite: (file: TargetFile): TargetFile => {
5
+ console.log('onBefore writing', file);
6
+ return file;
13
7
  },
14
- onAfterProcess: (files: { dir: string; fileName: string }[]) => {
8
+ onAfterProcess: (files: TargetFile[]) => {
15
9
  console.log('onAfterProcess files', files);
16
10
  },
17
11
  };
@@ -30,12 +30,12 @@ class Apexdocs {
30
30
  const processor = factory_1.TypeTranspilerFactory.get(settings_1.Settings.getInstance().targetGenerator);
31
31
  transpiler_1.default.generate(filteredTypes, processor);
32
32
  const generatedFiles = processor.fileBuilder().files();
33
- const generatedFilePaths = [];
33
+ const files = [];
34
34
  file_writer_1.FileWriter.write(generatedFiles, (file) => {
35
- logger_1.Logger.logSingle(`${file.fileName} processed.`, false, 'green', false);
36
- generatedFilePaths.push(file);
35
+ logger_1.Logger.logSingle(`${file.name} processed.`, false, 'green', false);
36
+ files.push(file);
37
37
  });
38
- settings_1.Settings.getInstance().onAfterProcess(generatedFilePaths);
38
+ settings_1.Settings.getInstance().onAfterProcess(files);
39
39
  // Error logging
40
40
  error_logger_1.default.logErrors(filteredTypes);
41
41
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Apexdocs.js","sourceRoot":"","sources":["../../src/application/Apexdocs.ts"],"names":[],"mappings":";;;AAAA,kEAA6D;AAC7D,wDAA2D;AAC3D,6DAA0E;AAC1E,2CAAwC;AACxC,kEAA6D;AAC7D,8CAAkD;AAClD,0CAAuC;AACvC,yDAAkD;AAClD,wDAAoD;AACpD,uDAA+C;AAG/C,gEAA4D;AAC5D,mDAA8D;AAE9D;;GAEG;AACH,MAAa,QAAQ;IACnB;;OAEG;IACH,MAAM,CAAC,QAAQ;QACb,eAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAC9B,MAAM,UAAU,GAAG,iCAAc,CAAC,YAAY,CAAC,IAAI,+BAAiB,EAAE,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,IAAA,iCAAc,EAAC,IAAI,sBAAa,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,qBA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EAAE,CAAC,CAAC;KACjF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { OutputFile } from '../model/outputFile';
2
- import { TargetLocation } from '../settings';
2
+ import { TargetFile } from '../settings';
3
3
  export declare class FileWriter {
4
- static write(files: OutputFile[], onWriteCallback: (file: TargetLocation) => void): void;
4
+ static write(files: OutputFile[], onWriteCallback: (file: TargetFile) => void): void;
5
5
  private static getTargetLocation;
6
6
  }
@@ -6,23 +6,28 @@ const path = require("path");
6
6
  const settings_1 = require("../settings");
7
7
  class FileWriter {
8
8
  static write(files, onWriteCallback) {
9
- const onBeforeFileWrite = (outputDir, fileName) => settings_1.Settings.getInstance().onBeforeFileWrite(outputDir, fileName);
9
+ const onBeforeFileWrite = (file) => settings_1.Settings.getInstance().onBeforeFileWrite(file);
10
10
  files.forEach((file) => {
11
- const { dir: dirPath, fileName } = this.getTargetLocation(file, onBeforeFileWrite);
12
- if (!fs.existsSync(dirPath)) {
13
- fs.mkdirSync(dirPath, { recursive: true });
11
+ const resolvedFile = this.getTargetLocation(file, onBeforeFileWrite);
12
+ const fullDir = path.join(resolvedFile.dir.baseDir, resolvedFile.dir.fileDir);
13
+ if (!fs.existsSync(fullDir)) {
14
+ fs.mkdirSync(fullDir, { recursive: true });
14
15
  }
15
- const filePath = path.join(dirPath, fileName);
16
+ const filePath = path.join(fullDir, `${resolvedFile.name}${resolvedFile.extension}`);
16
17
  fs.writeFileSync(filePath, file.body, 'utf8');
17
- onWriteCallback({ dir: dirPath, fileName });
18
+ onWriteCallback(resolvedFile);
18
19
  });
19
20
  }
20
21
  static getTargetLocation(file, onBeforeFileWrite) {
21
- const fileName = `${file.fileName}${file.fileExtension()}`;
22
- return onBeforeFileWrite({
23
- baseDir: settings_1.Settings.getInstance().outputDir,
24
- fileDir: file.dir,
25
- }, fileName);
22
+ const targetFile = {
23
+ name: file.fileName,
24
+ extension: file.fileExtension(),
25
+ dir: {
26
+ baseDir: settings_1.Settings.getInstance().outputDir,
27
+ fileDir: file.dir,
28
+ },
29
+ };
30
+ return onBeforeFileWrite(targetFile);
26
31
  }
27
32
  }
28
33
  exports.FileWriter = FileWriter;
@@ -1 +1 @@
1
- {"version":3,"file":"file-writer.js","sourceRoot":"","sources":["../../src/service/file-writer.ts"],"names":[],"mappings":";;;AAAA,yBAAyB;AACzB,6BAA6B;AAE7B,0CAAqF;AAErF,MAAa,UAAU;IACrB,MAAM,CAAC,KAAK,CAAC,KAAmB,EAAE,eAA+C;QAC/E,MAAM,iBAAiB,GAAG,CAAC,SAAoB,EAAE,QAAgB,EAAE,EAAE,CACnE,mBAAQ,CAAC,WAAW,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACrB,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;YACnF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;gBAC3B,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;aAC5C;YAED,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAC9C,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC9C,eAAe,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC9C,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,MAAM,CAAC,iBAAiB,CAAC,IAAgB,EAAE,iBAAoC;QACrF,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;QAC3D,O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AAE,iBAAoC;QACrF,MAAM,UAAU,GAAe;YAC7B,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE;YAC/B,GAAG,EAAE;gBACH,OAAO,EAAE,mBAAQ,CAAC,WAAW,EAAE,CAAC,SAAS;gBACzC,OAAO,EAAE,IAAI,CAAC,GAAG;aAClB;SACF,CAAC;QAEF,OAAO,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;CACF;AA5BD,gCA4BC"}
package/lib/settings.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { GeneratorChoices } from './transpiler/generator-choices';
2
- export type OnBeforeFileWrite = (outputDir: OutputDir, fileName: string) => TargetLocation;
3
- export type TargetLocation = {
4
- dir: string;
5
- fileName: string;
2
+ export type OnBeforeFileWrite = (file: TargetFile) => TargetFile;
3
+ export type TargetFile = {
4
+ name: string;
5
+ extension: string;
6
+ dir: OutputDir;
6
7
  };
7
8
  export type OutputDir = {
8
9
  baseDir: string;
@@ -23,14 +24,8 @@ export interface SettingsConfig {
23
24
  openApiFileName: string;
24
25
  includeMetadata: boolean;
25
26
  rootDir?: string;
26
- onAfterProcess?: (files: {
27
- dir: string;
28
- fileName: string;
29
- }[]) => void;
30
- onBeforeFileWrite?: (outputDir: OutputDir, fileName: string) => {
31
- dir: string;
32
- fileName: string;
33
- };
27
+ onAfterProcess?: (files: TargetFile[]) => void;
28
+ onBeforeFileWrite?: (file: TargetFile) => TargetFile;
34
29
  }
35
30
  export declare class Settings {
36
31
  config: SettingsConfig;
@@ -53,12 +48,6 @@ export declare class Settings {
53
48
  openApiFileName(): string;
54
49
  includeMetadata(): boolean;
55
50
  getRootDir(): string | undefined;
56
- onAfterProcess(files: {
57
- dir: string;
58
- fileName: string;
59
- }[]): void;
60
- onBeforeFileWrite(outputDir: OutputDir, fileName: string): {
61
- dir: string;
62
- fileName: string;
63
- };
51
+ onAfterProcess(files: TargetFile[]): void;
52
+ onBeforeFileWrite(file: TargetFile): TargetFile;
64
53
  }
package/lib/settings.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Settings = void 0;
4
- const path = require("path");
5
4
  class Settings {
6
5
  constructor(config) {
7
6
  this.config = config;
@@ -69,12 +68,11 @@ class Settings {
69
68
  this.config.onAfterProcess(files);
70
69
  }
71
70
  }
72
- onBeforeFileWrite(outputDir, fileName) {
71
+ onBeforeFileWrite(file) {
73
72
  if (this.config.onBeforeFileWrite) {
74
- return this.config.onBeforeFileWrite(outputDir, fileName);
73
+ return this.config.onBeforeFileWrite(file);
75
74
  }
76
- const defaultDir = path.join(outputDir.baseDir, outputDir.fileDir);
77
- return { dir: defaultDir, fileName };
75
+ return file;
78
76
  }
79
77
  }
80
78
  exports.Settings = Settings;
@@ -1 +1 @@
1
- {"version":3,"file":"settings.js","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":";;;AACA,6BAA6B;AAiC7B,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,CAA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@cparra/apexdocs",
3
- "version": "2.19.0-alpha.3",
3
+ "version": "2.19.0",
4
4
  "description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
5
5
  "keywords": [
6
6
  "apex",
@@ -4,7 +4,7 @@ import { ReflectionResult, reflect, Type } from '@cparra/apex-reflection';
4
4
  import { Logger } from '../util/logger';
5
5
  import { createManifest } from '../service/manifest-factory';
6
6
  import { RawBodyParser } from '../service/parser';
7
- import { Settings } from '../settings';
7
+ import { Settings, TargetFile } from '../settings';
8
8
  import Transpiler from '../transpiler/transpiler';
9
9
  import { FileWriter } from '../service/file-writer';
10
10
  import ErrorLogger from '../util/error-logger';
@@ -31,13 +31,13 @@ export class Apexdocs {
31
31
  Transpiler.generate(filteredTypes, processor);
32
32
  const generatedFiles = processor.fileBuilder().files();
33
33
 
34
- const generatedFilePaths: { dir: string; fileName: string }[] = [];
35
- FileWriter.write(generatedFiles, (file: { dir: string; fileName: string }) => {
36
- Logger.logSingle(`${file.fileName} processed.`, false, 'green', false);
37
- generatedFilePaths.push(file);
34
+ const files: TargetFile[] = [];
35
+ FileWriter.write(generatedFiles, (file: TargetFile) => {
36
+ Logger.logSingle(`${file.name} processed.`, false, 'green', false);
37
+ files.push(file);
38
38
  });
39
39
 
40
- Settings.getInstance().onAfterProcess(generatedFilePaths);
40
+ Settings.getInstance().onAfterProcess(files);
41
41
 
42
42
  // Error logging
43
43
  ErrorLogger.logErrors(filteredTypes);
@@ -1,32 +1,34 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
3
  import { OutputFile } from '../model/outputFile';
4
- import { OnBeforeFileWrite, OutputDir, Settings, TargetLocation } from '../settings';
4
+ import { OnBeforeFileWrite, Settings, TargetFile } from '../settings';
5
5
 
6
6
  export class FileWriter {
7
- static write(files: OutputFile[], onWriteCallback: (file: TargetLocation) => void) {
8
- const onBeforeFileWrite = (outputDir: OutputDir, fileName: string) =>
9
- Settings.getInstance().onBeforeFileWrite(outputDir, fileName);
7
+ static write(files: OutputFile[], onWriteCallback: (file: TargetFile) => void) {
8
+ const onBeforeFileWrite: OnBeforeFileWrite = (file: TargetFile) => Settings.getInstance().onBeforeFileWrite(file);
10
9
  files.forEach((file) => {
11
- const { dir: dirPath, fileName } = this.getTargetLocation(file, onBeforeFileWrite);
12
- if (!fs.existsSync(dirPath)) {
13
- fs.mkdirSync(dirPath, { recursive: true });
10
+ const resolvedFile = this.getTargetLocation(file, onBeforeFileWrite);
11
+ const fullDir = path.join(resolvedFile.dir.baseDir, resolvedFile.dir.fileDir);
12
+ if (!fs.existsSync(fullDir)) {
13
+ fs.mkdirSync(fullDir, { recursive: true });
14
14
  }
15
15
 
16
- const filePath = path.join(dirPath, fileName);
16
+ const filePath = path.join(fullDir, `${resolvedFile.name}${resolvedFile.extension}`);
17
17
  fs.writeFileSync(filePath, file.body, 'utf8');
18
- onWriteCallback({ dir: dirPath, fileName });
18
+ onWriteCallback(resolvedFile);
19
19
  });
20
20
  }
21
21
 
22
- private static getTargetLocation(file: OutputFile, onBeforeFileWrite: OnBeforeFileWrite): TargetLocation {
23
- const fileName = `${file.fileName}${file.fileExtension()}`;
24
- return onBeforeFileWrite(
25
- {
22
+ private static getTargetLocation(file: OutputFile, onBeforeFileWrite: OnBeforeFileWrite): TargetFile {
23
+ const targetFile: TargetFile = {
24
+ name: file.fileName,
25
+ extension: file.fileExtension(),
26
+ dir: {
26
27
  baseDir: Settings.getInstance().outputDir,
27
28
  fileDir: file.dir,
28
29
  },
29
- fileName,
30
- );
30
+ };
31
+
32
+ return onBeforeFileWrite(targetFile);
31
33
  }
32
34
  }
package/src/settings.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { GeneratorChoices } from './transpiler/generator-choices';
2
- import * as path from 'path';
3
2
 
4
- export type OnBeforeFileWrite = (outputDir: OutputDir, fileName: string) => TargetLocation;
3
+ export type OnBeforeFileWrite = (file: TargetFile) => TargetFile;
5
4
 
6
- export type TargetLocation = {
7
- dir: string;
8
- fileName: string;
5
+ export type TargetFile = {
6
+ name: string;
7
+ extension: string;
8
+ dir: OutputDir;
9
9
  };
10
10
 
11
11
  export type OutputDir = {
@@ -28,8 +28,8 @@ export interface SettingsConfig {
28
28
  openApiFileName: string;
29
29
  includeMetadata: boolean;
30
30
  rootDir?: string;
31
- onAfterProcess?: (files: { dir: string; fileName: string }[]) => void;
32
- onBeforeFileWrite?: (outputDir: OutputDir, fileName: string) => { dir: string; fileName: string };
31
+ onAfterProcess?: (files: TargetFile[]) => void;
32
+ onBeforeFileWrite?: (file: TargetFile) => TargetFile;
33
33
  }
34
34
 
35
35
  export class Settings {
@@ -111,17 +111,16 @@ export class Settings {
111
111
  return this.config.rootDir;
112
112
  }
113
113
 
114
- public onAfterProcess(files: { dir: string; fileName: string }[]) {
114
+ public onAfterProcess(files: TargetFile[]): void {
115
115
  if (this.config.onAfterProcess) {
116
116
  this.config.onAfterProcess(files);
117
117
  }
118
118
  }
119
119
 
120
- public onBeforeFileWrite(outputDir: OutputDir, fileName: string): { dir: string; fileName: string } {
120
+ public onBeforeFileWrite(file: TargetFile): TargetFile {
121
121
  if (this.config.onBeforeFileWrite) {
122
- return this.config.onBeforeFileWrite(outputDir, fileName);
122
+ return this.config.onBeforeFileWrite(file);
123
123
  }
124
- const defaultDir = path.join(outputDir.baseDir, outputDir.fileDir);
125
- return { dir: defaultDir, fileName };
124
+ return file;
126
125
  }
127
126
  }