@cparra/apexdocs 3.0.0-beta.1 → 3.0.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 (125) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +246 -650
  3. package/dist/cli/generate.js +74 -3095
  4. package/dist/defaults-BcE8DTat.js +13 -0
  5. package/dist/defaults-D07y_bq4.js +40 -0
  6. package/dist/defaults-gPzwP66p.js +14 -0
  7. package/dist/index.d.ts +49 -19
  8. package/dist/index.js +90 -2
  9. package/dist/logger-BEbUIfqN.js +3282 -0
  10. package/dist/logger-BGuf1PnL.js +3281 -0
  11. package/dist/logger-CWBRF2za.js +3284 -0
  12. package/dist/logger-CdBmDEN1.js +3283 -0
  13. package/dist/logger-Ce4QqPFR.js +3278 -0
  14. package/dist/logger-CyEVYaAC.js +3284 -0
  15. package/dist/logger-D7a83ycP.js +3277 -0
  16. package/dist/logger-DGaHeBKk.js +3279 -0
  17. package/dist/logger-Dqhl_lO_.js +3278 -0
  18. package/dist/logger-aySSWi0G.js +3280 -0
  19. package/dist/logger-qLCcAtiy.js +3284 -0
  20. package/examples/README.md +5 -0
  21. package/examples/docsify/README.md +17 -0
  22. package/examples/docsify/apexdocs.config.ts +13 -0
  23. package/examples/docsify/classes/ASampleClass.cls +57 -0
  24. package/examples/docsify/classes/CodeControl.cls +19 -0
  25. package/examples/docsify/classes/SampleClass.cls +95 -0
  26. package/examples/docsify/classes/SampleInterface.cls +17 -0
  27. package/examples/docsify/classes/SomeDto.cls +122 -0
  28. package/examples/docsify/docs/.nojekyll +0 -0
  29. package/examples/docsify/docs/README.md +25 -0
  30. package/examples/docsify/docs/_config.yml +1 -0
  31. package/examples/docsify/docs/index.html +22 -0
  32. package/examples/docsify/docs/miscellaneous/ASampleClass.md +88 -0
  33. package/examples/docsify/docs/miscellaneous/CodeControl.md +107 -0
  34. package/examples/docsify/docs/miscellaneous/SomeDto.md +244 -0
  35. package/examples/docsify/docs/sample-classes/SampleClass.md +171 -0
  36. package/examples/docsify/docs/sample-interfaces/SampleInterface.md +36 -0
  37. package/examples/docsify/package-lock.json +2459 -0
  38. package/examples/docsify/package.json +14 -0
  39. package/examples/imported/.forceignore +12 -0
  40. package/examples/imported/README.md +6 -0
  41. package/examples/imported/config/project-scratch-def.json +5 -0
  42. package/examples/imported/docs/index.md +109 -0
  43. package/examples/imported/docs/miscellaneous/BaseClass.md +13 -0
  44. package/examples/imported/docs/miscellaneous/MultiInheritanceClass.md +69 -0
  45. package/examples/imported/docs/miscellaneous/ParentInterface.md +12 -0
  46. package/examples/imported/docs/miscellaneous/ReferencedEnum.md +5 -0
  47. package/examples/imported/docs/miscellaneous/SampleException.md +21 -0
  48. package/examples/imported/docs/miscellaneous/SampleInterface.md +113 -0
  49. package/examples/imported/docs/miscellaneous/Url.md +308 -0
  50. package/examples/imported/docs/sample-enums/SampleEnum.md +33 -0
  51. package/examples/imported/docs/samplegroup/SampleClass.md +167 -0
  52. package/examples/imported/force-app/classes/BaseClass.cls +3 -0
  53. package/examples/imported/force-app/classes/MultiInheritanceClass.cls +1 -0
  54. package/examples/imported/force-app/classes/ParentInterface.cls +3 -0
  55. package/examples/imported/force-app/classes/ReferencedEnum.cls +3 -0
  56. package/examples/imported/force-app/classes/SampleInterface.cls +50 -0
  57. package/examples/imported/force-app/classes/Url.cls +196 -0
  58. package/examples/imported/package-lock.json +665 -0
  59. package/examples/imported/package.json +6 -0
  60. package/examples/imported/scripts/process-docs.mjs +16 -0
  61. package/examples/imported/sfdx-project.json +12 -0
  62. package/examples/markdown/README.md +7 -0
  63. package/examples/markdown/docs/miscellaneous/Url.md +10 -8
  64. package/examples/markdown/force-app/classes/Url.cls +3 -1
  65. package/examples/markdown-jsconfig/.forceignore +12 -0
  66. package/examples/markdown-jsconfig/README.md +9 -0
  67. package/examples/markdown-jsconfig/apexdocs.config.mjs +22 -0
  68. package/examples/markdown-jsconfig/config/project-scratch-def.json +5 -0
  69. package/examples/markdown-jsconfig/docs/index.md +12 -0
  70. package/examples/markdown-jsconfig/docs/miscellaneous/Url.md +315 -0
  71. package/examples/markdown-jsconfig/force-app/classes/Url.cls +196 -0
  72. package/examples/markdown-jsconfig/package-lock.json +665 -0
  73. package/examples/markdown-jsconfig/package.json +15 -0
  74. package/examples/markdown-jsconfig/sfdx-project.json +12 -0
  75. package/examples/open-api/README.md +5 -0
  76. package/examples/open-api/docs/openapi.json +2 -570
  77. package/examples/vitepress/README.md +25 -0
  78. package/examples/vitepress/apexdocs.config.ts +9 -2
  79. package/examples/vitepress/docs/index.md +11 -11
  80. package/examples/vitepress/docs/miscellaneous/BaseClass.md +1 -1
  81. package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +2 -2
  82. package/examples/vitepress/docs/miscellaneous/SampleException.md +1 -1
  83. package/examples/vitepress/docs/miscellaneous/SampleInterface.md +6 -6
  84. package/examples/vitepress/docs/miscellaneous/Url.md +3 -3
  85. package/examples/vitepress/docs/sample-enums/SampleEnum.md +3 -3
  86. package/examples/vitepress/docs/samplegroup/SampleClass.md +5 -5
  87. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleClass.cls +73 -0
  88. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleEnum.cls +30 -0
  89. package/examples/vitepress/force-app/main/default/classes/feature-a/SampleException.cls +17 -0
  90. package/package.json +3 -3
  91. package/src/application/Apexdocs.ts +16 -19
  92. package/src/application/__tests__/apex-file-reader.spec.ts +108 -67
  93. package/src/application/apex-file-reader.ts +1 -0
  94. package/src/application/generators/openapi.ts +17 -13
  95. package/src/cli/args.ts +12 -3
  96. package/src/cli/commands/markdown.ts +15 -12
  97. package/src/cli/commands/openapi.ts +5 -5
  98. package/src/cli/generate.ts +20 -4
  99. package/src/core/markdown/__test__/generating-class-docs.spec.ts +15 -386
  100. package/src/core/markdown/__test__/generating-docs.spec.ts +378 -0
  101. package/src/core/markdown/__test__/generating-enum-docs.spec.ts +4 -328
  102. package/src/core/markdown/__test__/generating-interface-docs.spec.ts +4 -296
  103. package/src/core/markdown/__test__/generating-reference-guide.spec.ts +17 -1
  104. package/src/core/markdown/__test__/test-helpers.ts +3 -1
  105. package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +3 -1
  106. package/src/core/markdown/adapters/renderable-to-page-data.ts +6 -4
  107. package/src/core/markdown/generate-docs.ts +13 -15
  108. package/src/core/markdown/reflection/__test__/filter-scope.spec.ts +290 -0
  109. package/src/core/markdown/reflection/__test__/helpers.ts +18 -0
  110. package/src/core/markdown/reflection/__test__/remove-excluded-tags.spec.ts +200 -0
  111. package/src/core/markdown/reflection/remove-excluded-tags.ts +168 -0
  112. package/src/core/markdown/reflection/{sort-members.ts → sort-types-and-members.ts} +7 -5
  113. package/src/core/markdown/templates/reference-guide.ts +2 -2
  114. package/src/core/openapi/__tests__/open-api-docs-processor.spec.ts +6 -3
  115. package/src/core/openapi/open-api-docs-processor.ts +3 -3
  116. package/src/core/openapi/parser.ts +5 -2
  117. package/src/core/shared/types.d.ts +18 -18
  118. package/src/defaults.ts +15 -3
  119. package/src/index.ts +88 -14
  120. package/src/util/error-logger.ts +36 -36
  121. package/src/util/logger.ts +18 -11
  122. /package/examples/{vitepress/force-app/main/default → imported/force-app}/classes/SampleClass.cls +0 -0
  123. /package/examples/{vitepress/force-app/main/default → imported/force-app}/classes/SampleEnum.cls +0 -0
  124. /package/examples/{vitepress/force-app/main/default → imported/force-app}/classes/SampleException.cls +0 -0
  125. /package/examples/vitepress/force-app/main/default/classes/{SampleInterface.cls → feature-a/SampleInterface.cls} +0 -0
