@cparra/apexdocs 1.13.4 → 2.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/.eslintrc.js +12 -0
  2. package/.prettierrc.js +7 -0
  3. package/README.md +344 -277
  4. package/ROADMAP.md +18 -0
  5. package/docs/Gemfile.lock +1 -1
  6. package/docs/Sample-Classes/SampleClass.md +138 -30
  7. package/docs/Sample-Interfaces/SampleInterface.md +21 -4
  8. package/docs/index.md +1 -9
  9. package/examples/apex/SampleClass.cls +31 -6
  10. package/examples/apex/SampleInterface.cls +3 -2
  11. package/lib/application/Apexdocs.d.ts +11 -0
  12. package/lib/application/Apexdocs.js +41 -0
  13. package/lib/application/Apexdocs.js.map +1 -0
  14. package/lib/cli/generate.js +17 -21
  15. package/lib/cli/generate.js.map +1 -0
  16. package/lib/index.d.ts +1 -1
  17. package/lib/index.js +2 -1
  18. package/lib/index.js.map +1 -0
  19. package/lib/model/file.d.ts +10 -0
  20. package/lib/model/file.js +23 -0
  21. package/lib/model/file.js.map +1 -0
  22. package/lib/model/manifest.d.ts +22 -0
  23. package/lib/model/manifest.js +41 -0
  24. package/lib/model/manifest.js.map +1 -0
  25. package/lib/model/markdown-file.d.ts +10 -0
  26. package/lib/model/markdown-file.js +52 -0
  27. package/lib/model/markdown-file.js.map +1 -0
  28. package/lib/model/markdown-generation-util/field-declaration-util.d.ts +3 -0
  29. package/lib/model/markdown-generation-util/field-declaration-util.js +33 -0
  30. package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -0
  31. package/lib/model/markdown-generation-util/index.d.ts +3 -0
  32. package/lib/model/markdown-generation-util/index.js +9 -0
  33. package/lib/model/markdown-generation-util/index.js.map +1 -0
  34. package/lib/model/markdown-generation-util/method-declaration-util.d.ts +3 -0
  35. package/lib/model/markdown-generation-util/method-declaration-util.js +97 -0
  36. package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -0
  37. package/lib/model/markdown-generation-util/type-declaration-util.d.ts +3 -0
  38. package/lib/model/markdown-generation-util/type-declaration-util.js +25 -0
  39. package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -0
  40. package/lib/model/markdown-home-file.d.ts +11 -0
  41. package/lib/model/markdown-home-file.js +50 -0
  42. package/lib/model/markdown-home-file.js.map +1 -0
  43. package/lib/model/markdown-type-file.d.ts +17 -0
  44. package/lib/model/markdown-type-file.js +62 -0
  45. package/lib/model/markdown-type-file.js.map +1 -0
  46. package/lib/service/apex-file-reader.d.ts +13 -0
  47. package/lib/service/apex-file-reader.js +39 -0
  48. package/lib/service/apex-file-reader.js.map +1 -0
  49. package/lib/service/file-system.d.ts +12 -0
  50. package/lib/service/file-system.js +21 -0
  51. package/lib/service/file-system.js.map +1 -0
  52. package/lib/service/file-writer.d.ts +4 -0
  53. package/lib/service/file-writer.js +25 -0
  54. package/lib/service/file-writer.js.map +1 -0
  55. package/lib/service/manifest-factory.d.ts +9 -0
  56. package/lib/service/manifest-factory.js +13 -0
  57. package/lib/service/manifest-factory.js.map +1 -0
  58. package/lib/service/parser.d.ts +9 -0
  59. package/lib/service/parser.js +17 -0
  60. package/lib/service/parser.js.map +1 -0
  61. package/lib/service/walkers/class-walker.d.ts +4 -0
  62. package/lib/service/walkers/class-walker.js +32 -0
  63. package/lib/service/walkers/class-walker.js.map +1 -0
  64. package/lib/service/walkers/enum-walker.d.ts +4 -0
  65. package/lib/service/walkers/enum-walker.js +10 -0
  66. package/lib/service/walkers/enum-walker.js.map +1 -0
  67. package/lib/service/walkers/interface-walker.d.ts +4 -0
  68. package/lib/service/walkers/interface-walker.js +14 -0
  69. package/lib/service/walkers/interface-walker.js.map +1 -0
  70. package/lib/service/walkers/walker-factory.d.ts +5 -0
  71. package/lib/service/walkers/walker-factory.js +19 -0
  72. package/lib/service/walkers/walker-factory.js.map +1 -0
  73. package/lib/service/walkers/walker.d.ts +16 -0
  74. package/lib/service/walkers/walker.js +9 -0
  75. package/lib/service/walkers/walker.js.map +1 -0
  76. package/lib/settings.d.ts +21 -0
  77. package/lib/settings.js +42 -0
  78. package/lib/settings.js.map +1 -0
  79. package/lib/transpiler/file-container.d.ts +6 -0
  80. package/lib/transpiler/file-container.js +15 -0
  81. package/lib/transpiler/file-container.js.map +1 -0
  82. package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +6 -0
  83. package/lib/transpiler/markdown/class-file-generatorHelper.js +17 -0
  84. package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -0
  85. package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +4 -0
  86. package/lib/transpiler/markdown/docsify/docsify-docs-processor.js +10 -0
  87. package/lib/transpiler/markdown/docsify/docsify-docs-processor.js.map +1 -0
  88. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +8 -0
  89. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +24 -0
  90. package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -0
  91. package/lib/transpiler/markdown/markdown-transpiler-base.d.ts +11 -0
  92. package/lib/transpiler/markdown/markdown-transpiler-base.js +23 -0
  93. package/lib/transpiler/markdown/markdown-transpiler-base.js.map +1 -0
  94. package/lib/transpiler/processor-type-transpiler.d.ts +8 -0
  95. package/lib/transpiler/processor-type-transpiler.js +6 -0
  96. package/lib/transpiler/processor-type-transpiler.js.map +1 -0
  97. package/lib/transpiler/transpiler.d.ts +5 -0
  98. package/lib/transpiler/transpiler.js +21 -0
  99. package/lib/transpiler/transpiler.js.map +1 -0
  100. package/lib/util/logger.d.ts +18 -0
  101. package/lib/util/logger.js +32 -0
  102. package/lib/util/logger.js.map +1 -0
  103. package/package.json +22 -11
  104. package/src/application/Apexdocs.ts +41 -0
  105. package/src/cli/generate.ts +52 -64
  106. package/src/index.ts +1 -1
  107. package/src/model/__tests__/manifest.spec.ts +15 -0
  108. package/src/model/file.ts +23 -0
  109. package/src/model/manifest.ts +60 -0
  110. package/src/model/markdown-file.ts +56 -0
  111. package/src/model/markdown-generation-util/field-declaration-util.ts +42 -0
  112. package/src/model/markdown-generation-util/index.ts +3 -0
  113. package/src/model/markdown-generation-util/method-declaration-util.ts +128 -0
  114. package/src/model/markdown-generation-util/type-declaration-util.ts +29 -0
  115. package/src/model/markdown-home-file.ts +48 -0
  116. package/src/model/markdown-type-file.ts +75 -0
  117. package/src/service/__tests__/apex-file-reader.spec.ts +79 -0
  118. package/src/service/__tests__/manifest-factory.spec.ts +16 -0
  119. package/src/service/apex-file-reader.ts +45 -0
  120. package/src/service/file-system.ts +28 -0
  121. package/src/service/file-writer.ts +25 -0
  122. package/src/service/manifest-factory.ts +12 -0
  123. package/src/service/parser.ts +18 -0
  124. package/src/service/walkers/class-walker.ts +31 -0
  125. package/src/service/walkers/enum-walker.ts +8 -0
  126. package/src/service/walkers/interface-walker.ts +12 -0
  127. package/src/service/walkers/walker-factory.ts +18 -0
  128. package/src/service/walkers/walker.ts +35 -0
  129. package/src/settings.ts +57 -0
  130. package/src/transpiler/file-container.ts +13 -0
  131. package/src/transpiler/markdown/class-file-generatorHelper.ts +16 -0
  132. package/src/transpiler/markdown/docsify/docsify-docs-processor.ts +7 -0
  133. package/src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts +22 -0
  134. package/src/transpiler/markdown/markdown-transpiler-base.ts +28 -0
  135. package/src/transpiler/processor-type-transpiler.ts +12 -0
  136. package/src/transpiler/transpiler.ts +18 -0
  137. package/src/util/logger.ts +31 -0
  138. package/tsconfig.json +9 -3
  139. package/.prettierrc +0 -5
  140. package/examples/config/config.json +0 -5
  141. package/lib/AsJsDocsProcessor.d.ts +0 -9
  142. package/lib/AsJsDocsProcessor.js +0 -61
  143. package/lib/ClassFileGeneratorHelper.d.ts +0 -5
  144. package/lib/ClassFileGeneratorHelper.js +0 -25
  145. package/lib/ClassFileGeneratorHelper.test.d.ts +0 -1
  146. package/lib/ClassFileGeneratorHelper.test.js +0 -32
  147. package/lib/Configuration.d.ts +0 -34
  148. package/lib/Configuration.js +0 -37
  149. package/lib/DocsProcessor.d.ts +0 -6
  150. package/lib/DocsProcessor.js +0 -9
  151. package/lib/DocsifyDocsProcessor.d.ts +0 -4
  152. package/lib/DocsifyDocsProcessor.js +0 -9
  153. package/lib/DocsifyDocsProcessor.test.d.ts +0 -1
  154. package/lib/DocsifyDocsProcessor.test.js +0 -7
  155. package/lib/FileManager.d.ts +0 -6
  156. package/lib/FileManager.js +0 -28
  157. package/lib/JekyllDocsProcessor.d.ts +0 -8
  158. package/lib/JekyllDocsProcessor.js +0 -20
  159. package/lib/JekyllDocsProcessor.test.d.ts +0 -1
  160. package/lib/JekyllDocsProcessor.test.js +0 -21
  161. package/lib/JsHelper.d.ts +0 -12
  162. package/lib/JsHelper.js +0 -72
  163. package/lib/MarkdownDocsProcessor.d.ts +0 -22
  164. package/lib/MarkdownDocsProcessor.js +0 -358
  165. package/lib/MarkdownHelper.d.ts +0 -13
  166. package/lib/MarkdownHelper.js +0 -78
  167. package/lib/Settings.d.ts +0 -22
  168. package/lib/Settings.js +0 -51
  169. package/lib/Settings.test.d.ts +0 -1
  170. package/lib/Settings.test.js +0 -38
  171. package/lib/command/Generate.d.ts +0 -2
  172. package/lib/command/Generate.js +0 -54
  173. package/lib/command/__test__/Generte.test.d.ts +0 -1
  174. package/lib/command/__test__/Generte.test.js +0 -30
  175. package/lib/model/ApexModel.d.ts +0 -30
  176. package/lib/model/ApexModel.js +0 -85
  177. package/lib/model/ClassModel.d.ts +0 -39
  178. package/lib/model/ClassModel.js +0 -125
  179. package/lib/model/EnumModel.d.ts +0 -6
  180. package/lib/model/EnumModel.js +0 -28
  181. package/lib/model/MethodModel.d.ts +0 -18
  182. package/lib/model/MethodModel.js +0 -74
  183. package/lib/model/PropertyModel.d.ts +0 -6
  184. package/lib/model/PropertyModel.js +0 -40
  185. package/lib/model/__test__/ClassModel.test.d.ts +0 -1
  186. package/lib/model/__test__/ClassModel.test.js +0 -79
  187. package/lib/model/__test__/MethodModel.test.d.ts +0 -1
  188. package/lib/model/__test__/MethodModel.test.js +0 -55
  189. package/lib/model/__test__/PropertyModel.test.d.ts +0 -1
  190. package/lib/model/__test__/PropertyModel.test.js +0 -25
  191. package/lib/parser/ClassParser.d.ts +0 -5
  192. package/lib/parser/ClassParser.js +0 -79
  193. package/lib/parser/EnumParser.d.ts +0 -5
  194. package/lib/parser/EnumParser.js +0 -45
  195. package/lib/parser/FileParser.d.ts +0 -8
  196. package/lib/parser/FileParser.js +0 -210
  197. package/lib/parser/MethodParser.d.ts +0 -5
  198. package/lib/parser/MethodParser.js +0 -109
  199. package/lib/parser/PropertyParser.d.ts +0 -5
  200. package/lib/parser/PropertyParser.js +0 -46
  201. package/lib/parser/__test__/ClassParser.test.d.ts +0 -1
  202. package/lib/parser/__test__/ClassParser.test.js +0 -52
  203. package/lib/parser/__test__/FileParser.test.d.ts +0 -1
  204. package/lib/parser/__test__/FileParser.test.js +0 -12
  205. package/lib/parser/__test__/MethodParser.test.d.ts +0 -1
  206. package/lib/parser/__test__/MethodParser.test.js +0 -69
  207. package/lib/parser/__test__/PropertyParser.test.d.ts +0 -1
  208. package/lib/parser/__test__/PropertyParser.test.js +0 -14
  209. package/lib/parser/__test__/testFileContents.d.ts +0 -1
  210. package/lib/parser/__test__/testFileContents.js +0 -82
  211. package/lib/utils.d.ts +0 -12
  212. package/lib/utils.js +0 -49
  213. package/lib/utils.test.d.ts +0 -1
  214. package/lib/utils.test.js +0 -35
  215. package/src/AsJsDocsProcessor.ts +0 -67
  216. package/src/ClassFileGeneratorHelper.test.ts +0 -44
  217. package/src/ClassFileGeneratorHelper.ts +0 -26
  218. package/src/Configuration.ts +0 -69
  219. package/src/DocsProcessor.ts +0 -9
  220. package/src/DocsifyDocsProcessor.test.ts +0 -6
  221. package/src/DocsifyDocsProcessor.ts +0 -7
  222. package/src/FileManager.ts +0 -32
  223. package/src/JekyllDocsProcessor.test.ts +0 -28
  224. package/src/JekyllDocsProcessor.ts +0 -22
  225. package/src/JsHelper.ts +0 -78
  226. package/src/MarkdownDocsProcessor.ts +0 -420
  227. package/src/MarkdownHelper.ts +0 -91
  228. package/src/Settings.test.ts +0 -54
  229. package/src/Settings.ts +0 -65
  230. package/src/command/Generate.ts +0 -69
  231. package/src/command/__test__/Generte.test.ts +0 -39
  232. package/src/model/ApexModel.ts +0 -102
  233. package/src/model/ClassModel.ts +0 -140
  234. package/src/model/EnumModel.ts +0 -27
  235. package/src/model/MethodModel.ts +0 -80
  236. package/src/model/PropertyModel.ts +0 -37
  237. package/src/model/__test__/ClassModel.test.ts +0 -100
  238. package/src/model/__test__/MethodModel.test.ts +0 -70
  239. package/src/model/__test__/PropertyModel.test.ts +0 -34
  240. package/src/parser/ClassParser.ts +0 -83
  241. package/src/parser/EnumParser.ts +0 -47
  242. package/src/parser/FileParser.ts +0 -250
  243. package/src/parser/MethodParser.ts +0 -119
  244. package/src/parser/PropertyParser.ts +0 -46
  245. package/src/parser/__test__/ClassParser.test.ts +0 -70
  246. package/src/parser/__test__/FileParser.test.ts +0 -14
  247. package/src/parser/__test__/MethodParser.test.ts +0 -90
  248. package/src/parser/__test__/PropertyParser.test.ts +0 -18
  249. package/src/parser/__test__/testFileContents.ts +0 -81
  250. package/src/utils.test.ts +0 -40
  251. package/src/utils.ts +0 -52
