@cparra/apexdocs 2.24.0 → 2.25.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +12 -12
- package/.github/workflows/ci.yaml +22 -0
- package/.github/workflows/close_stale.yml +22 -22
- package/.prettierrc.js +7 -7
- package/LICENSE +21 -21
- package/README.md +742 -718
- package/apexdocs.config.ts +13 -13
- package/docs/{README.md → __old/README.md} +1 -1
- package/docs/{restapi.json → __old/restapi.json} +589 -589
- package/docs/{types → __old/types}/Classes/nspc.ChildClass.md +97 -97
- package/docs/{types → __old/types}/Main/nspc.SampleClass.md +189 -189
- package/examples/force-app/main/default/classes/AnotherInterface.cls +16 -16
- package/examples/force-app/main/default/classes/ChildClass.cls +42 -42
- package/examples/force-app/main/default/classes/EscapedAnnotations.cls +5 -5
- package/examples/force-app/main/default/classes/GrandparentClass.cls +4 -4
- package/examples/force-app/main/default/classes/GroupedClass.cls +8 -8
- package/examples/force-app/main/default/classes/MemberGrouping.cls +17 -17
- package/examples/force-app/main/default/classes/ParentClass.cls +16 -16
- package/examples/force-app/main/default/classes/SampleClass.cls +166 -166
- package/examples/force-app/main/default/classes/SampleClass.cls-meta.xml +5 -5
- package/examples/force-app/main/default/classes/SampleClassWithoutModifier.cls +9 -9
- package/examples/force-app/main/default/classes/SampleInterface.cls +16 -16
- package/examples/force-app/main/default/restapi/SampleRestResource.cls +195 -195
- package/examples/force-app/main/default/restapi/SampleRestResourceToSkip.cls +35 -35
- package/examples/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +24 -24
- package/examples/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +15 -15
- package/examples/force-app/main/default/restapi/references/Reference1.cls +9 -9
- package/examples/force-app/main/default/restapi/references/Reference2.cls +9 -9
- package/examples/force-app/main/default/restapi/references/Reference3.cls +3 -3
- package/examples/force-app/main/default/restapi/references/Reference4.cls +3 -3
- package/examples/force-app/main/default/restapi/references/Reference5.cls +3 -3
- package/examples/force-app/main/default/restapi/references/Reference6.cls +6 -6
- package/examples/force-app/main/default/restapi/references/Reference7.cls +3 -3
- package/examples/includes/header.md +3 -3
- package/examples/plain-markdown/.forceignore +12 -0
- package/examples/plain-markdown/README.md +301 -0
- package/examples/plain-markdown/config/project-scratch-def.json +5 -0
- package/examples/plain-markdown/force-app/classes/BaseClass.cls +3 -0
- package/examples/plain-markdown/force-app/classes/ParentInterface.cls +3 -0
- package/examples/plain-markdown/force-app/classes/ReferencedEnum.cls +3 -0
- package/examples/plain-markdown/force-app/classes/SampleClass.cls +35 -0
- package/examples/plain-markdown/force-app/classes/SampleEnum.cls +30 -0
- package/examples/plain-markdown/force-app/classes/SampleException.cls +1 -0
- package/examples/plain-markdown/force-app/classes/SampleInterface.cls +46 -0
- package/examples/plain-markdown/package-lock.json +665 -0
- package/examples/plain-markdown/package.json +24 -0
- package/examples/plain-markdown/sfdx-project.json +12 -0
- package/examples/plain-markdown/template.md +3 -0
- package/jest.config.js +5 -5
- package/lib/adapters/apex-types.d.ts +5 -0
- package/lib/adapters/apex-types.js +34 -0
- package/lib/adapters/apex-types.js.map +1 -0
- package/lib/adapters/documentables.d.ts +6 -0
- package/lib/adapters/documentables.js +41 -0
- package/lib/adapters/documentables.js.map +1 -0
- package/lib/adapters/fields-and-properties.d.ts +3 -0
- package/lib/adapters/fields-and-properties.js +10 -0
- package/lib/adapters/fields-and-properties.js.map +1 -0
- package/lib/adapters/methods-and-constructors.d.ts +4 -0
- package/lib/adapters/methods-and-constructors.js +49 -0
- package/lib/adapters/methods-and-constructors.js.map +1 -0
- package/lib/adapters/references.d.ts +5 -0
- package/lib/adapters/references.js +82 -0
- package/lib/adapters/references.js.map +1 -0
- package/lib/adapters/type-utils.d.ts +2 -0
- package/lib/adapters/type-utils.js +8 -0
- package/lib/adapters/type-utils.js.map +1 -0
- package/lib/application/Apexdocs.d.ts +13 -13
- package/lib/application/Apexdocs.js +79 -76
- package/lib/application/Apexdocs.js.map +1 -1
- package/lib/cli/generate.d.ts +2 -2
- package/lib/cli/generate.js +156 -130
- package/lib/cli/generate.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +17 -17
- package/lib/model/apex-bundle.d.ts +6 -6
- package/lib/model/apex-bundle.js +10 -10
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.d.ts +7 -7
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.js +13 -13
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.d.ts +7 -7
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.js +11 -11
- package/lib/model/inheritance.d.ts +8 -8
- package/lib/model/inheritance.js +2 -2
- package/lib/model/manifest.d.ts +22 -22
- package/lib/model/manifest.js +46 -46
- package/lib/model/manifest.js.map +1 -1
- package/lib/model/markdown-file.d.ts +16 -16
- package/lib/model/markdown-file.js +109 -106
- package/lib/model/markdown-file.js.map +1 -1
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.d.ts +8 -8
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +46 -43
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -1
- package/lib/model/markdown-generation-util/field-declaration-util.d.ts +3 -3
- package/lib/model/markdown-generation-util/field-declaration-util.js +54 -54
- package/lib/model/markdown-generation-util/index.d.ts +3 -3
- package/lib/model/markdown-generation-util/index.js +19 -19
- package/lib/model/markdown-generation-util/method-declaration-util.d.ts +4 -4
- package/lib/model/markdown-generation-util/method-declaration-util.js +114 -114
- package/lib/model/markdown-generation-util/type-declaration-util.d.ts +3 -3
- package/lib/model/markdown-generation-util/type-declaration-util.js +81 -81
- package/lib/model/markdown-home-file.d.ts +11 -11
- package/lib/model/markdown-home-file.js +56 -53
- package/lib/model/markdown-home-file.js.map +1 -1
- package/lib/model/markdown-type-file.d.ts +26 -26
- package/lib/model/markdown-type-file.js +136 -133
- package/lib/model/markdown-type-file.js.map +1 -1
- package/lib/model/openapi/apex-doc-types.d.ts +19 -19
- package/lib/model/openapi/apex-doc-types.js +4 -4
- package/lib/model/openapi/open-api-types.d.ts +93 -93
- package/lib/model/openapi/open-api-types.js +2 -2
- package/lib/model/openapi/open-api.d.ts +16 -16
- package/lib/model/openapi/open-api.js +33 -33
- package/lib/model/openapi/openapi-type-file.d.ts +7 -7
- package/lib/model/openapi/openapi-type-file.js +16 -16
- package/lib/model/outputFile.d.ts +10 -10
- package/lib/model/outputFile.js +28 -28
- package/lib/model/types-repository.d.ts +16 -16
- package/lib/model/types-repository.js +53 -53
- package/lib/service/apex-file-reader.d.ts +14 -14
- package/lib/service/apex-file-reader.js +48 -45
- package/lib/service/apex-file-reader.js.map +1 -1
- package/lib/service/file-system.d.ts +14 -14
- package/lib/service/file-system.js +47 -24
- package/lib/service/file-system.js.map +1 -1
- package/lib/service/file-writer.d.ts +6 -6
- package/lib/service/file-writer.js +56 -33
- package/lib/service/file-writer.js.map +1 -1
- package/lib/service/manifest-factory.d.ts +10 -10
- package/lib/service/manifest-factory.js +16 -13
- package/lib/service/manifest-factory.js.map +1 -1
- package/lib/service/metadata-processor.d.ts +3 -3
- package/lib/service/metadata-processor.js +16 -16
- package/lib/service/parser.d.ts +21 -21
- package/lib/service/parser.js +137 -134
- package/lib/service/parser.js.map +1 -1
- package/lib/service/state.d.ts +9 -9
- package/lib/service/state.js +19 -19
- package/lib/service/walkers/class-walker.d.ts +4 -4
- package/lib/service/walkers/class-walker.js +32 -32
- package/lib/service/walkers/enum-walker.d.ts +4 -4
- package/lib/service/walkers/enum-walker.js +10 -10
- package/lib/service/walkers/interface-walker.d.ts +4 -4
- package/lib/service/walkers/interface-walker.js +14 -14
- package/lib/service/walkers/walker-factory.d.ts +5 -5
- package/lib/service/walkers/walker-factory.js +20 -20
- package/lib/service/walkers/walker.d.ts +19 -19
- package/lib/service/walkers/walker.js +16 -16
- package/lib/settings.d.ts +70 -64
- package/lib/settings.js +99 -88
- package/lib/settings.js.map +1 -1
- package/lib/templating/compile.d.ts +7 -0
- package/lib/templating/compile.js +98 -0
- package/lib/templating/compile.js.map +1 -0
- package/lib/templating/helpers.d.ts +2 -0
- package/lib/templating/helpers.js +18 -0
- package/lib/templating/helpers.js.map +1 -0
- package/lib/test-helpers/AnnotationBuilder.d.ts +12 -12
- package/lib/test-helpers/AnnotationBuilder.js +30 -30
- package/lib/test-helpers/ClassMirrorBuilder.d.ts +18 -18
- package/lib/test-helpers/ClassMirrorBuilder.js +53 -53
- package/lib/test-helpers/DocCommentAnnotationBuilder.d.ts +8 -8
- package/lib/test-helpers/DocCommentAnnotationBuilder.js +25 -25
- package/lib/test-helpers/DocCommentBuilder.d.ts +12 -12
- package/lib/test-helpers/DocCommentBuilder.js +37 -37
- package/lib/test-helpers/FieldMirrorBuilder.d.ts +18 -18
- package/lib/test-helpers/FieldMirrorBuilder.js +53 -53
- package/lib/test-helpers/InterfaceMirrorBuilder.d.ts +16 -0
- package/lib/test-helpers/InterfaceMirrorBuilder.js +43 -0
- package/lib/test-helpers/InterfaceMirrorBuilder.js.map +1 -0
- package/lib/test-helpers/MethodMirrorBuilder.d.ts +29 -10
- package/lib/test-helpers/MethodMirrorBuilder.js +71 -36
- package/lib/test-helpers/MethodMirrorBuilder.js.map +1 -1
- package/lib/test-helpers/SettingsBuilder.d.ts +8 -8
- package/lib/test-helpers/SettingsBuilder.js +26 -26
- package/lib/transpiler/factory.d.ts +6 -6
- package/lib/transpiler/factory.js +34 -31
- package/lib/transpiler/factory.js.map +1 -1
- package/lib/transpiler/file-container.d.ts +6 -6
- package/lib/transpiler/file-container.js +15 -15
- package/lib/transpiler/generator-choices.d.ts +1 -1
- package/lib/transpiler/generator-choices.js +2 -2
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +11 -8
- package/lib/transpiler/markdown/class-file-generatorHelper.js +74 -55
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +6 -6
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js +12 -12
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +11 -11
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +50 -50
- package/lib/transpiler/markdown/markdown-transpiler-base.d.ts +11 -11
- package/lib/transpiler/markdown/markdown-transpiler-base.js +26 -23
- package/lib/transpiler/markdown/markdown-transpiler-base.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/class-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/class-template.js +36 -0
- package/lib/transpiler/markdown/plain-markdown/class-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js +39 -0
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js +25 -0
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/enum-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/enum-template.js +15 -0
- package/lib/transpiler/markdown/plain-markdown/enum-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js +24 -0
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.js +20 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js +49 -0
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +13 -6
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +121 -13
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js +31 -0
- package/lib/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.js.map +1 -0
- package/lib/transpiler/openapi/open-api-docs-processor.d.ts +13 -13
- package/lib/transpiler/openapi/open-api-docs-processor.js +77 -74
- package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -1
- package/lib/transpiler/openapi/parsers/Builder.d.ts +16 -16
- package/lib/transpiler/openapi/parsers/Builder.js +29 -29
- package/lib/transpiler/openapi/parsers/Builder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/MethodParser.d.ts +20 -20
- package/lib/transpiler/openapi/parsers/MethodParser.js +189 -166
- package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.d.ts +7 -7
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.js +10 -10
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.d.ts +39 -39
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +248 -225
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.d.ts +10 -10
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.js +19 -19
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.d.ts +7 -7
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js +21 -21
- package/lib/transpiler/processor-type-transpiler.d.ts +10 -10
- package/lib/transpiler/processor-type-transpiler.js +8 -8
- package/lib/transpiler/transpiler.d.ts +5 -5
- package/lib/transpiler/transpiler.js +29 -26
- package/lib/transpiler/transpiler.js.map +1 -1
- package/lib/util/error-logger.d.ts +8 -8
- package/lib/util/error-logger.js +89 -89
- package/lib/util/error-logger.js.map +1 -1
- package/lib/util/logger.d.ts +21 -21
- package/lib/util/logger.js +60 -57
- package/lib/util/logger.js.map +1 -1
- package/lib/util/string-utils.d.ts +2 -2
- package/lib/util/string-utils.js +14 -14
- package/package.json +79 -78
- package/src/adapters/__tests__/interface-adapter.spec.ts +76 -0
- package/src/adapters/__tests__/references.spec.ts +115 -0
- package/src/adapters/apex-types.ts +67 -0
- package/src/adapters/documentables.ts +58 -0
- package/src/adapters/fields-and-properties.ts +14 -0
- package/src/adapters/methods-and-constructors.ts +78 -0
- package/src/adapters/references.ts +113 -0
- package/src/adapters/type-utils.ts +5 -0
- package/src/adapters/types.d.ts +8 -0
- package/src/cli/generate.ts +3 -0
- package/src/model/__tests__/manifest.spec.ts +1 -0
- package/src/model/manifest.ts +3 -3
- package/src/model/markdown-file.ts +1 -1
- package/src/model/openapi/open-api-types.ts +2 -2
- package/src/service/__tests__/apex-file-reader.spec.ts +4 -4
- package/src/service/__tests__/manifest-factory.spec.ts +1 -2
- package/src/settings.ts +15 -0
- package/src/templating/__tests__/compile.spec.ts +741 -0
- package/src/templating/compile.ts +187 -0
- package/src/templating/helpers.ts +14 -0
- package/src/templating/types.d.ts +104 -0
- package/src/test-helpers/FieldMirrorBuilder.ts +1 -1
- package/src/test-helpers/InterfaceMirrorBuilder.ts +44 -0
- package/src/test-helpers/MethodMirrorBuilder.ts +46 -6
- package/src/transpiler/markdown/class-file-generatorHelper.ts +22 -2
- package/src/transpiler/markdown/plain-markdown/class-template.ts +32 -0
- package/src/transpiler/markdown/plain-markdown/constructors-partial-template.ts +35 -0
- package/src/transpiler/markdown/plain-markdown/documentable-partial-template.ts +21 -0
- package/src/transpiler/markdown/plain-markdown/enum-template.ts +11 -0
- package/src/transpiler/markdown/plain-markdown/fieldsPartialTemplate.ts +20 -0
- package/src/transpiler/markdown/plain-markdown/interface-template.ts +16 -0
- package/src/transpiler/markdown/plain-markdown/methods-partial-template.ts +45 -0
- package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +122 -0
- package/src/transpiler/markdown/plain-markdown/type-level-apex-doc-partial-template.ts +27 -0
- package/src/transpiler/openapi/parsers/Builder.ts +1 -1
- package/src/transpiler/openapi/parsers/MethodParser.ts +1 -1
- package/src/transpiler/openapi/parsers/ReferenceBuilder.ts +1 -1
- package/src/util/error-logger.ts +4 -4
- package/src/util/logger.ts +3 -3
- package/tsconfig.json +21 -20
- package/tslint.json +5 -5
- package/lib/model/manifest-diff.d.ts +0 -27
- package/lib/model/manifest-diff.js +0 -69
- package/lib/model/manifest-diff.js.map +0 -1
- package/src/model/__tests__/manifest-diff.spec.ts +0 -139
- package/src/model/manifest-diff.ts +0 -94
- /package/docs/{index.html → __old/index.html} +0 -0
- /package/docs/{types → __old/types}/Classes/nspc.AnotherInterface.md +0 -0
- /package/docs/{types → __old/types}/Main/nspc.GroupedClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.EscapedAnnotations.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.GrandparentClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.InterfaceWithInheritance.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.MemberGrouping.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.ParentClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference1.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference2.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference3.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference4.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference5.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference6.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference7.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleClassWithoutModifier.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleRestResource.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleRestResourceWithInnerClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleRestResourceWithoutApexDocs.md +0 -0
- /package/docs/{types → __old/types}/README.md +0 -0
- /package/docs/{types → __old/types}/Sample-Interfaces/nspc.SampleInterface.md +0 -0
package/package.json
CHANGED
|
@@ -1,78 +1,79 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"apex",
|
|
7
|
-
"salesforce",
|
|
8
|
-
"documentation",
|
|
9
|
-
"cli",
|
|
10
|
-
"apex-docs",
|
|
11
|
-
"docs"
|
|
12
|
-
],
|
|
13
|
-
"main": "lib/index.js",
|
|
14
|
-
"bin": {
|
|
15
|
-
"apexdocs-generate": "lib/cli/generate.js"
|
|
16
|
-
},
|
|
17
|
-
"types": "lib/index.d.ts",
|
|
18
|
-
"scripts": {
|
|
19
|
-
"test": "jest --coverage",
|
|
20
|
-
"build": "rimraf ./lib && npm run lint && tsc --declaration",
|
|
21
|
-
"lint": "eslint \"./src/**/*.{js,ts}\" --quiet --fix",
|
|
22
|
-
"prepare": "npm run build",
|
|
23
|
-
"version": "npm run format && git add -A src",
|
|
24
|
-
"postversion": "git push && git push --tags",
|
|
25
|
-
"docs:init": "docsify init docs",
|
|
26
|
-
"docs:serve": "docsify serve docs",
|
|
27
|
-
"execute:example": "rimraf ./docs/types && node lib/cli/generate.js -s examples/force-app -t docs/types --scope global public private protected -g docsify --defaultGroupName \"Misc Group\" --namespace nspc --title \"Sample Documentation\" --documentationRootDir types",
|
|
28
|
-
"execute:example:index:only": "node lib/cli/generate.js -s examples/force-app -t docs --scope global public private -g docsify --indexOnly",
|
|
29
|
-
"execute:example:openapi": "node lib/cli/generate.js -s examples/force-app -t docs -g openapi --openApiTitle \"Sample REST Api\" --namespace nspc --openApiFileName restapi"
|
|
30
|
-
},
|
|
31
|
-
"author": "Cesar Parra",
|
|
32
|
-
"license": "MIT",
|
|
33
|
-
"repository": {
|
|
34
|
-
"type": "git",
|
|
35
|
-
"url": "https://github.com/cesarParra/apexdocs"
|
|
36
|
-
},
|
|
37
|
-
"devDependencies": {
|
|
38
|
-
"@types/html-entities": "^1.3.4",
|
|
39
|
-
"@types/jest": "^
|
|
40
|
-
"@types/js-yaml": "^4.0.
|
|
41
|
-
"@types/node": "^
|
|
42
|
-
"@types/shelljs": "^0.8.
|
|
43
|
-
"@types/yargs": "^15.0.3",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
45
|
-
"@typescript-eslint/parser": "^
|
|
46
|
-
"docsify": "^4.13.
|
|
47
|
-
"eslint": "^8.0
|
|
48
|
-
"eslint-config-prettier": "^8.3.0",
|
|
49
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
50
|
-
"husky": "^8.0.3",
|
|
51
|
-
"jest": "^
|
|
52
|
-
"lint-staged": "^13.2.1",
|
|
53
|
-
"prettier": "^2.
|
|
54
|
-
"rimraf": "^3.0.2",
|
|
55
|
-
"ts-jest": "^
|
|
56
|
-
"typescript": "^4.8.4"
|
|
57
|
-
},
|
|
58
|
-
"husky": {
|
|
59
|
-
"hooks": {
|
|
60
|
-
"pre-commit": "lint-staged"
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
"lint-staged": {
|
|
64
|
-
"*.{js,ts,tsx}": [
|
|
65
|
-
"eslint --fix"
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
"dependencies": {
|
|
69
|
-
"@cparra/apex-reflection": "2.
|
|
70
|
-
"chalk": "^4.1.2",
|
|
71
|
-
"cosmiconfig": "^9.0.0",
|
|
72
|
-
"fast-xml-parser": "^4.0
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@cparra/apexdocs",
|
|
3
|
+
"version": "2.25.0-alpha.0",
|
|
4
|
+
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"apex",
|
|
7
|
+
"salesforce",
|
|
8
|
+
"documentation",
|
|
9
|
+
"cli",
|
|
10
|
+
"apex-docs",
|
|
11
|
+
"docs"
|
|
12
|
+
],
|
|
13
|
+
"main": "lib/index.js",
|
|
14
|
+
"bin": {
|
|
15
|
+
"apexdocs-generate": "lib/cli/generate.js"
|
|
16
|
+
},
|
|
17
|
+
"types": "lib/index.d.ts",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"test": "jest --coverage",
|
|
20
|
+
"build": "rimraf ./lib && npm run lint && tsc --declaration",
|
|
21
|
+
"lint": "eslint \"./src/**/*.{js,ts}\" --quiet --fix",
|
|
22
|
+
"prepare": "npm run build",
|
|
23
|
+
"version": "npm run format && git add -A src",
|
|
24
|
+
"postversion": "git push && git push --tags",
|
|
25
|
+
"docs:init": "docsify init docs",
|
|
26
|
+
"docs:serve": "docsify serve docs",
|
|
27
|
+
"execute:example": "rimraf ./docs/types && node lib/cli/generate.js -s examples/force-app -t docs/types --scope global public private protected -g docsify --defaultGroupName \"Misc Group\" --namespace nspc --title \"Sample Documentation\" --documentationRootDir types",
|
|
28
|
+
"execute:example:index:only": "node lib/cli/generate.js -s examples/force-app -t docs --scope global public private -g docsify --indexOnly",
|
|
29
|
+
"execute:example:openapi": "node lib/cli/generate.js -s examples/force-app -t docs -g openapi --openApiTitle \"Sample REST Api\" --namespace nspc --openApiFileName restapi"
|
|
30
|
+
},
|
|
31
|
+
"author": "Cesar Parra",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/cesarParra/apexdocs"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/html-entities": "^1.3.4",
|
|
39
|
+
"@types/jest": "^29.5.12",
|
|
40
|
+
"@types/js-yaml": "^4.0.9",
|
|
41
|
+
"@types/node": "^20.14.2",
|
|
42
|
+
"@types/shelljs": "^0.8.15",
|
|
43
|
+
"@types/yargs": "^15.0.3",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^7.12.0",
|
|
45
|
+
"@typescript-eslint/parser": "^7.12.0",
|
|
46
|
+
"docsify": "^4.13.1",
|
|
47
|
+
"eslint": "^8.57.0",
|
|
48
|
+
"eslint-config-prettier": "^8.3.0",
|
|
49
|
+
"eslint-plugin-prettier": "^4.0.0",
|
|
50
|
+
"husky": "^8.0.3",
|
|
51
|
+
"jest": "^29.7.0",
|
|
52
|
+
"lint-staged": "^13.2.1",
|
|
53
|
+
"prettier": "^2.8.8",
|
|
54
|
+
"rimraf": "^3.0.2",
|
|
55
|
+
"ts-jest": "^29.1.4",
|
|
56
|
+
"typescript": "^4.8.4"
|
|
57
|
+
},
|
|
58
|
+
"husky": {
|
|
59
|
+
"hooks": {
|
|
60
|
+
"pre-commit": "lint-staged"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
"lint-staged": {
|
|
64
|
+
"*.{js,ts,tsx}": [
|
|
65
|
+
"eslint --fix"
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
"dependencies": {
|
|
69
|
+
"@cparra/apex-reflection": "2.9.2",
|
|
70
|
+
"chalk": "^4.1.2",
|
|
71
|
+
"cosmiconfig": "^9.0.0",
|
|
72
|
+
"fast-xml-parser": "^4.4.0",
|
|
73
|
+
"handlebars": "^4.7.8",
|
|
74
|
+
"js-yaml": "^4.1.0",
|
|
75
|
+
"log-update": "4.0.0",
|
|
76
|
+
"xss": "^1.0.11",
|
|
77
|
+
"yargs": "^16.0.3"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { InterfaceMirrorBuilder } from '../../test-helpers/InterfaceMirrorBuilder';
|
|
2
|
+
import { AnnotationBuilder } from '../../test-helpers/AnnotationBuilder';
|
|
3
|
+
import { MethodMirrorBuilder, ParameterBuilder } from '../../test-helpers/MethodMirrorBuilder';
|
|
4
|
+
import { interfaceTypeToInterfaceSource } from '../apex-types';
|
|
5
|
+
|
|
6
|
+
describe('Conversion from InterfaceMirror to InterfaceSource understandable by the templating engine', () => {
|
|
7
|
+
it('converts the name', () => {
|
|
8
|
+
const interfaceMirror = new InterfaceMirrorBuilder().withName('SampleInterface').build();
|
|
9
|
+
const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
|
|
10
|
+
|
|
11
|
+
expect(interfaceSource.name).toBe('SampleInterface');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('converts the access modifier', () => {
|
|
15
|
+
const interfaceMirror = new InterfaceMirrorBuilder().build();
|
|
16
|
+
const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
|
|
17
|
+
|
|
18
|
+
expect(interfaceSource.accessModifier).toBe('public');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('converts annotations', () => {
|
|
22
|
+
const interfaceMirror = new InterfaceMirrorBuilder()
|
|
23
|
+
.addAnnotation(new AnnotationBuilder().withName('MyAnnotation').build())
|
|
24
|
+
.build();
|
|
25
|
+
const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
|
|
26
|
+
|
|
27
|
+
expect(interfaceSource.annotations).toEqual(['MYANNOTATION']);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('converts method declarations. Method with no parameters', () => {
|
|
31
|
+
const interfaceMirror = new InterfaceMirrorBuilder()
|
|
32
|
+
.addMethod(
|
|
33
|
+
new MethodMirrorBuilder()
|
|
34
|
+
.withName('sampleMethod')
|
|
35
|
+
.withTypeReference({
|
|
36
|
+
type: 'String',
|
|
37
|
+
rawDeclaration: 'String',
|
|
38
|
+
})
|
|
39
|
+
.build(),
|
|
40
|
+
)
|
|
41
|
+
.build();
|
|
42
|
+
|
|
43
|
+
const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
|
|
44
|
+
|
|
45
|
+
expect(interfaceSource.methods).toHaveLength(1);
|
|
46
|
+
expect(interfaceSource.methods![0].signature).toBe('public String sampleMethod()');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('converts method declarations. Method with parameters', () => {
|
|
50
|
+
const interfaceMirror = new InterfaceMirrorBuilder()
|
|
51
|
+
.addMethod(
|
|
52
|
+
new MethodMirrorBuilder()
|
|
53
|
+
.withName('sampleMethod')
|
|
54
|
+
.withTypeReference({
|
|
55
|
+
type: 'String',
|
|
56
|
+
rawDeclaration: 'String',
|
|
57
|
+
})
|
|
58
|
+
.addParameter(
|
|
59
|
+
new ParameterBuilder()
|
|
60
|
+
.withName('param1')
|
|
61
|
+
.withTypeReference({
|
|
62
|
+
type: 'String',
|
|
63
|
+
rawDeclaration: 'String',
|
|
64
|
+
})
|
|
65
|
+
.build(),
|
|
66
|
+
)
|
|
67
|
+
.build(),
|
|
68
|
+
)
|
|
69
|
+
.build();
|
|
70
|
+
|
|
71
|
+
const interfaceSource = interfaceTypeToInterfaceSource(interfaceMirror);
|
|
72
|
+
|
|
73
|
+
expect(interfaceSource.methods).toHaveLength(1);
|
|
74
|
+
expect(interfaceSource.methods![0].signature).toBe('public String sampleMethod(String param1)');
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { replaceInlineReferences } from '../references';
|
|
2
|
+
import { Link } from '../../templating/types';
|
|
3
|
+
|
|
4
|
+
function getFileLink(typeName: string): Link {
|
|
5
|
+
return {
|
|
6
|
+
title: typeName,
|
|
7
|
+
url: `/api/${typeName}.html`,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getEmailLink(typeName: string) {
|
|
12
|
+
return {
|
|
13
|
+
title: typeName,
|
|
14
|
+
url: `mailto:${typeName}`,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('reference utilities', () => {
|
|
19
|
+
it('returns a RenderableContent array with the full string when there are no links', () => {
|
|
20
|
+
const text = 'This is a test';
|
|
21
|
+
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
22
|
+
|
|
23
|
+
const expected = ['This is a test'];
|
|
24
|
+
|
|
25
|
+
expect(result).toEqual(expected);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('replace inline links', () => {
|
|
29
|
+
it('replaces links in the format of <<ClassName>>', () => {
|
|
30
|
+
const text = 'This is a test <<ClassName>>.';
|
|
31
|
+
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
32
|
+
|
|
33
|
+
const expected = [
|
|
34
|
+
'This is a test ',
|
|
35
|
+
{
|
|
36
|
+
title: 'ClassName',
|
|
37
|
+
url: '/api/ClassName.html',
|
|
38
|
+
},
|
|
39
|
+
'.',
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
expect(result).toEqual(expected);
|
|
43
|
+
});
|
|
44
|
+
it('replaces links in the format of {@link ClassName}', () => {
|
|
45
|
+
function getFileLinkByTypeName(typeName: string): Link {
|
|
46
|
+
return {
|
|
47
|
+
title: typeName,
|
|
48
|
+
url: `/api/${typeName}.html`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const text = 'This is a test {@link ClassName}';
|
|
53
|
+
const result = replaceInlineReferences(text, getFileLinkByTypeName, getEmailLink);
|
|
54
|
+
|
|
55
|
+
const expected = [
|
|
56
|
+
'This is a test ',
|
|
57
|
+
{
|
|
58
|
+
title: 'ClassName',
|
|
59
|
+
url: '/api/ClassName.html',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
expect(result).toEqual(expected);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('replace inline emails', () => {
|
|
68
|
+
it('replaces emails in the format of {@email email-address}', () => {
|
|
69
|
+
function getLinkByTypeName(typeName: string) {
|
|
70
|
+
return {
|
|
71
|
+
title: typeName,
|
|
72
|
+
url: `mailto:${typeName}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const text = 'This is an email {@email example@example.com}';
|
|
77
|
+
const result = replaceInlineReferences(text, getFileLink, getLinkByTypeName);
|
|
78
|
+
|
|
79
|
+
const expected = [
|
|
80
|
+
'This is an email ',
|
|
81
|
+
{
|
|
82
|
+
title: 'example@example.com',
|
|
83
|
+
url: 'mailto:example@example.com',
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
expect(result).toEqual(expected);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('replaces both links and emails in the same string', () => {
|
|
92
|
+
const text = 'This is a test <<ClassName>>, and {@link AnotherClass}, and an email {@email testerson}';
|
|
93
|
+
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
94
|
+
|
|
95
|
+
const expected = [
|
|
96
|
+
'This is a test ',
|
|
97
|
+
{
|
|
98
|
+
title: 'ClassName',
|
|
99
|
+
url: '/api/ClassName.html',
|
|
100
|
+
},
|
|
101
|
+
', and ',
|
|
102
|
+
{
|
|
103
|
+
title: 'AnotherClass',
|
|
104
|
+
url: '/api/AnotherClass.html',
|
|
105
|
+
},
|
|
106
|
+
', and an email ',
|
|
107
|
+
{
|
|
108
|
+
title: 'testerson',
|
|
109
|
+
url: 'mailto:testerson',
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
expect(result).toEqual(expected);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ClassMirror, EnumMirror, InterfaceMirror, Type } from '@cparra/apex-reflection';
|
|
2
|
+
import { BaseTypeSource, ClassSource, EnumSource, InterfaceSource } from '../templating/types';
|
|
3
|
+
import { adaptDescribable, adaptDocumentable } from './documentables';
|
|
4
|
+
import { linkFromTypeNameGenerator } from './references';
|
|
5
|
+
import { FieldMirrorWithInheritance } from '../model/inheritance';
|
|
6
|
+
import { adaptConstructor, adaptMethod } from './methods-and-constructors';
|
|
7
|
+
import { adaptField } from './fields-and-properties';
|
|
8
|
+
|
|
9
|
+
function baseTypeAdapter(type: EnumMirror | InterfaceMirror | ClassMirror): BaseTypeSource {
|
|
10
|
+
function extractAnnotationBody(type: Type, annotationName: string): string | undefined {
|
|
11
|
+
return type.docComment?.annotations.find(
|
|
12
|
+
(currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName,
|
|
13
|
+
)?.body;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function extractSeeAnnotations(type: Type): string[] {
|
|
17
|
+
return (
|
|
18
|
+
type.docComment?.annotations
|
|
19
|
+
.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === 'see')
|
|
20
|
+
.map((currentAnnotation) => currentAnnotation.body) ?? []
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
...adaptDocumentable(type),
|
|
26
|
+
accessModifier: type.access_modifier,
|
|
27
|
+
name: type.name,
|
|
28
|
+
group: extractAnnotationBody(type, 'group'),
|
|
29
|
+
author: extractAnnotationBody(type, 'author'),
|
|
30
|
+
date: extractAnnotationBody(type, 'date'),
|
|
31
|
+
sees: extractSeeAnnotations(type).map(linkFromTypeNameGenerator),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function enumTypeToEnumSource(enumType: EnumMirror): EnumSource {
|
|
36
|
+
return {
|
|
37
|
+
__type: 'enum',
|
|
38
|
+
...baseTypeAdapter(enumType),
|
|
39
|
+
values: enumType.values.map((value) => ({
|
|
40
|
+
...adaptDescribable(value.docComment?.descriptionLines),
|
|
41
|
+
value: value.name,
|
|
42
|
+
})),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function interfaceTypeToInterfaceSource(interfaceType: InterfaceMirror): InterfaceSource {
|
|
47
|
+
return {
|
|
48
|
+
__type: 'interface',
|
|
49
|
+
...baseTypeAdapter(interfaceType),
|
|
50
|
+
extends: interfaceType.extended_interfaces.map(linkFromTypeNameGenerator),
|
|
51
|
+
methods: interfaceType.methods.map(adaptMethod),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function classTypeToClassSource(classType: ClassMirror): ClassSource {
|
|
56
|
+
return {
|
|
57
|
+
__type: 'class',
|
|
58
|
+
...baseTypeAdapter(classType),
|
|
59
|
+
classModifier: classType.classModifier,
|
|
60
|
+
sharingModifier: classType.sharingModifier,
|
|
61
|
+
implements: classType.implemented_interfaces.map(linkFromTypeNameGenerator),
|
|
62
|
+
extends: classType.extended_class ? linkFromTypeNameGenerator(classType.extended_class) : undefined,
|
|
63
|
+
methods: classType.methods.map(adaptMethod),
|
|
64
|
+
constructors: classType.constructors.map((constructor) => adaptConstructor(classType.name, constructor)),
|
|
65
|
+
fields: classType.fields.map((field) => adaptField(field as FieldMirrorWithInheritance)),
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { CustomTag, DocumentableSource, RenderableContent } from '../templating/types';
|
|
2
|
+
import { Describable, Documentable } from './types';
|
|
3
|
+
import { replaceInlineReferences } from './references';
|
|
4
|
+
import { isEmptyLine } from './type-utils';
|
|
5
|
+
|
|
6
|
+
export function adaptDescribable(describable: Describable): { description?: RenderableContent[] } {
|
|
7
|
+
function describableToRenderableContent(describable: Describable): RenderableContent[] | undefined {
|
|
8
|
+
if (!describable) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
describable
|
|
14
|
+
.map<RenderableContent[]>((line) => [
|
|
15
|
+
...replaceInlineReferences(line),
|
|
16
|
+
{
|
|
17
|
+
type: 'empty-line',
|
|
18
|
+
},
|
|
19
|
+
])
|
|
20
|
+
.flatMap((line) => line)
|
|
21
|
+
// If the last element is an empty line, remove it
|
|
22
|
+
.filter((line, index, lines) => !(isEmptyLine(line) && index === lines.length - 1))
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
description: describableToRenderableContent(describable),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function adaptDocumentable(documentable: Documentable): DocumentableSource {
|
|
32
|
+
function extractCustomTags(type: Documentable): CustomTag[] {
|
|
33
|
+
const baseTags = ['description', 'group', 'author', 'date', 'see', 'example', 'mermaid', 'throws', 'exception'];
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
type.docComment?.annotations
|
|
37
|
+
.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase()))
|
|
38
|
+
.map<CustomTag>((currentAnnotation) => ({
|
|
39
|
+
...adaptDescribable(currentAnnotation.bodyLines),
|
|
40
|
+
name: currentAnnotation.name,
|
|
41
|
+
})) ?? []
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function extractAnnotationBodyLines(type: Documentable, annotationName: string): string[] | undefined {
|
|
46
|
+
return type.docComment?.annotations.find(
|
|
47
|
+
(currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName,
|
|
48
|
+
)?.bodyLines;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
...adaptDescribable(documentable.docComment?.descriptionLines),
|
|
53
|
+
annotations: documentable.annotations.map((annotation) => annotation.type.toUpperCase()),
|
|
54
|
+
customTags: extractCustomTags(documentable),
|
|
55
|
+
mermaid: extractAnnotationBodyLines(documentable, 'mermaid'),
|
|
56
|
+
example: documentable.docComment?.exampleAnnotation?.bodyLines,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FieldMirrorWithInheritance } from '../model/inheritance';
|
|
2
|
+
import { FieldSource } from '../templating/types';
|
|
3
|
+
import { adaptDocumentable } from './documentables';
|
|
4
|
+
import { linkFromTypeNameGenerator } from './references';
|
|
5
|
+
|
|
6
|
+
export function adaptField(field: FieldMirrorWithInheritance): FieldSource {
|
|
7
|
+
return {
|
|
8
|
+
...adaptDocumentable(field),
|
|
9
|
+
name: field.name,
|
|
10
|
+
type: linkFromTypeNameGenerator(field.typeReference.rawDeclaration),
|
|
11
|
+
inherited: field.inherited,
|
|
12
|
+
accessModifier: field.access_modifier,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ConstructorMirror, MethodMirror, ParameterMirror, ThrowsAnnotation } from '@cparra/apex-reflection';
|
|
2
|
+
import { ConstructorSource, MethodSource } from '../templating/types';
|
|
3
|
+
import { MethodMirrorWithInheritance } from '../model/inheritance';
|
|
4
|
+
import { adaptDescribable, adaptDocumentable } from './documentables';
|
|
5
|
+
import { linkFromTypeNameGenerator } from './references';
|
|
6
|
+
import { Documentable } from './types';
|
|
7
|
+
|
|
8
|
+
export function adaptMethod(method: MethodMirror): MethodSource {
|
|
9
|
+
function buildTitle(method: MethodMirrorWithInheritance): string {
|
|
10
|
+
const { name, parameters } = method;
|
|
11
|
+
const parametersString = parameters.map((param) => param.name).join(', ');
|
|
12
|
+
return `${name}(${parametersString})`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function buildSignature(method: MethodMirrorWithInheritance): string {
|
|
16
|
+
const { access_modifier, typeReference, name, memberModifiers } = method;
|
|
17
|
+
const parameters = method.parameters
|
|
18
|
+
.map((param) => `${param.typeReference.rawDeclaration} ${param.name}`)
|
|
19
|
+
.join(', ');
|
|
20
|
+
const members = memberModifiers.length > 0 ? `${memberModifiers.join(' ')} ` : '';
|
|
21
|
+
return `${access_modifier} ${members}${typeReference.rawDeclaration} ${name}(${parameters})`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
...adaptDocumentable(method),
|
|
26
|
+
title: buildTitle(method as MethodMirrorWithInheritance),
|
|
27
|
+
signature: buildSignature(method as MethodMirrorWithInheritance),
|
|
28
|
+
returnType: {
|
|
29
|
+
...adaptDescribable(method.docComment?.returnAnnotation?.bodyLines),
|
|
30
|
+
type: linkFromTypeNameGenerator(method.typeReference.rawDeclaration),
|
|
31
|
+
},
|
|
32
|
+
throws: method.docComment?.throwsAnnotations.map((thrown) => mapThrows(thrown)),
|
|
33
|
+
parameters: method.parameters.map((param) => mapParameters(method, param)),
|
|
34
|
+
inherited: (method as MethodMirrorWithInheritance).inherited,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function adaptConstructor(typeName: string, constructor: ConstructorMirror): ConstructorSource {
|
|
39
|
+
function buildTitle(name: string, constructor: ConstructorMirror): string {
|
|
40
|
+
const { parameters } = constructor;
|
|
41
|
+
const parametersString = parameters.map((param) => param.name).join(', ');
|
|
42
|
+
return `${name}(${parametersString})`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function buildSignature(name: string, constructor: ConstructorMirror): string {
|
|
46
|
+
const { access_modifier } = constructor;
|
|
47
|
+
const parameters = constructor.parameters
|
|
48
|
+
.map((param) => `${param.typeReference.rawDeclaration} ${param.name}`)
|
|
49
|
+
.join(', ');
|
|
50
|
+
return `${access_modifier} ${name}(${parameters})`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
...adaptDocumentable(constructor),
|
|
55
|
+
title: buildTitle(typeName, constructor),
|
|
56
|
+
signature: buildSignature(typeName, constructor),
|
|
57
|
+
parameters: constructor.parameters.map((param) => mapParameters(constructor, param)),
|
|
58
|
+
throws: constructor.docComment?.throwsAnnotations.map((thrown) => mapThrows(thrown)),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function mapParameters(documentable: Documentable, param: ParameterMirror) {
|
|
63
|
+
const paramAnnotation = documentable.docComment?.paramAnnotations.find(
|
|
64
|
+
(pa) => pa.paramName.toLowerCase() === param.name.toLowerCase(),
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
...adaptDescribable(paramAnnotation?.bodyLines),
|
|
68
|
+
name: param.name,
|
|
69
|
+
type: linkFromTypeNameGenerator(param.typeReference.rawDeclaration),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function mapThrows(thrown: ThrowsAnnotation) {
|
|
74
|
+
return {
|
|
75
|
+
...adaptDescribable(thrown.bodyLines),
|
|
76
|
+
type: linkFromTypeNameGenerator(thrown.exceptionName),
|
|
77
|
+
};
|
|
78
|
+
}
|