package/README.md CHANGED
@@ -1,779 +1,375 @@
1
1
  # ApexDocs
2
2
 
3
- <p align="center">
4
- <b>ApexDocs is a Node.js library with CLI capabilities to docGenerator documentation for Salesforce Apex classes.</b>
5
- </p>
3
+ <div align="center">
4
+ <b>CLI and Node library to generate documentation for Salesforce Apex classes.</b>
6
5
 
6
+ [![CI](https://github.com/cesarParra/apexdocs/actions/workflows/ci.yaml/badge.svg)](https://github.com/cesarParra/apexdocs/actions/workflows/ci.yaml)
7
7
  [![License](https://img.shields.io/github/license/cesarParra/apexdocs)](https://github.com/cesarParra/apexdocs/blob/master/LICENSE)
8
+ [![npm](https://img.shields.io/npm/dm/@cparra/apexdocs)](https://www.npmjs.com/package/@cparra/apexdocs)
9
+ </div>
8
10
 
9
- ## Description
11
+ ApexDocs is a non-opinionated documentation generator for Salesforce Apex classes.
12
+ It can output documentation in Markdown
13
+ format,
14
+ which allows you to use the Static Site Generator of your choice to create a documentation site that fits your needs,
15
+ hosted in any static web hosting service.
10
16
 
11
- ApexDocs was originally built as an alternative to
12
- the [Java based ApexDoc tool](https://github.com/SalesforceFoundation/ApexDoc) originally created by Aslam Bari and
13
- later maintained by Salesforce.org, as that tool is no longer being maintained.
17
+ ## 💿 Installation
14
18
 
15
- ApexDocs is a Node.js library built on Typescript and hosted on [npm](https://www.npmjs.com/package/@cparra/apexdocs).
16
- It offers CLI capabilities to automatically document your source code, based on the ApexDoc style of documentation.
17
- Additionally, it can be imported and consumed directly by your JavaScript code.
18
-
19
- There are some key differences between ApexDocs and the Java based ApexDoc tool:
19
+ ```bash
20
+ npm i -g @cparra/apexdocs
21
+ ```
20
22
 
21
- - **Recursive file search through your module directory structure**. In an `sfdx` based project, all of your classes
22
- will be documented by specifying the top-most directory where file search should begin.
23
- - **Unopinionated documentation site generation**. Instead of creating HTML files, ApexDocs generates a Markdown (.md)
24
- file per Apex class being documented. This means you can host your files in static web hosting services that parse
25
- Markdown like Github Pages or Netlify, and use site generators like Jekyll or Gatsby. This gives you the freedom to
26
- decide how to style your site to match your needs.
23
+ ## Quick Start
27
24
 
28
- #### Features
25
+ ### CLI
29
26
 
30
- * Custom Annotations
27
+ #### Markdown
31
28
 
32
- Any custom annotation defined in the Apexdoc is at the class level are supported, for example the following will be
33
- output to the resulting markdown file:
29
+ Run the following command to generate markdown files for your global Salesforce Apex classes:
34
30
 
35
- ```apex
36
- /**
37
- * @MyCustomAnnotation This is a custom annotation
38
- */
39
- public class MyClass {
40
- }
31
+ ```bash
32
+ apexdocs markdown -s force-app
41
33
  ```
42
34
 
43
- * Single Line ApexDoc Blocks
35
+ #### OpenApi
44
36
 
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
46
- escape them by adding wrapping the annotation in ticks, for example
37
+ Run the following command to generate an OpenApi REST specification for your Salesforce Apex classes
38
+ annotated with `@RestResource`:
47
39
 
48
- ```apex
49
- /**
50
- * @MyCustomAnnotation This is a custom annotation with an `@embedded` annotation
51
- */
40
+ ```bash
41
+ apexdocs openapi -s force-app
52
42
  ```
53
43
 
44
+ ## 🚀 Features
45
+
46
+ * Generate documentation for Salesforce Apex classes as Markdown files
47
+ * Generate an OpenApi REST specification based on `@RestResource` classes
54
48
  * Support for grouping blocks of related code within a class
55
- * Support for HTML tags
56
- * OpenApi REST specification generation
57
49
  * Support for ignoring files and members from being documented
58
50
  * Namespace support
59
51
  * Configuration file support
52
+ * Single line ApexDoc Blocks
53
+ * Custom tag support
60
54
  * And much, much more!
61
55
 
62
- ### Demo
56
+ ## 👀 Demo
63
57
 
64
- ApexDocs currently supports generating markdown files for Jekyll and Docsify sites, as well as generating plain markdown
65
- files.
58
+ ApexDocs generates Markdown files, which can be integrated into any Static Site Generation engine,
59
+ (e.g. Jekyll, Vitepress, Hugo, Docosaurus, etc.) to create a documentation site that fits your needs.
66
60
 
67
- ### In the wild
68
-
69
- - [Expression](https://cesarparra.github.io/expression/)
70
- - [Nimble AMS Docs](https://nimbleuser.github.io/nams-api-docs/#/api-reference/)
71
- - [Yet Another Salesforce Logger](https://cesarparra.github.io/yet-another-salesforce-logger/#/)
72
-
73
- ### [Docsify](https://docsify.js.org/)
74
-
75
- Demo
61
+ This repo contains several example implementations in the `examples` directory, showcasing how to integrate
62
+ with some of these tools.
76
63
 
77
- - [Docsify](https://cesarparra.github.io/apexdocs/)
64
+ * [Examples](./examples)
78
65
 
79
- ### [Jekyll](https://jekyllrb.com/)
80
-
81
- Demo
82
-
83
- - [Jekyll](https://cesarparra.github.io/apexdocs-docsify-example/)
66
+ ### In the wild
84
67
 
85
- ## Installation
68
+ Here are some live projects using ApexDocs:
86
69
 
87
- ```bash
88
- npm i -g @cparra/apexdocs
89
- ```
70
+ - [Trailhead Apex Recipes](https://github.com/trailheadapps/apex-recipes)
71
+ - [Salesforce Commerce Apex Reference](https://developer.salesforce.com/docs/commerce/salesforce-commerce/references/comm-apex-reference/cart-reference.html)
72
+ - [Expression (API)](https://cesarparra.github.io/expression/)
73
+ - [Nimble AMS Docs](https://nimbleuser.github.io/nams-api-docs/#/api-reference/)
90
74
 
91
- ## Usage
75
+ ## ▶️ Available Commands
92
76
 
93
- ### CLI
77
+ `markdown`
94
78
 
95
- ```bash
96
- apexdocs-generate
97
- -s src
98
- -t docs
99
- -p global
100
- -g docsify
101
- ```
79
+ ### Flags
102
80
 
103
- The CLI supports the following parameters:
104
-
105
- | Parameter | Alias | Description | Default | Required |
106
- |-----------------------------|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|----------|
107
- | --sourceDir | -s | The directory location which contains your apex .cls classes. | N/A | Yes |
108
- | --targetDir | -t | The directory location where documentation will be generated to. | `docs` | No |
109
- | --recursive | -r | Whether .cls classes will be searched for recursively in the directory provided. | `true` | No |
110
- | --scope | -p | A list of scopes to document. Values should be separated by a space, e.g --scope public private. Note that this setting is ignored if generating an OpenApi REST specification since that looks for classes annotated with @RestResource. | `global` | No |
111
- | --targetGenerator | -g | Define the static file generator for which the documents will be created. Currently supports: `jekyll`, `docsify`, `plain-markdown`, and `openapi`. | `jekyll` | No |
112
- | --indexOnly | N/A | Defines whether only the index file should be generated. | `false` | No |
113
- | --defaultGroupName | N/A | Defines the `@group` name to be used when a file does not specify it. | `Miscellaneous` | No |
114
- | --sanitizeHtml | N/A | When on, any special character within your ApexDocs is converted into its HTML code representation. This is specially useful when generic objects are described within the docs, e.g. "List< Foo>", "Map<Foo, Bar>" because otherwise the content within < and > would be treated as HTML tags and not shown in the output. Content in @example blocks are never sanitized. | true | No |
115
- | --openApiTitle | N/A | If using "openapi" as the target generator, this allows you to specify the OpenApi title value. | `Apex REST Api` | No |
116
- | --title | N/A | Allows you to specify the home page main title. If using "openapi" this acts as an alias to the openApiTitle parameter | `Classes` | No |
117
- | --namespace | N/A | The package namespace, if any. If this value is provided the namespace will be added as a prefix to all of the parsed files. If generating an OpenApi definition, it will be added to the file's Server Url. | N/A | No |
118
- | --openApiFileName | N/A | If using "openapi" as the target generator, this allows you to specify the name of the output file. | `openapi` | No |
119
- | --sortMembersAlphabetically | N/A | Whether to sort the members of a class alphabetically. | `false` | No |
120
- | --includeMetadata | N/A | Whether to include the file's meta.xml information: Whether it is active and and the API version | false | No |
121
- | --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
-
123
- ### Using a configuration file
124
-
125
- You can also use a configuration file to define the parameters that will be used when generating the documentation. Apexdocs
126
- uses [cosmiconfig](https://www.npmjs.com/package/cosmiconfig) to load the configuration file, which means it supports
127
- the following formats:
81
+ | Flag | Alias | Description | Default | Required |
82
+ |------------------------|-------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------|----------|
83
+ | `--sourceDir` | `-s` | The directory where the source files are located. | N/A | Yes |
84
+ | `--targetDir` | `-t` | The directory where the generated files will be placed. | `docs` | No |
85
+ | `--scope` | `-p` | A list of scopes to document. Values should be separated by a space, e.g --scope global public namespaceaccessible. | `global` | No |
86
+ | `--defaultGroupName` | N/A | The default group name to use when a group is not specified. | `Miscellaneous` | No |
87
+ | `--namespace` | N/A | The package namespace, if any. If provided, it will be added to the generated files. | N/A | No |
88
+ | `--sortAlphabetically` | N/A | Sorts files appearing in the Reference Guide alphabetically, as well as the members of a class, interface or enum alphabetically. If false, the members will be displayed in the same order as the code. | `false` | No |
89
+ | `--includeMetadata ` | N/A | Whether to include the file's meta.xml information: Whether it is active and and the API version | `false` | No |
90
+ | `--linkingStrategy` | N/A | The strategy to use when linking to other classes. Possible values are `relative`, `no-link`, and `none` | `relative` | No |
128
91
 
129
- - A `package.json` property, e.g. `{ "apexdocs": { "sourceDir": "src", "targetDir": "docs" } }`
130
- - A `.apexdocsrc` file, written in YAML or JSON, with optional extensions: `.yaml/.yml/.json/.js`
131
- - An `apexdocs.config.js` file that exports an object
132
- - A `apexdocs.config.ts` file that exports an object
92
+ #### Linking Strategy
133
93
 
134
- The configuration file should be placed in the root directory of your project.
135
-
136
- **Note that when using a configuration file, you can still override any of the parameters by passing them through the CLI.**
137
-
138
- When defining a `.js` or `.ts` configuration file, your object export can also contain the following functions that will
139
- allow you to override some of the default behavior:
140
-
141
- - `onBeforeFileWrite` - A function that will be called before a file is written to disk. It receives a `TargetFile` object
142
- that contains the file's content, path, and name, etc. It should return a `TargetFile` object with the updated content.
143
- The full object definition can be imported from `@cparra/apexdocs/lib/settings`
144
- - `onAfterProcess` - A function that will be called after all files have been processed. It receives a `TargetFile[]` array
145
- with all of the files that were processed and does not return anything.
146
- - `frontMatterHeader` - A function that will be called before the front matter is written to the file (when using the Jekyll generator).
147
- It receives a `TargetType` object
148
- and should return a list of strings that will be written to the file as the front matter.
149
- The full object definition can be imported from `@cparra/apexdocs/lib/settings`
150
- and contains the following properties:
151
- - `name` - The name of the type
152
- - `typeName` - Can be 'class', 'interface', or 'enum'
153
- - `accessModifier` - The access modifier of the type
154
- - `group` - The group to which the type belongs (if any)
155
- - `description` - The description of the type as defined in the ApexDoc
94
+ The linking strategy determines how ApexDocs will link to other classes in your documentation. For example,
95
+ if I have class `A` that links through class `B` (e.g. through an `{@link B}` tag, the `@see` tag,
96
+ takes it as a param, returns it from a method, etc.), the linking strategy will determine how the link to class `B` is
97
+ created.
156
98
 
157
- ```typescript
158
- import {TargetFile} from "@cparra/apexdocs/lib/settings";
159
- export default {
160
- onBeforeFileWrite: (file: TargetFile): TargetFile => {
161
- console.log('onBefore writing', file);
162
- return file;
163
- },
164
- onAfterProcess: (files: TargetFile[]) => {
165
- console.log('onAfterProcess files', files);
166
- },
167
- };
168
-
169
- ```
99
+ These are the possible values for the `linkingStrategy` flag:
170
100
 
171
- ### Importing to your project
101
+ - `relative`
172
102
 
173
- If you are just interested in the Apex parsing capabilities, you can use the
174
- standalone [Apex Reflection Library](https://www.npmjs.com/package/@cparra/apex-reflection)
175
- which is what gets used by this library behind the scenes to generate the documentation files.
103
+ Create a relative link to the class file.
104
+ So if both classes are in the same directory, the link will be created as
105
+ `[B](B.md)`.
106
+ If the classes are in different directories, the link will be created as `[B](../path/to/B.md)`
176
107
 
177
- ## Documentation Format
108
+ - `no-link`
178
109
 
179
- ApexDocs picks up blocks of comments throughout your `.cls` files. The block must begin with `/**` and end with `*/`.
110
+ Does not create a link at all. The class name will be displayed as plain text.
180
111
 
181
- ### Documenting Classes and Interfaces
112
+ - `none`
182
113
 
183
- The following tags are supported at the class or interface level:
114
+ Does not apply any kind of logic. Instead, the links will be determined by the path to the file
115
+ from the root of the documentation site OR by whatever path you have returned in the `transformReference` hook
116
+ for the file.
184
117
 
185
- **Note** Any custom generated tag is also supported. Custom tags can be added with at symbol (`@`) followed by the name
186
- of the tag. For example `@custom-tag`
118
+ ### Sample Usage
187
119
 
188
- | Tag | Description |
189
- |----------------|------------------------------------------|
190
- | `@description` | One or more lines describing the class. |
191
- | `@see` | The name of a related class. |
192
- | `@group` | The group to which the class belongs to. |
193
- | `@author` | The author of the class. |
194
- | `@date` | The date the class was created. |
195
-
196
- **Example**
197
-
198
- ```apex
199
- /**
200
- * @description This is my class description.
201
- */
202
- public with sharing class TestClass {
203
- }
120
+ ```bash
121
+ apexdocs markdown -s force-app -t docs -p global public namespaceaccessible -n MyNamespace
204
122
  ```
205
123
 
206
- ### Documenting Enums
124
+ `openapi`
207
125
 
208
- The following tags are supported on the enum level:
126
+ ### Flags
209
127
 
210
- | Tag | Description |
211
- |----------------|--------------------------------------------------|
212
- | `@description` | One or more lines describing the enum. |
213
- | `@see` | The name of a related class, enum, or interface. |
214
- | `@group` | The group to which the enum belongs to. |
215
- | `@author` | The author of the enum. |
216
- | `@date` | The date the enum was created. |
128
+ | Flag | Alias | Description | Default | Required |
129
+ |----------------|-------|-------------------------------------------------------------------------------|-----------------|----------|
130
+ | `--sourceDir` | `-s` | The directory where the source files are located. | N/A | Yes |
131
+ | `--targetDir` | `-t` | The directory where the generated files will be placed. | `docs` | No |
132
+ | `--fileName` | N/A | The name of the OpenApi file. | `openapi.json` | No |
133
+ | `--namespace` | N/A | The package namespace, if any. This will be added to the API file Server Url. | N/A | No |
134
+ | `--title` | N/A | The title of the OpenApi file. | `Apex REST API` | No |
135
+ | `--apiVersion` | N/A | The version of the API. | `1.0.0` | No |
217
136
 
218
- **Example**
137
+ ### Sample Usage
219
138
 
220
- ```apex
221
- /**
222
- * @description This is my enum description.
223
- */
224
- public Enum ExampleEnum {
225
- VALUE_1, VALUE_2
226
- }
139
+ ```bash
140
+ apexdocs openapi -s force-app -t docs -n MyNamespace --title "My Custom OpenApi Title"
227
141
  ```
228
142
 
229
- ### Documenting Enum Values
143
+ ## 🔬 Defining a configuration file
230
144
 
231
- The following tags are supported on the enum value level:
145
+ You can also use a configuration file to define the parameters that will be used when generating the documentation.
232
146
 
233
- | Tag | Description |
234
- |----------------|-----------------------------------------|
235
- | `@description` | One or more lines describing the value. |
147
+ Configuration files are the main way to integrate the generated documentation with the Static Site Generator of your
148
+ choice and your build process, as well as configuring any custom behavior and the output of the generated files.
236
149
 
237
- **Example**
150
+ ### Overview
238
151
 
239
- ```apex
240
- public enum ExampleEnum {
241
- /** @description This is my enum value description. */
242
- VALUE_1,
243
- /** @description This is my other enum value description. */
244
- VALUE_2
245
- }
246
- ```
152
+ Apexdocs uses [cosmiconfig](https://www.npmjs.com/package/cosmiconfig) to load the configuration file, which means it
153
+ supports the following formats (plus anything else supported by cosmiconfig):
247
154
 
248
- ### Documenting Properties
155
+ - A `package.json` property, e.g. `{ "apexdocs": { "sourceDir": "src", "targetDir": "docs" } }`
156
+ - A `.apexdocsrc` file, written in YAML or JSON, with optional extensions: `.yaml/.yml/.json/.js`
157
+ - An `apexdocs.config.js` (or `.mjs`) file that exports an object
158
+ - A `apexdocs.config.ts` file that exports an object
249
159
 
250
- The following tags are supported on the property level:
160
+ **The configuration file should be placed in the root directory of your project.**
251
161
 
252
- | Tag | Description |
253
- |----------------|--------------------------------------------|
254
- | `@description` | One or more lines describing the property. |
162
+ **Note that when using a configuration file, you can still override any of the parameters by passing them through the
163
+ CLI.**
255
164
 
256
- **Example**
165
+ ### Configuration file
257
166
 
258
- ```apex
259
- /**
260
- * @description This is my property description.
261
- */
262
- public String ExampleProperty { get; set; }
263
- ```
167
+ When defining a configuration file, it is recommended to use ES modules syntax. The config file should `default`
168
+ export an object with the parameters you want to use.:
264
169
 
265
- ### Documenting Methods and Constructors
266
-
267
- Methods and constructors support the same tags.
268
-
269
- The following tags are supported on the method level:
270
-
271
- | Tag | Description |
272
- |------------------------------|---------------------------------------------------|
273
- | `@description` | One or more lines describing the method. |
274
- | `@param` _paramName_ | Description of a single parameter. |
275
- | `@return` | Description of the return value of the method. |
276
- | `@example` | Example of how the code can be used or called. |
277
- | `@throws` _ExceptionName_ | Description of an exception thrown by the method. |
278
- | `@exception` _ExceptionName_ | Same as `@throws`. V2 only |
279
- | `@mermaid` | Diagrams in Mermaid format. |
280
-
281
- **Example**
282
-
283
- ```apex
284
- /**
285
- * @description This is my method description.
286
- * @param action The action to execute.
287
- * @return The result of the operation.
288
- * @example
289
- * Object result = SampleClass.call('exampleAction');
290
- */
291
- public static Object call(String action) {
170
+ ```javascript
171
+ export default {
172
+ sourceDir: 'force-app',
173
+ targetDir: 'docs',
174
+ scope: ['global', 'public'],
175
+ ...
292
176
  }
293
177
  ```
294
178
 
295
- ### Using custom tags
179
+ Every property in the configuration file is optional, and if not provided, either the value provided through the
180
+ CLI will be used, or the default value will be used.
296
181
 
297
- You can use custom tags to document your code. Custom tags can be added with at symbol (`@`) followed by the name
298
- of the tag. Apexdocs will automatically format tags which words are separated by a dash (`-`) by separating them with a
299
- space and uppercasing them. For example, `@custom-tag` will be displayed as `Custom Tag`.
182
+ ### Config Intellisense
300
183
 
301
- Within a custom tag, you can also add code blocks by using the triple backtick syntax. This is useful when you want to
302
- display code snippets within your documentation.
184
+ Using the `defineMarkdownConfig` (or the `defineOpenApiConfig` for OpenApi documentation)
185
+ helper will provide Typescript-powered intellisense
186
+ for the configuration file options. This should work with both Javascript and Typescript files.
303
187
 
304
- **Example**
305
-
306
- ```apex
307
- /**
308
- * @custom-tag This is a custom tag
309
- * @custom-tag-with-code
310
- * ```
311
- * System.debug('Hello World');
312
- * ```
313
- */
314
- public class MyClass {
315
- }
316
- ```
317
-
318
- Note that the language of the code block will be set to `apex` by default, but you can change it by adding the language
319
- name after the triple backticks. For example, to display a JavaScript code block you can use:
320
-
321
- ```apex
322
- /**
323
- * @custom-tag-with-code
324
- * ```javascript
325
- * console.log('Hello World');
326
- * ```
327
- */
328
- public class MyClass {
329
- }
188
+ ```typescript
189
+ import { defineMarkdownConfig } from "@cparra/apexdocs";
190
+
191
+ export default defineMarkdownConfig({
192
+ sourceDir: 'force-app',
193
+ targetDir: 'docs',
194
+ scope: ['global', 'public'],
195
+ ...
196
+ });
330
197
  ```
331
198
 
332
- ### Grouping Declarations Within A Class
199
+ ### Excluding Tags from Appearing in the Documentation
333
200
 
334
- A class might have members that should be grouped together. For example, you can have a class for constants with
335
- groups of constants that should be grouped together because they share a common behavior (e.g. different groups
336
- of constants representing the possible values for different picklists.)
201
+ You can exclude tags from appearing in the documentation by using the `excludeTags` property in the configuration file,
202
+ which allow you to pass a list of tags that you want to exclude from the documentation.
337
203
 
338
- You can group things together within a class by using the following syntax:
339
-
340
- ```apex
341
- // @start-group Group Name or Description
342
- public static final String CONSTANT_FOO = 'Foo';
343
- public static final String CONSTANT_BAR = 'Bar';
344
- // @end-group
204
+ ```typescript
205
+ import { defineMarkdownConfig } from "@cparra/apexdocs";
206
+
207
+ export default defineMarkdownConfig({
208
+ sourceDir: 'force-app',
209
+ targetDir: 'docs',
210
+ scope: ['global', 'public'],
211
+ excludeTags: ['internal', 'ignore'],
212
+ ...
213
+ });
345
214
  ```
346
215
 
347
- Groups of members are displayed together under their own subsection after its name or description.
348
-
349
- Some notes about grouping:
216
+ ### Configuration Hooks
350
217
 
351
- * This is only supported on classes, NOT enums and interfaces
352
- * Supports
353
- * Properties
354
- * Fields (variables and constants)
355
- * Constructors
356
- * Methods
357
- * BUT only members of the same type are grouped together. For example,
358
- if you have a group that contains properties and methods the properties will be grouped together under Properties ->
359
- Group Name, and the methods will be grouped together under Methods -> Group Name
360
- * Does not support inner types (inner classes, interfaces, and enums)
361
- * It is necessary to use `// @end-group` whenever a group has been started, otherwise a parsing error will be raised for
362
- that file.
218
+ When defining a `.js` or `.ts` configuration file, your object export can also make use
219
+ of different hooks that will be called at different stages of the documentation generation process.
363
220
 
364
- ### Inline linking
221
+ All hooks can be async functions, allowing you to make asynchronous operations, like calling an external API.
365
222
 
366
- Apexdocs allows you to reference other classes from anywhere in your docs, and automatically creates a link to that
367
- class file for easy navigation.
223
+ 📒 Note: The extension hook functions are only available when generating Markdown files (not OpenApi).
368
224
 
369
- Apexdocs recognizes 2 different syntax when linking files:
225
+ #### **transformReferenceGuide**
370
226
 
371
- - Javadoc's `{@link FileName}` syntax
372
- - A class name wrapped in between `<<` `>>`.
227
+ Allows changing the Allows changing the frontmatter and content of the reference guide, or even if creating a reference
228
+ guide page should be skipped.
373
229
 
374
- **Example**
230
+ **Type**
375
231
 
376
- ```apex
377
- /**
378
- * @description This is my method description. This method receives an <<ExampleClass>>.
379
- * @param param1 An <<ExampleClass>> instance. Can also do {@link ExampleClass}
380
- * @return The result of the operation.
381
- */
382
- public static Object doSomething(ExampleClass param1) {}
232
+ ```typescript
233
+ type TransformReferenceGuide = (referenceGuide: ReferenceGuidePageData) => Partial<ReferenceGuidePageData> | Skip | Promise<Partial<ReferenceGuidePageData> | Skip>;
383
234
  ```
384
235
 
385
- ---
386
-
387
- Email addresses can also be inlined linked by using the `{@email EMAIL_ADDRESS}` syntax.
236
+ Example: Updating the frontmatter
388
237
 
389
- ### HTML support
390
-
391
- For the most part all HTML is sanitized when the `--sanitizeHtml` flag is passed a true value (which is the default).
392
- But there are some tags are allowed to have for the possibility of better
393
- styling long text.
394
-
395
- - Allowed tags are: `br`, `p`, `ul`, `li`, and `code`
396
-
397
- Example
398
-
399
- ```apex
400
- /**
401
- * @description <p>This is a paragraph</p>
402
- * <p>And this is another paragraph</p>
403
- * <ul>
404
- * <li>This is a list item</li>
405
- * <li>This is another list item</li>
406
- * </ul>
407
- */
408
- class MyClass {
409
- }
238
+ ```typescript
239
+ export default {
240
+ transformReferenceGuide: (referenceGuide) => {
241
+ return {
242
+ // The frontmatter can either be an object, of the frontmatter string itself
243
+ frontmatter: { example: 'example' }
244
+ };
245
+ }
246
+ };
410
247
  ```
411
248
 
412
- ⚠️When the `--sanitizeHtml` flag is ON, any special character between code blocks (i.e. \```, \`, or `<code>`) will also
413
- be escaped.
414
- So if you have references to Apex generic collections (Set, List, or Maps) they will not look right, as the < and >
415
- symbols will be escaped.
416
- To prevent this you can turn the flag off, but be aware of the special considerations when doing this described below.
417
-
418
- ---
419
-
420
- For full control over the output you can also turn off the `--sanitizeHtml` flag, which will allow you
421
- to have any desired HTML within your docs.
422
-
423
- ⚠️When the `--sanitizeHtml` flag is OFF, references to Apex generic collections (Set, List or Maps) can be problematic
424
- as they will be treated as an HTML tag and not displayed. For example if you have something
425
- like `@description Returns a List<String>`
426
- the `<String>` portion will be treated as HTML and thus not appear on the page.
249
+ Example: skipping the reference guide
427
250
 
428
- To fix this issue, when not sanitizing HTML, you should wrap any code that contain special characters that can be
429
- treated as HTML within '\`'
430
- or within `<code>` tags.
251
+ ```typescript
252
+ // The skip function is imported from the package
253
+ import { defineMarkdownConfig, skip } from "@cparra/apexdocs";
254
+
255
+ export default defineMarkdownConfig({
256
+ transformReferenceGuide: (referenceGuide) => {
257
+ return skip();
258
+ }
259
+ });
260
+ ```
431
261
 
432
- ### Displaying diagrams
262
+ #### **transformDocs**
433
263
 
434
- You can display diagrams in your documentation by leveraging Github's built-in [Mermaid](https://mermaid-js.github.io/mermaid/#/) support.
264
+ The main purpose of this hook is to allow you to skip the generation of specific pages,
265
+ by returning a filtered array of `DocPageData` objects.
435
266
 
436
- If you are using a markdown generator that supports Mermaid (e.g. [Github's markdown](https://github.blog/2022-02-14-include-diagrams-markdown-files-mermaid/),
437
- you can add diagrams to your documentation by using the
438
- `@mermaid` tag.
267
+ If you want to modify the contents or frontmatter of the docs, use the `transformDocPage` hook instead.
439
268
 
440
- **Example**
269
+ **Type**
441
270
 
442
- ```apex
443
- /**
444
- * @mermaid
445
- * graph TD
446
- * A[Christmas] -->|Get money| B(Go shopping)
447
- * B --> C{Let me think}
448
- * C -->|One| D[Laptop]
449
- * C -->|Two| E[iPhone]
450
- * C -->|Three| F[Car]
451
- */
452
- public class MyClass {
453
- }
271
+ ```typescript
272
+ type TransformDocs = (docs: DocPageData[]) => DocPageData[] | Promise<DocPageData[]>
454
273
  ```
455
274
 
456
- [Here's an example of how that looks](/docs/types/Classes/nspc.AnotherInterface.md)
457
-
458
- ### Ignoring files and members
459
-
460
- You can ignore files and members by using the `@ignore` tag on any ApexDoc block. If used at the class level, the entire
461
- file will be ignored. If used at the member level, only that member will be ignored.
462
-
463
275
  Example
464
276
 
465
- ```apex
466
- /**
467
- * @ignore
468
- */
469
- public class MyClass {
470
- public static void myMethod() {}
471
- }
472
- ```
473
-
474
- ## Generating OpenApi REST Definitions
475
-
476
- ApexDocs supports generating OpenApi 3.1.0 REST definitions based on any `@RestResource` classes in your source code.
477
-
478
- ### Usage
479
-
480
- To create an OpenApi specification file, run the `apexdocs-generate` and pass `openapi` to the `--targetGenerator` parameter.
481
- When using this generator, you can also pass a custom title through the `--openApiTitle` parameter. This title will be placed
482
- in the output file's `info.title` property, as defined by the [OpenApi documentation for the Info Object](https://spec.openapis.org/oas/v3.1.0#info-object)
483
-
484
-
485
- ```shell
486
- apexdocs-generate -s ./src -t docs -g openapi --openApiTitle "Custom OpenApi Title"
277
+ ```typescript
278
+ export default {
279
+ transformDocs: (docs) => {
280
+ return docs.filter(doc => doc.name !== 'MyClass');
281
+ }
282
+ };
487
283
  ```
488
284
 
489
- ### How It Works
490
-
491
- When generating an OpenApi document, since `@RestResource` classes need to be global in Apex, the `--scope` parameter will be ignored.
492
- Instead, ApexDocs will run through all classes annotated with `@RestResource` and add it to the output OpenApi file.
493
-
494
- Once it finishes running, a file named `openapi.json` will be created in the specified `--targetDir`.
285
+ #### **transformDocPage**
495
286
 
496
- ### Configuring What Gets Created
287
+ Allows changing the frontmatter and content of the doc page.
497
288
 
498
- ApexDocs will automatically parse your source code and generate the OpenApi definition based on the HTTP related Apex
499
- annotations (RestResource, HttpDelete, HttpGet, HttpPatch, HttpPost, HttpGet). The different HTTP annotations will be used to generate a file that complies with the [OpenApi Specification v3.1.0](https://spec.openapis.org/oas/v3.1.0)
289
+ **Type**
500
290
 
501
- Besides these annotations, the ApexDocs tool will also use any information provided through your code's Apexdocs, relying on
502
- some custom annotations that are specific to generating OpenApi definitions:
503
-
504
- * `@http-request-body`
505
- * `@http-parameter`
506
- * `@http-response`
507
-
508
- #### @http-request-body
509
-
510
- Allows you to specify the HTTP request's expected request body. It supports receiving a `description`,
511
- whether it is `required` or not, and a `schema`, which defines the shape of the object that is expected.
512
-
513
- 📝 Note that only one `@http-request-body` should be defined per method. If you add more than one, only
514
- a single one will be used when generating the OpenApi definition.
515
-
516
- The `schema` can either be a reference to another class in your source code (see the `Class References` section below)
517
- or a fully defined custom schema (See the `Custom Schemas` section below).
518
-
519
- Example
520
- ```apex
521
- /**
522
- * @description This is a sample HTTP Post method
523
- * @http-request-body
524
- * description: This is an example of a request body
525
- * required: true
526
- * schema: ClassName
527
- */
528
- @HttpPost
529
- global static void doPost() {
530
- ///...
531
- }
291
+ ```typescript
292
+ type TransformDocPage = (
293
+ doc: DocPageData,
294
+ ) => Partial<ConfigurableDocPageData> | Promise<Partial<ConfigurableDocPageData>>
532
295
  ```
533
296
 
534
- 📝 Note that each parameter of this annotation is expected to be on its own line. Parameters are treated as YAML,
535
- so spacing is important.
536
-
537
- #### @http-parameter
538
-
539
- Allows you to specify any HTTP parameter expected by your method. It supports receiving a `name`,
540
- an `in` as defined by the supported [Parameter Locations](https://spec.openapis.org/oas/v3.1.0#parameter-locations),
541
- whether it is `required` or not, a `description`, and a `schema`.
542
-
543
- 📝 Note that you can specify as many `@http-parameter` annotations as needed.
544
-
545
297
  Example
546
- ```apex
547
- /**
548
- * @description This is a sample HTTP Post method
549
- * @return A String SObject.
550
- * @http-parameter
551
- * name: limit
552
- * in: query
553
- * required: true
554
- * description: Limits the number of items on a page
555
- * schema:
556
- * type: integer
557
- * @http-parameter
558
- * name: complex
559
- * in: cookie
560
- * schema: MyClassName
561
- */
562
- @HttpPost
563
- global static String doPost() {
564
- // ..
565
- }
566
- ```
567
298
 
568
- 📝 Note that each parameter of this annotation is expected to be on its own line. Parameters are treated as YAML,
569
- so spacing is important.
570
-
571
- #### @http-response
572
-
573
- Allows you to specify any HTTP response returned by your method. It supports receiving a `statusCode` with the response code,
574
- a `description`, and a `schema`.
575
-
576
- If no `description` is provided then one will be automatically built using the `statusCode`.
577
-
578
- 📝 Note that you can specify as many `@http-parameter` annotations as needed.
579
-
580
- ```apex
581
- /**
582
- * @description This is a sample HTTP Post method
583
- * @return A String SObject.
584
- * @http-response
585
- * statusCode: 200
586
- * schema: SuccessfulResponseClassName
587
- * @http-response
588
- * statusCode: 500
589
- * description: Status Code 500 - An internal server error occurred.
590
- * schema:
591
- * type: string
592
- */
593
- @HttpPost
594
- global static String doPost() {
595
- // ...
596
- }
299
+ ```typescript
300
+ export default {
301
+ transformDocPage: (doc) => {
302
+ return {
303
+ frontmatter: { example: 'example' }
304
+ };
305
+ }
306
+ };
597
307
  ```
598
308
 
599
- #### Class References
600
-
601
- Whenever specifying a `schema` parameter, you can pass as a string the name of any class in your source code. This
602
- class will be parsed by the ApexDocs tool and automatically converted to a reference in the resulting OpenApi definition.
309
+ #### **transformReference**
603
310
 
604
- The tool will parse the class and create a reference that complies with [Apex's support for User-Defined Types](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_rest_methods.htm#ApexRESTUserDefinedTypes)
311
+ Allows changing where the files are written to and how files are linked to each other.
605
312
 
606
- ##### Reference Overrides
313
+ **Type**
607
314
 
608
- When dealing with references, there might be cases when you want to manually tell the parser what type of object a property
609
- or field is. For example, let's say we have a class that looks as follows
610
-
611
- ```apex
612
- public class MyClass {
613
- public Object myObject;
614
- public Account myAccountRecord;
615
- }
616
- ```
617
-
618
- In this case `myObject` has a type of `Object`, and `myAccountRecord` is an SObject. Neither of these will be accurately
619
- parsed when building the OpenApi definition, instead they will be simple be referenced as `object` without any properties.
620
-
621
- To accurately represent the shape of these objects, you can use the `@http-schema` annotation to essentially override its
622
- type during parsing. In this annotation you can specify the same thing you would in any `schema` property when dealing with any
623
- of the main `@http-*` methods, meaning a reference to another class, or a Custom Schema (as defined below).
624
-
625
- ```apex
626
- public class MyClass {
627
- /**
628
- * @description This is a generic reference to another class
629
- * @http-schema MyOtherClassName
630
- */
631
- public Object myObject;
632
-
633
- /**
634
- * @description This is a reference to an Account SObject
635
- * @http-schema
636
- * type: object
637
- * properties:
638
- * Id:
639
- * type: string
640
- * Name:
641
- * type: string
642
- * CustomField__c:
643
- * type: number
644
- */
645
- public Account myAccountRecord;
646
- }
315
+ ```typescript
316
+ type TransformReference = (
317
+ reference: DocPageReference,
318
+ ) => Partial<ConfigurableDocPageReference> | Promise<ConfigurableDocPageReference>;
647
319
  ```
648
320
 
649
- ---
650
-
651
- If dealing with a collection, you can also specify the name of the reference either using the `List` or `Set` syntax.
652
-
653
- 📝 When using List or Set syntax in the `schema` of the ApexDoc `@http-*` annotation, only collections one level
654
- deep are supported (e.g. List<List<String>> is not supported). This is only a limitation when referencing collections
655
- on the ApexDoc `schema` property directly, and is fully supported when multi-level collections are inside of a referenced
656
- class as part of your codebase.
657
-
658
- Maps are not supported, as it is not possible to know which keys the map will contain, and thus it is not possible
659
- to convert that to a valid specification. For this use case, define a Custom Schema as explained below.
660
-
661
- ```apex
662
- /**
663
- * @description This is a sample HTTP Post method
664
- * @http-request-body
665
- * description: This is an example of a request body
666
- * schema: List<ClassName>
667
- */
668
- @HttpPost
669
- global static void doPost() {
670
- ///...
671
- }
672
- ```
321
+ Example
673
322
 
674
- Inner class references are also supported, but note that you need to pass the full name of the reference,
675
- by using the `ParentClassName.InnerClassName` syntax, even if the inner class resides on the same class as the HTTP method
676
- referencing it.
677
-
678
- ```apex
679
- /**
680
- * @description This is a sample HTTP Post method
681
- * @http-request-body
682
- * description: This is an example of a request body
683
- * schema: ParentClass.InnerClass
684
- */
685
- @HttpPost
686
- global static void doPost() {
687
- ///...
688
- }
323
+ ```typescript
324
+ export default {
325
+ // Notice how we are setting the linking strategy to none, so that nothing is done
326
+ // to the links by the tool when it tries to link to other classes
327
+ linkingStrategy: 'none',
328
+ transformReference: (reference) => {
329
+ return {
330
+ // Link to the class in Github instead to its doc page.
331
+ referencePath: `https://github.com/MyOrg/MyRepo/blob/main/src/classes/${reference.name}.cls`
332
+ };
333
+ }
334
+ };
689
335
  ```
690
336
 
691
- #### Custom Schemas
692
-
693
- For any `schema` parameter in any of the HTTP ApexDocs annotations, besides specifying the name of a class, you
694
- can also specify a custom schema definition. The schema definition can either be for a primitive type, an `object` or an `array`
695
-
696
- **Primitives**
337
+ ## ⤵︎ Importing to your project
697
338
 
698
- For primitives, you should specify the `type` and an optional `format`, as defined by the [OpenApi Specification on Data Types](https://spec.openapis.org/oas/v3.1.0#data-types)
699
-
700
- ```apex
701
- /**
702
- * ...
703
- * schema:
704
- * type: string
705
- * format: password
706
- */
707
- ```
708
-
709
- **Objects**
710
-
711
- To specify a custom object schema, use `object` as the `type`, and specify as many properties as follows:
712
-
713
- ```apex
714
- /**
715
- * schema:
716
- * type: object
717
- * properties:
718
- * id:
719
- * type: string
720
- * description: The super Id.
721
- * name:
722
- * type: string
723
- * phone:
724
- * type: string
725
- * format: byte
726
- */
727
- ```
339
+ ### Reflection
728
340
 
729
- Properties can be defined as primitives (as explained above), other objects, or arrays (explained below)
341
+ If you are just interested in the Apex parsing capabilities, you can use the
342
+ standalone [Apex Reflection Library](https://www.npmjs.com/package/@cparra/apex-reflection)
343
+ which is what gets used by this library behind the scenes to generate the documentation files.
730
344
 
731
- **Arrays**
345
+ ### Processing
732
346
 
733
- To specify a custom array schema, use `array` as the `type`, and provide an `items` definition. In `items`
734
- you can specify the definition of any other custom type (primitives, objects, or other arrays).
347
+ If you would like to use the processing capabilities of ApexDocs directly from Javascript/Typescript
348
+ instead of using the CLI, you can import the `process` function from the library.
735
349
 
736
- ```apex
737
- /**
738
- * schema:
739
- * type: array
740
- * items:
741
- * type: object
742
- * properties:
743
- * name:
744
- * type: string
745
- */
350
+ ```typescript
351
+ import { process } from '@cparra/apexdocs';
352
+
353
+ process({
354
+ sourceDir: 'force-app',
355
+ targetDir: 'docs',
356
+ scope: ['global', 'public'],
357
+ ...
358
+ });
746
359
  ```
747
360
 
748
- #### SObject References
749
-
750
- ApexDocs is not able to automatically parse SObject references, as it can with class references, as it does
751
- not reach into your org to get existing SObject describes. Because of this, when dealing with SObject references
752
- you should create a Custom Schema as defined above. This will also allow you to specify which specific
753
- fields are being received or returned.
754
-
755
-
756
- ### Considerations
757
-
758
- Please be aware of the following when using ApexDocs to create an OpenApi definition:
361
+ ### 👨‍💻 Typescript
759
362
 
760
- * Map references are resolved as `object` with no properties, as it is not possible to know which keys the map will contain.
761
- When using maps either create a class that better represents the shape of the object and use a Class Reference, or
762
- define a Custom Schema in the `schema` section of the ApexDoc itself.
763
- * Same thing when referencing SObjects, as SObject describe parsing is not supported by the ApexDocs tool. When referencing
764
- SObjects, consider defining a Custom Schema in the `schema` section of the ApexDoc.
765
- * ApexDoc is only able to parse through your source code, so references to other packages (namespaced classes) or any
766
- code that lives outside your source code is not supported. Consider creating a Custom Schema for those situations.
767
- * The return value and received parameters or your methods are currently not being considered when creating the OpenApi definition file.
768
- Instead, use the `@http-response` ApexDoc annotation to specify the return value, and `@http-parameter` to specify any
769
- expected parameter.
363
+ If using Typescript, ApexDocs provides all necessary type definitions.
770
364
 
771
- ## Typescript
365
+ ## 📖 Documentation Guide
772
366
 
773
- ApexDocs provides all necessary type definitions.
367
+ See the [wiki](https://github.com/cesarParra/apexdocs/wiki/%F0%9F%93%96-Documenting-Apex-code)
368
+ for an in-depth guide on how to document your Apex code to get the most out of ApexDocs.
774
369
 
775
- ---
370
+ ## 📄 Generating OpenApi REST Definitions
776
371
 
777
- ## 1.X
372
+ ApexDocs can also generate OpenApi REST definitions for your Salesforce Apex classes annotated with `@RestResource`.
778
373
 
779
- Looking for documentation for version 1.X? Please refer to its [branch](https://github.com/cesarParra/apexdocs/tree/1.x)
374
+ See the [wiki](https://github.com/cesarParra/apexdocs/wiki/%F0%9F%93%84-Generating-OpenApi-REST-Definitions)
375
+ for more information.