package/.eslintrc.js ADDED
@@ -0,0 +1,12 @@
1
+ module.exports = {
2
+ parser: '@typescript-eslint/parser',
3
+ parserOptions: {
4
+ ecmaVersion: 2020,
5
+ sourceType: 'module',
6
+ },
7
+ extends: [
8
+ 'plugin:@typescript-eslint/recommended',
9
+ 'plugin:prettier/recommended',
10
+ ],
11
+ rules: {},
12
+ };
package/.prettierrc.js ADDED
@@ -0,0 +1,7 @@
1
+ module.exports = {
2
+ semi: true,
3
+ trailingComma: 'all',
4
+ singleQuote: true,
5
+ printWidth: 120,
6
+ tabWidth: 2,
7
+ };
package/README.md CHANGED
@@ -1,277 +1,344 @@
1
- # ApexDocs
2
-
3
- <p align="center">
4
- <b>ApexDocs is a Node.js library with CLI capabilities to generate documentation for Salesforce Apex classes.</b>
5
- </p>
6
-
7
- [![License](https://img.shields.io/github/license/cesarParra/apexdocs)](https://github.com/cesarParra/apexdocs/blob/master/LICENSE)
8
-
9
- ## Description
10
-
11
- ApexDocs was built as an alternative to the [Java based ApexDoc tool](https://github.com/SalesforceFoundation/ApexDoc) originally created by Aslam Bari and later maintained by Salesforce.org, as that tool is no longer being maintained.
12
-
13
- ApexDocs is a Node.js library built on Typescript and hosted on [npm](https://www.npmjs.com/package/@cparra/apexdocs). It offers CLI capabilities to automatically generate a set of files that fully document each one of you classes. Additionally it can be imported and consumed directly by your JavaScript code.
14
-
15
- There are some key differences between ApexDocs and the Java based ApexDoc tool:
16
-
17
- - **Recursive file search through your module directory structure**. In an `sfdx` based project, all of your classes will be documented by specifying the top-most directory where file search should begin.
18
- - **Unopinionated documentation site generation**. Instead of creating HTML files, ApexDocs generates a Markdown (.md) file per Apex class being documented. This means you can host your files in static web hosting services that parse Markdown like Github Pages or Netlify, and use site generators like Jekyll or Gatsby. This gives you the freedom to decide how to style your site to match your needs.
19
-
20
- ### Demo
21
-
22
- ApexDocs currently supports generating markdown files for Jekyll and Docsify sites.
23
-
24
- ### In the wild
25
-
26
- - [Nimble AMS Docs](https://nimbleuser.github.io/nams-api-docs/#/public-apis/)
27
- - [Yet Another Salesforce Logger](https://cesarparra.github.io/yet-another-salesforce-logger/#/)
28
-
29
- ### [Docsify](https://docsify.js.org/)
30
-
31
- Demo
32
-
33
- - [Docsify](https://cesarparra.github.io/apexdocs-docsify-example/)
34
-
35
- ### [Jekyll](https://jekyllrb.com/)
36
-
37
- Demo
38
-
39
- - [Jekyll](https://cesarparra.github.io/apexdocs/)
40
-
41
- ## Installation
42
-
43
- ```bash
44
- npm i @cparra/apexdocs
45
- ```
46
-
47
- ## Usage
48
-
49
- ### CLI
50
-
51
- ```bash
52
- apexdocs-generate
53
- -s src
54
- -t docs
55
- -p global
56
- -g docsify
57
- ```
58
-
59
- The CLI supports the following parameters:
60
-
61
- | Parameter | Alias | Description | Default | Required |
62
- | ----------------- | ----- | ---------------------------------------------------------------------------------------------------------------- | ----------------------------------- | -------- |
63
- | --sourceDir | -s | The directory location which contains your apex .cls classes. | N/A | Yes |
64
- | --targetDir | -t | The directory location where documentation will be generated to. | `docs` | No |
65
- | --recursive | -r | Whether .cls classes will be searched for recursively in the directory provided. | `true` | No |
66
- | --scope | -p | A list of scopes to document. Values should be separated by a space, e.g --scope public private | `global namespaceaccessible public` | No |
67
- | --targetGenerator | -g | Define the static file generator for which the documents will be created. Currently supports jekyll and docsify. | `jekyll` | No |
68
- | --configPath | -c | The path to the JSON configuration file that defines the structure of the documents to generate. | N/A | No |
69
- | --group | -o | Define whether the generated files should be grouped by the @group tag on the top level classes. | `true` | No |
70
-
71
- #### Configuration File
72
-
73
- You can optionally specify the path to a configuration JSON file through the `--configPath` parameter. This let's you have some additional control over the content outputs.
74
-
75
- The configuration file allows you to specify the following:
76
-
77
- _Note_: Everything in the configuration file is optional. When something is not specified, the default will be used.
78
-
79
- `root` (String)
80
-
81
- Default: None
82
-
83
- Allows you to specify the root directory for where the files are being generated. This can be helpful when embedding the generated docs into an existing site so that the links are generated correctly.
84
-
85
- `defaultGroupName`
86
-
87
- Default: Miscellaneous
88
-
89
- Defines the `@group` name to be used when a file does not specify it.
90
-
91
- `sourceLanguage`
92
-
93
- Default: None
94
-
95
- Defines the name of the language that will be used when generating `@example` blocks. Use this when you are interested in using syntax highlighting for your project.
96
-
97
- Even though the source code material for which documentation is generated is always `Apex`, generally you will be able to use a syntax highlighter that recognizes `java` source code, so set this value to `java` in those cases.
98
-
99
- `home` (Object)
100
-
101
- Gives you control over the home page.
102
-
103
- `home.header` (String)
104
-
105
- Default: None
106
-
107
- Allows you to embedd custom content into your home page by using the `header` property to point to the a file which contents will be added to the top of the generated home page.
108
-
109
- Specify the path with the content that you want to embed.
110
-
111
- `content` (Object)
112
-
113
- Gives you control over the content pages.
114
-
115
- `content.includeAuthor` (Boolean)
116
-
117
- Default: false
118
-
119
- Whether the `@author` tag should be used to add the file's author to the page.
120
-
121
- `content.includeDate` (Boolean)
122
-
123
- Default: false
124
-
125
- Whether the `@date` tag should be used to add the file's date to the page.
126
-
127
- `content.startingHeadingLevel` (Number)
128
-
129
- Default: 1
130
-
131
- The starting H tag level for the document. Each title will use this as the starting point to generate the approaprite `<h#>` tag. For example, if set to 1, the class' file name at the top of the file will use an `<h1>` tag, the `Properties` title will be `<h2>`, each property name will be an `<h3>`, etc.
132
-
133
- ```
134
- {
135
- "root": "root-directory",
136
- "defaultGrouName": "api",
137
- "sourceLanguage": "java",
138
- "home": {
139
- "header": "./examples/includes/header.md"
140
- },
141
- "content": {
142
- "startingHeadingLevel": 1,
143
- "includeAuthor": true,
144
- "includeDate": true
145
- }
146
- }
147
- ```
148
-
149
- ### Importing to your project
150
-
151
- If you are just interested in the documentation parsing capabilities, you can import ApexDocs into your own project.
152
-
153
- Use the `generate` function to create a list of `ClassModel` that includes all of the parsed information from your .cls files.
154
-
155
- `generate(sourceDirectory[,recursive][,scope][,outputDir])`
156
-
157
- - `sourceDirectory` \<string>
158
- - `recursive` \<boolean>
159
- - `scope` \<string[]>
160
- - `outpurDir` \<string>
161
-
162
- ```javascript
163
- var { generate } = require('@cparra/apexdocs');
164
-
165
- let documentedClasses = generate('src', true, ['global'], 'docs');
166
- ```
167
-
168
- ## Documentation Format
169
-
170
- ApexDocs picks up blocks of comments throughout your `.cls` files. The block must begin with `/**` and span through multiple lines, ending with `*/`.
171
-
172
- ### Documenting Classes
173
-
174
- The following tags are supported on the class level:
175
-
176
- | Tag | Description |
177
- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
178
- | `@description` | One or more lines describing the class. |
179
- | `@see` | The name of a related class. |
180
- | `@group` | The group to which the class belongs to. |
181
- | `@author` | The author of the class. Note that this only gets added if it is explicitly defined through the configuration class that it should. |
182
- | `@date` | The date the class was created. Note that this only gets added if it is explicitly defined through the configuration class that it should. |
183
-
184
- **Example**
185
-
186
- ```java
187
- /**
188
- * @description This is my class description.
189
- */
190
- public with sharing class TestClass { }
191
- ```
192
-
193
- ### Documenting Enums
194
-
195
- The following tags are supported on the enum level:
196
-
197
- | Tag | Description |
198
- | -------------- | -------------------------------------- |
199
- | `@description` | One or more lines describing the enum. |
200
-
201
- **Example**
202
-
203
- ```java
204
- /**
205
- * @description This is my enum description.
206
- */
207
- public Enum ExampleEnum { VALUE_1, VALUE_2 }
208
- ```
209
-
210
- ### Documenting Properties
211
-
212
- The following tags are supported on the property level:
213
-
214
- | Tag | Description |
215
- | -------------- | ------------------------------------------ |
216
- | `@description` | One or more lines describing the property. |
217
-
218
- **Example**
219
-
220
- ```java
221
- /**
222
- * @description This is my property description.
223
- */
224
- public String ExampleProperty { get; set; }
225
- ```
226
-
227
- ### Documenting Methods and Constructors
228
-
229
- Methods and constructors support the same tags.
230
-
231
- The following tags are supported on the method level:
232
-
233
- | Tag | Description |
234
- | ------------------------- | ------------------------------------------------- |
235
- | `@description` | One or more lines describing the method. |
236
- | `@param` _paramName_ | Description of a single parameter. |
237
- | `@return` | Description of the return value of the method. |
238
- | `@example` | Example of how the code can be used or called. |
239
- | `@throws` _ExceptionName_ | Description of an exception thrown by the method. |
240
-
241
- **Example**
242
-
243
- ```java
244
- /**
245
- * @description This is my method description.
246
- * @param action The action to execute.
247
- * @return The result of the operation.
248
- * @example
249
- * Object result = SampleClass.call('exampleAction');
250
- */
251
- public static Object call(String action) {
252
- ```
253
-
254
- ### Inline linking
255
-
256
- Apexdocs allows you to reference other classes from anywhere in your docs, and automatically creates a link to that class
257
- file for easy navigation.
258
-
259
- Apexdocs recognizes 2 different syntax when linking files:
260
-
261
- - Javadoc's `{@link FileName}` syntax
262
- - A class name wrapped in between `<<` `>>`.
263
-
264
- **Example**
265
-
266
- ```java
267
- /**
268
- * @description This is my method description. This method receives an <<ExampleClass>>.
269
- * @param param1 An <<ExampleClass>> instance. Can also do {@link ExampleClass}
270
- * @return The result of the operation.
271
- */
272
- public static Object class(ExampleClass param1) {
273
- ```
274
-
275
- ## Typescript
276
-
277
- ApexDocs provides all necessary type definitions.
1
+ # ApexDocs
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>
6
+
7
+ [![License](https://img.shields.io/github/license/cesarParra/apexdocs)](https://github.com/cesarParra/apexdocs/blob/master/LICENSE)
8
+
9
+ ## Description
10
+
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.
14
+
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 docGenerator a set of files that fully document each one of you classes.
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:
20
+
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.
27
+
28
+ ## Version 2.X
29
+
30
+ Version shares almost* all the same functionality (and more) of 1.X , but is a rewrite from the ground up of the tool,
31
+ so please be aware if migrating from a 1.X version.
32
+
33
+ The Apex code parsing logic for the 1.X codebase was almost a one-to-one translation of the Java based ApexDoc tool to
34
+ Javascript. With 2.X the parsing logic has been improved and extracted out of this codebase, and into its own standalone
35
+ NPM module which is solely focused on Apex code reflection: https://www.npmjs.com/package/@cparra/apex-reflection
36
+
37
+ This allows for an improved code quality of both code bases and an increased ease of introducing future improvements and
38
+ fixing issues.
39
+
40
+ But please be aware: migration to 2.X is not recommended at this time for production until a GA release.
41
+
42
+ ### Differences between the versions
43
+
44
+ When migrating from 1.X please be aware of these changes between the major versions:
45
+
46
+ #### Deprecated features
47
+
48
+ * The `--group` CLI parameter has been deprecated. All files are grouped by default.
49
+
50
+ #### Features not yet migrated to 2.X
51
+
52
+ * The `--configPath` CLI parameter has been temporarily deprecated. We are planning on reintroducing it but the config
53
+ file will use a different format.
54
+ * Internal linking between files using the `@see` annotation and {@link FileName} and <<FileName>> syntax has not been
55
+ implemented.
56
+
57
+ #### New features
58
+
59
+ * All Apex annotations are now supported through the `--scope` CLI parameter, not just `namespaceaccessible`. This means
60
+ that scopes like `auraenabled`, `invocablemethod`, `invocablevariable`, `remoteaction`, and all other valid Apex
61
+ annotations are supported.
62
+ * Just like Javadoc, both `@throws` and `@exception` are supported when referencing an exception thrown by a method or
63
+ constructor.
64
+ * Any custom annotation defined in the Apexdoc is at the class level are supported, for example the following will be
65
+ output to the resulting markdown file:
66
+
67
+ ```apex
68
+ /**
69
+ * @MyCustomAnnotation This is a custom annotation
70
+ */
71
+ public class MyClass {
72
+ }
73
+ ```
74
+
75
+ ### Demo
76
+
77
+ ApexDocs currently supports generating markdown files for Jekyll and Docsify sites.
78
+
79
+ ### In the wild
80
+
81
+ - [Nimble AMS Docs](https://nimbleuser.github.io/nams-api-docs/#/api-reference/)
82
+ - [Yet Another Salesforce Logger](https://cesarparra.github.io/yet-another-salesforce-logger/#/)
83
+
84
+ ### [Docsify](https://docsify.js.org/)
85
+
86
+ Demo
87
+
88
+ - [Docsify](https://cesarparra.github.io/apexdocs-docsify-example/)
89
+
90
+ ### [Jekyll](https://jekyllrb.com/)
91
+
92
+ Demo
93
+
94
+ - [Jekyll](https://cesarparra.github.io/apexdocs/)
95
+
96
+ ## Installation
97
+
98
+ ```bash
99
+ npm i -g @cparra/apexdocs
100
+ ```
101
+
102
+ ## Usage
103
+
104
+ ### CLI
105
+
106
+ ```bash
107
+ apexdocs-generate
108
+ -s src
109
+ -t docs
110
+ -p global
111
+ -g docsify
112
+ ```
113
+
114
+ The CLI supports the following parameters:
115
+
116
+ | Parameter | Alias | Description | Default | Required |
117
+ | ----------------- | ----- | ---------------------------------------------------------------------------------------------------------------- | ----------------------------------- | -------- |
118
+ | --sourceDir | -s | The directory location which contains your apex .cls classes. | N/A | Yes |
119
+ | --targetDir | -t | The directory location where documentation will be generated to. | `docs` | No |
120
+ | --recursive | -r | Whether .cls classes will be searched for recursively in the directory provided. | `true` | No |
121
+ | --scope | -p | A list of scopes to document. Values should be separated by a space, e.g --scope public private | `global namespaceaccessible public` | No |
122
+ | --targetGenerator | -g | Define the static file generator for which the documents will be created. Currently supports jekyll and docsify. | `jekyll` | No |
123
+ | --configPath | -c | The path to the JSON configuration file that defines the structure of the documents to docGenerator. | N/A | No |
124
+ | --group | -o | Define whether the generated files should be grouped by the @group tag on the top level classes. | `true` | No |
125
+
126
+ #### Configuration File
127
+
128
+ You can optionally specify the path to a configuration JSON file through the `--configPath` parameter. This let's you
129
+ have some additional control over the content outputs.
130
+
131
+ The configuration file allows you to specify the following:
132
+
133
+ _Note_: Everything in the configuration file is optional. When something is not specified, the default will be used.
134
+
135
+ `root` (String)
136
+
137
+ Default: None
138
+
139
+ Allows you to specify the root directory for where the files are being generated. This can be helpful when embedding the
140
+ generated docs into an existing site so that the links are generated correctly.
141
+
142
+ `defaultGroupName`
143
+
144
+ Default: Miscellaneous
145
+
146
+ Defines the `@group` name to be used when a file does not specify it.
147
+
148
+ `sourceLanguage`
149
+
150
+ Default: None
151
+
152
+ Defines the name of the language that will be used when generating `@example` blocks. Use this when you are interested
153
+ in using syntax highlighting for your project.
154
+
155
+ Even though the source code material for which documentation is generated is always `Apex`, generally you will be able
156
+ to use a syntax highlighter that recognizes `java` source code, so set this value to `java` in those cases.
157
+
158
+ `home` (Object)
159
+
160
+ Gives you control over the home page.
161
+
162
+ `home.header` (String)
163
+
164
+ Default: None
165
+
166
+ Allows you to embed custom content into your home page by using the `header` property to point to the file which
167
+ contents will be added to the top of the generated home page.
168
+
169
+ Specify the path with the content that you want to embed.
170
+
171
+ `content` (Object)
172
+
173
+ Gives you control over the content pages.
174
+
175
+ `content.includeAuthor` (Boolean)
176
+
177
+ Default: false
178
+
179
+ Whether the `@author` tag should be used to add the file's author to the page.
180
+
181
+ `content.includeDate` (Boolean)
182
+
183
+ Default: false
184
+
185
+ Whether the `@date` tag should be used to add the file's date to the page.
186
+
187
+ `content.startingHeadingLevel` (Number)
188
+
189
+ Default: 1
190
+
191
+ The starting H tag level for the document. Each title will use this as the starting point to docGenerator the
192
+ appropriate `<h#>` tag. For example, if set to 1, the class' file name at the top of the file will use an `<h1>` tag,
193
+ the `Properties` title will be `<h2>`, each property name will be an `<h3>`, etc.
194
+
195
+ ```
196
+ {
197
+ "root": "root-directory",
198
+ "defaultGrouName": "api",
199
+ "sourceLanguage": "java",
200
+ "home": {
201
+ "header": "./examples/includes/header.md"
202
+ },
203
+ "content": {
204
+ "startingHeadingLevel": 1,
205
+ "includeAuthor": true,
206
+ "includeDate": true
207
+ }
208
+ }
209
+ ```
210
+
211
+ ### Importing to your project
212
+
213
+ If you are just interested in the documentation parsing capabilities, you can import ApexDocs into your own project.
214
+
215
+ Use the `docGenerator` function to create a list of `ClassModel` that includes all the parsed information from your .cls
216
+ files.
217
+
218
+ `docGenerator(sourceDirectory[,recursive][,scope][,outputDir])`
219
+
220
+ - `sourceDirectory` \<string>
221
+ - `recursive` \<boolean>
222
+ - `scope` \<string[]>
223
+ - `outpurDir` \<string>
224
+
225
+ ```javascript
226
+ var { docGenerator } = require('@cparra/apexdocs');
227
+
228
+ let documentedClasses = docGenerator('src', true, ['global'], 'docs');
229
+ ```
230
+
231
+ ## Documentation Format
232
+
233
+ ApexDocs picks up blocks of comments throughout your `.cls` files. The block must begin with `/**` and span through
234
+ multiple lines, ending with `*/`.
235
+
236
+ ### Documenting Classes
237
+
238
+ The following tags are supported on the class level:
239
+
240
+ | Tag | Description |
241
+ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
242
+ | `@description` | One or more lines describing the class. |
243
+ | `@see` | The name of a related class. |
244
+ | `@group` | The group to which the class belongs to. |
245
+ | `@author` | The author of the class. Note that this only gets added if it is explicitly defined through the configuration class that it should. |
246
+ | `@date` | The date the class was created. Note that this only gets added if it is explicitly defined through the configuration class that it should. |
247
+
248
+ **Example**
249
+
250
+ ```apex
251
+ /**
252
+ * @description This is my class description.
253
+ */
254
+ public with sharing class TestClass {
255
+ }
256
+ ```
257
+
258
+ ### Documenting Enums
259
+
260
+ The following tags are supported on the enum level:
261
+
262
+ | Tag | Description |
263
+ | -------------- | -------------------------------------- |
264
+ | `@description` | One or more lines describing the enum. |
265
+
266
+ **Example**
267
+
268
+ ```apex
269
+ /**
270
+ * @description This is my enum description.
271
+ */
272
+ public Enum ExampleEnum {
273
+ VALUE_1, VALUE_2
274
+ }
275
+ ```
276
+
277
+ ### Documenting Properties
278
+
279
+ The following tags are supported on the property level:
280
+
281
+ | Tag | Description |
282
+ | -------------- | ------------------------------------------ |
283
+ | `@description` | One or more lines describing the property. |
284
+
285
+ **Example**
286
+
287
+ ```apex
288
+ /**
289
+ * @description This is my property description.
290
+ */
291
+ public String ExampleProperty { get; set; }
292
+ ```
293
+
294
+ ### Documenting Methods and Constructors
295
+
296
+ Methods and constructors support the same tags.
297
+
298
+ The following tags are supported on the method level:
299
+
300
+ | Tag | Description |
301
+ | ------------------------- | ------------------------------------------------- |
302
+ | `@description` | One or more lines describing the method. |
303
+ | `@param` _paramName_ | Description of a single parameter. |
304
+ | `@return` | Description of the return value of the method. |
305
+ | `@example` | Example of how the code can be used or called. |
306
+ | `@throws` _ExceptionName_ | Description of an exception thrown by the method. |
307
+
308
+ **Example**
309
+
310
+ ```apex
311
+ /**
312
+ * @description This is my method description.
313
+ * @param action The action to execute.
314
+ * @return The result of the operation.
315
+ * @example
316
+ * Object result = SampleClass.call('exampleAction');
317
+ */
318
+ public static Object call(String action) {
319
+ ```
320
+
321
+ ### Inline linking
322
+
323
+ Apexdocs allows you to reference other classes from anywhere in your docs, and automatically creates a link to that
324
+ class file for easy navigation.
325
+
326
+ Apexdocs recognizes 2 different syntax when linking files:
327
+
328
+ - Javadoc's `{@link FileName}` syntax
329
+ - A class name wrapped in between `<<` `>>`.
330
+
331
+ **Example**
332
+
333
+ ```apex
334
+ /**
335
+ * @description This is my method description. This method receives an <<ExampleClass>>.
336
+ * @param param1 An <<ExampleClass>> instance. Can also do {@link ExampleClass}
337
+ * @return The result of the operation.
338
+ */
339
+ public static Object class(ExampleClass param1) {
340
+ ```
341
+
342
+ ## Typescript
343
+
344
+ ApexDocs provides all necessary type definitions.