@cparra/apexdocs 2.25.0-alpha.8 → 2.25.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 -0
- package/README.md +12 -73
- package/apexdocs.config.ts +13 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +1 -0
- package/docs/index.html +22 -0
- package/docs/restapi.json +589 -0
- package/docs/types/Classes/nspc.AnotherInterface.md +22 -0
- package/docs/types/Classes/nspc.ChildClass.md +97 -0
- package/docs/types/Main/nspc.GroupedClass.md +10 -0
- package/docs/types/Main/nspc.SampleClass.md +190 -0
- package/docs/types/Misc-Group/nspc.EscapedAnnotations.md +4 -0
- package/docs/types/Misc-Group/nspc.GrandparentClass.md +13 -0
- package/docs/types/Misc-Group/nspc.InterfaceWithInheritance.md +29 -0
- package/docs/types/Misc-Group/nspc.MemberGrouping.md +13 -0
- package/docs/types/Misc-Group/nspc.ParentClass.md +37 -0
- package/docs/types/Misc-Group/nspc.Reference1.md +18 -0
- package/docs/types/Misc-Group/nspc.Reference2.md +12 -0
- package/docs/types/Misc-Group/nspc.Reference3.md +7 -0
- package/docs/types/Misc-Group/nspc.Reference4.md +7 -0
- package/docs/types/Misc-Group/nspc.Reference5.md +7 -0
- package/docs/types/Misc-Group/nspc.Reference6.md +9 -0
- package/docs/types/Misc-Group/nspc.Reference7.md +7 -0
- package/docs/types/Misc-Group/nspc.SampleClassWithoutModifier.md +11 -0
- package/docs/types/Misc-Group/nspc.SampleRestResource.md +211 -0
- package/docs/types/Misc-Group/nspc.SampleRestResourceWithInnerClass.md +34 -0
- package/docs/types/Misc-Group/nspc.SampleRestResourceWithoutApexDocs.md +14 -0
- package/docs/types/README.md +97 -0
- package/docs/types/Sample-Interfaces/nspc.SampleInterface.md +23 -0
- package/examples/includes/header.md +3 -0
- package/jest.config.js +1 -6
- package/lib/application/Apexdocs.d.ts +13 -0
- package/lib/application/Apexdocs.js +77 -0
- package/lib/application/Apexdocs.js.map +1 -0
- package/lib/cli/generate.d.ts +2 -0
- package/lib/cli/generate.js +131 -0
- package/lib/cli/generate.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/model/apex-bundle.d.ts +6 -0
- package/lib/model/apex-bundle.js +11 -0
- package/lib/model/apex-bundle.js.map +1 -0
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.d.ts +7 -0
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.js +14 -0
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.js.map +1 -0
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.d.ts +7 -0
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.js +12 -0
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.js.map +1 -0
- package/lib/model/inheritance.d.ts +8 -0
- package/lib/model/inheritance.js +3 -0
- package/lib/model/inheritance.js.map +1 -0
- package/lib/model/manifest-diff.d.ts +27 -0
- package/lib/model/manifest-diff.js +69 -0
- package/lib/model/manifest-diff.js.map +1 -0
- package/lib/model/manifest.d.ts +22 -0
- package/lib/model/manifest.js +47 -0
- package/lib/model/manifest.js.map +1 -0
- package/lib/model/markdown-file.d.ts +16 -0
- package/lib/model/markdown-file.js +107 -0
- package/lib/model/markdown-file.js.map +1 -0
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.d.ts +8 -0
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +44 -0
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -0
- package/lib/model/markdown-generation-util/field-declaration-util.d.ts +3 -0
- package/lib/model/markdown-generation-util/field-declaration-util.js +55 -0
- package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -0
- package/lib/model/markdown-generation-util/index.d.ts +3 -0
- package/lib/model/markdown-generation-util/index.js +20 -0
- package/lib/model/markdown-generation-util/index.js.map +1 -0
- package/lib/model/markdown-generation-util/method-declaration-util.d.ts +4 -0
- package/lib/model/markdown-generation-util/method-declaration-util.js +115 -0
- package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -0
- package/lib/model/markdown-generation-util/type-declaration-util.d.ts +3 -0
- package/lib/model/markdown-generation-util/type-declaration-util.js +82 -0
- package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -0
- package/lib/model/markdown-home-file.d.ts +11 -0
- package/lib/model/markdown-home-file.js +54 -0
- package/lib/model/markdown-home-file.js.map +1 -0
- package/lib/model/markdown-type-file.d.ts +26 -0
- package/lib/model/markdown-type-file.js +134 -0
- package/lib/model/markdown-type-file.js.map +1 -0
- package/lib/model/openapi/apex-doc-types.d.ts +19 -0
- package/lib/model/openapi/apex-doc-types.js +5 -0
- package/lib/model/openapi/apex-doc-types.js.map +1 -0
- package/lib/model/openapi/open-api-types.d.ts +93 -0
- package/lib/model/openapi/open-api-types.js +3 -0
- package/lib/model/openapi/open-api-types.js.map +1 -0
- package/lib/model/openapi/open-api.d.ts +16 -0
- package/lib/model/openapi/open-api.js +34 -0
- package/lib/model/openapi/open-api.js.map +1 -0
- package/lib/model/openapi/openapi-type-file.d.ts +7 -0
- package/lib/model/openapi/openapi-type-file.js +17 -0
- package/lib/model/openapi/openapi-type-file.js.map +1 -0
- package/lib/model/outputFile.d.ts +10 -0
- package/lib/model/outputFile.js +29 -0
- package/lib/model/outputFile.js.map +1 -0
- package/lib/model/types-repository.d.ts +16 -0
- package/lib/model/types-repository.js +54 -0
- package/lib/model/types-repository.js.map +1 -0
- package/lib/service/apex-file-reader.d.ts +14 -0
- package/lib/service/apex-file-reader.js +46 -0
- package/lib/service/apex-file-reader.js.map +1 -0
- package/lib/service/file-system.d.ts +14 -0
- package/lib/service/file-system.js +25 -0
- package/lib/service/file-system.js.map +1 -0
- package/lib/service/file-writer.d.ts +6 -0
- package/lib/service/file-writer.js +34 -0
- package/lib/service/file-writer.js.map +1 -0
- package/lib/service/manifest-factory.d.ts +10 -0
- package/lib/service/manifest-factory.js +14 -0
- package/lib/service/manifest-factory.js.map +1 -0
- package/lib/service/metadata-processor.d.ts +3 -0
- package/lib/service/metadata-processor.js +17 -0
- package/lib/service/metadata-processor.js.map +1 -0
- package/lib/service/parser.d.ts +21 -0
- package/lib/service/parser.js +135 -0
- package/lib/service/parser.js.map +1 -0
- package/lib/service/state.d.ts +9 -0
- package/lib/service/state.js +20 -0
- package/lib/service/state.js.map +1 -0
- package/lib/service/walkers/class-walker.d.ts +4 -0
- package/lib/service/walkers/class-walker.js +33 -0
- package/lib/service/walkers/class-walker.js.map +1 -0
- package/lib/service/walkers/enum-walker.d.ts +4 -0
- package/lib/service/walkers/enum-walker.js +11 -0
- package/lib/service/walkers/enum-walker.js.map +1 -0
- package/lib/service/walkers/interface-walker.d.ts +4 -0
- package/lib/service/walkers/interface-walker.js +15 -0
- package/lib/service/walkers/interface-walker.js.map +1 -0
- package/lib/service/walkers/walker-factory.d.ts +5 -0
- package/lib/service/walkers/walker-factory.js +21 -0
- package/lib/service/walkers/walker-factory.js.map +1 -0
- package/lib/service/walkers/walker.d.ts +19 -0
- package/lib/service/walkers/walker.js +17 -0
- package/lib/service/walkers/walker.js.map +1 -0
- package/lib/settings.d.ts +64 -0
- package/lib/settings.js +89 -0
- package/lib/settings.js.map +1 -0
- package/lib/test-helpers/AnnotationBuilder.d.ts +12 -0
- package/lib/test-helpers/AnnotationBuilder.js +31 -0
- package/lib/test-helpers/AnnotationBuilder.js.map +1 -0
- package/lib/test-helpers/ClassMirrorBuilder.d.ts +18 -0
- package/lib/test-helpers/ClassMirrorBuilder.js +54 -0
- package/lib/test-helpers/ClassMirrorBuilder.js.map +1 -0
- package/lib/test-helpers/DocCommentAnnotationBuilder.d.ts +8 -0
- package/lib/test-helpers/DocCommentAnnotationBuilder.js +26 -0
- package/lib/test-helpers/DocCommentAnnotationBuilder.js.map +1 -0
- package/lib/test-helpers/DocCommentBuilder.d.ts +12 -0
- package/lib/test-helpers/DocCommentBuilder.js +38 -0
- package/lib/test-helpers/DocCommentBuilder.js.map +1 -0
- package/lib/test-helpers/FieldMirrorBuilder.d.ts +18 -0
- package/lib/test-helpers/FieldMirrorBuilder.js +54 -0
- package/lib/test-helpers/FieldMirrorBuilder.js.map +1 -0
- package/lib/test-helpers/MethodMirrorBuilder.d.ts +10 -0
- package/lib/test-helpers/MethodMirrorBuilder.js +37 -0
- package/lib/test-helpers/MethodMirrorBuilder.js.map +1 -0
- package/lib/test-helpers/SettingsBuilder.d.ts +8 -0
- package/lib/test-helpers/SettingsBuilder.js +27 -0
- package/lib/test-helpers/SettingsBuilder.js.map +1 -0
- package/lib/transpiler/factory.d.ts +6 -0
- package/lib/transpiler/factory.js +32 -0
- package/lib/transpiler/factory.js.map +1 -0
- package/lib/transpiler/file-container.d.ts +6 -0
- package/lib/transpiler/file-container.js +16 -0
- package/lib/transpiler/file-container.js.map +1 -0
- package/lib/transpiler/generator-choices.d.ts +1 -0
- package/lib/transpiler/generator-choices.js +3 -0
- package/lib/transpiler/generator-choices.js.map +1 -0
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +8 -0
- package/lib/transpiler/markdown/class-file-generatorHelper.js +56 -0
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -0
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +6 -0
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js +13 -0
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js.map +1 -0
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +11 -0
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +51 -0
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -0
- package/lib/transpiler/markdown/markdown-transpiler-base.d.ts +11 -0
- package/lib/transpiler/markdown/markdown-transpiler-base.js +24 -0
- package/lib/transpiler/markdown/markdown-transpiler-base.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +6 -0
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +14 -0
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +1 -0
- package/lib/transpiler/openapi/open-api-docs-processor.d.ts +13 -0
- package/lib/transpiler/openapi/open-api-docs-processor.js +75 -0
- package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -0
- package/lib/transpiler/openapi/parsers/Builder.d.ts +16 -0
- package/lib/transpiler/openapi/parsers/Builder.js +30 -0
- package/lib/transpiler/openapi/parsers/Builder.js.map +1 -0
- package/lib/transpiler/openapi/parsers/MethodParser.d.ts +20 -0
- package/lib/transpiler/openapi/parsers/MethodParser.js +167 -0
- package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -0
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.d.ts +7 -0
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.js +11 -0
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.js.map +1 -0
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.d.ts +39 -0
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +226 -0
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -0
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.d.ts +10 -0
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.js +20 -0
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.js.map +1 -0
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.d.ts +7 -0
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js +22 -0
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js.map +1 -0
- package/lib/transpiler/processor-type-transpiler.d.ts +10 -0
- package/lib/transpiler/processor-type-transpiler.js +9 -0
- package/lib/transpiler/processor-type-transpiler.js.map +1 -0
- package/lib/transpiler/transpiler.d.ts +5 -0
- package/lib/transpiler/transpiler.js +27 -0
- package/lib/transpiler/transpiler.js.map +1 -0
- package/lib/util/error-logger.d.ts +8 -0
- package/lib/util/error-logger.js +90 -0
- package/lib/util/error-logger.js.map +1 -0
- package/lib/util/logger.d.ts +21 -0
- package/lib/util/logger.js +58 -0
- package/lib/util/logger.js.map +1 -0
- package/lib/util/string-utils.d.ts +2 -0
- package/lib/util/string-utils.js +15 -0
- package/lib/util/string-utils.js.map +1 -0
- package/package.json +36 -35
- package/src/application/Apexdocs.ts +70 -17
- package/src/cli/generate.ts +131 -10
- package/src/index.ts +1 -35
- package/src/model/__tests__/manifest-diff.spec.ts +147 -0
- package/src/model/apex-bundle.ts +3 -0
- package/src/{core/openapi → model}/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +3 -3
- package/src/model/inheritance.ts +7 -0
- package/src/model/manifest-diff.ts +94 -0
- package/src/model/manifest.ts +74 -0
- package/src/model/markdown-file.ts +121 -0
- package/src/model/markdown-generation-util/doc-comment-annotation-util.ts +50 -0
- package/src/model/markdown-generation-util/field-declaration-util.ts +71 -0
- package/src/model/markdown-generation-util/index.ts +3 -0
- package/src/model/markdown-generation-util/method-declaration-util.ts +166 -0
- package/src/model/markdown-generation-util/type-declaration-util.ts +91 -0
- package/src/model/markdown-home-file.ts +58 -0
- package/src/model/markdown-type-file.ts +165 -0
- package/src/{core → model}/openapi/open-api-types.ts +2 -2
- package/src/model/openapi/openapi-type-file.ts +14 -0
- package/src/model/outputFile.ts +29 -0
- package/src/{core/openapi → model}/types-repository.ts +9 -0
- package/src/service/__tests__/apex-file-reader.spec.ts +92 -0
- package/src/{core/openapi → service}/__tests__/manifest-factory.spec.ts +2 -1
- package/src/service/apex-file-reader.ts +51 -0
- package/src/service/file-writer.ts +34 -0
- package/src/{core/openapi → service}/manifest-factory.ts +3 -3
- package/src/service/metadata-processor.ts +16 -0
- package/src/{core/openapi → service}/parser.ts +9 -9
- package/src/service/state.ts +24 -0
- package/src/service/walkers/class-walker.ts +30 -0
- package/src/service/walkers/enum-walker.ts +7 -0
- package/src/service/walkers/interface-walker.ts +12 -0
- package/src/service/walkers/walker-factory.ts +19 -0
- package/src/service/walkers/walker.ts +42 -0
- package/src/settings.ts +147 -0
- package/src/test-helpers/ClassMirrorBuilder.ts +1 -14
- package/src/test-helpers/FieldMirrorBuilder.ts +1 -1
- package/src/test-helpers/MethodMirrorBuilder.ts +6 -46
- package/src/test-helpers/SettingsBuilder.ts +4 -1
- package/src/transpiler/factory.ts +33 -0
- package/src/transpiler/file-container.ts +13 -0
- package/src/transpiler/generator-choices.ts +1 -0
- package/src/transpiler/markdown/class-file-generatorHelper.ts +58 -0
- package/src/transpiler/markdown/docsify/docsify-docs-processor.ts +12 -0
- package/src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts +50 -0
- package/src/transpiler/markdown/markdown-transpiler-base.ts +28 -0
- package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +12 -0
- package/src/{core → transpiler}/openapi/__tests__/open-api-docs-processor.spec.ts +1 -1
- package/src/{core → transpiler}/openapi/open-api-docs-processor.ts +10 -9
- package/src/{core → transpiler}/openapi/parsers/Builder.ts +3 -3
- package/src/{core → transpiler}/openapi/parsers/MethodParser.ts +6 -6
- package/src/{core → transpiler}/openapi/parsers/ParameterObjectBuilder.ts +2 -2
- package/src/{core → transpiler}/openapi/parsers/ReferenceBuilder.ts +6 -7
- package/src/{core → transpiler}/openapi/parsers/RequestBodyBuilder.ts +2 -2
- package/src/{core → transpiler}/openapi/parsers/ResponsesBuilder.ts +2 -2
- package/src/{core → transpiler}/openapi/parsers/__tests__/MethodParser.spec.ts +1 -1
- package/src/{core → transpiler}/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +2 -2
- package/src/{core → transpiler}/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +2 -2
- package/src/{core → transpiler}/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +2 -2
- package/src/{core → transpiler}/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +1 -1
- package/src/transpiler/processor-type-transpiler.ts +18 -0
- package/src/{core/openapi → transpiler}/transpiler.ts +6 -2
- package/src/util/error-logger.ts +4 -4
- package/src/util/logger.ts +6 -6
- package/src/util/string-utils.ts +4 -0
- package/tsconfig.json +3 -8
- package/.github/workflows/ci.yaml +0 -22
- package/__mocks__/chalk.js +0 -12
- package/__mocks__/log-update.js +0 -6
- package/dist/cli/generate.js +0 -2976
- package/dist/defaults-DUwru49Q.js +0 -12
- package/dist/defaults-SH0Rsi5E.js +0 -11
- package/dist/index.d.ts +0 -62
- package/dist/index.js +0 -36
- package/eslint.config.mjs +0 -10
- package/examples/plain-markdown/.forceignore +0 -12
- package/examples/plain-markdown/config/project-scratch-def.json +0 -5
- package/examples/plain-markdown/docs/Miscellaneous/ns.BaseClass.md +0 -16
- package/examples/plain-markdown/docs/Miscellaneous/ns.MultiInheritanceClass.md +0 -73
- package/examples/plain-markdown/docs/Miscellaneous/ns.ParentInterface.md +0 -15
- package/examples/plain-markdown/docs/Miscellaneous/ns.ReferencedEnum.md +0 -8
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleException.md +0 -25
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleInterface.md +0 -119
- package/examples/plain-markdown/docs/Miscellaneous/ns.Url.md +0 -320
- package/examples/plain-markdown/docs/Sample-Enums/ns.SampleEnum.md +0 -38
- package/examples/plain-markdown/docs/SampleGroup/ns.SampleClass.md +0 -173
- package/examples/plain-markdown/docs/index.md +0 -117
- package/examples/plain-markdown/force-app/classes/BaseClass.cls +0 -3
- package/examples/plain-markdown/force-app/classes/MultiInheritanceClass.cls +0 -1
- package/examples/plain-markdown/force-app/classes/ParentInterface.cls +0 -3
- package/examples/plain-markdown/force-app/classes/ReferencedEnum.cls +0 -3
- package/examples/plain-markdown/force-app/classes/SampleClass.cls +0 -72
- package/examples/plain-markdown/force-app/classes/SampleEnum.cls +0 -30
- package/examples/plain-markdown/force-app/classes/SampleException.cls +0 -17
- package/examples/plain-markdown/force-app/classes/SampleInterface.cls +0 -46
- package/examples/plain-markdown/force-app/classes/Url.cls +0 -194
- package/examples/plain-markdown/package-lock.json +0 -665
- package/examples/plain-markdown/package.json +0 -20
- package/examples/plain-markdown/sfdx-project.json +0 -12
- package/examples/vitepress/.forceignore +0 -12
- package/examples/vitepress/apexdocs.config.ts +0 -108
- package/examples/vitepress/config/project-scratch-def.json +0 -13
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +0 -259
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +0 -40
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +0 -11474
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +0 -9172
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/package.json +0 -3
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +0 -4339
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +0 -567
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +0 -323
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +0 -7
- package/examples/vitepress/docs/.vitepress/config.mts +0 -21
- package/examples/vitepress/docs/.vitepress/sidebar.json +0 -119
- package/examples/vitepress/docs/Miscellaneous/apexdocs.BaseClass.md +0 -20
- package/examples/vitepress/docs/Miscellaneous/apexdocs.MultiInheritanceClass.md +0 -76
- package/examples/vitepress/docs/Miscellaneous/apexdocs.ParentInterface.md +0 -19
- package/examples/vitepress/docs/Miscellaneous/apexdocs.ReferencedEnum.md +0 -15
- package/examples/vitepress/docs/Miscellaneous/apexdocs.SampleException.md +0 -28
- package/examples/vitepress/docs/Miscellaneous/apexdocs.SampleInterface.md +0 -116
- package/examples/vitepress/docs/Miscellaneous/apexdocs.Url.md +0 -317
- package/examples/vitepress/docs/Sample-Enums/apexdocs.SampleEnum.md +0 -40
- package/examples/vitepress/docs/SampleGroup/apexdocs.SampleClass.md +0 -174
- package/examples/vitepress/docs/api-examples.md +0 -49
- package/examples/vitepress/docs/index-frontmatter.md +0 -16
- package/examples/vitepress/docs/index.md +0 -56
- package/examples/vitepress/docs/markdown-examples.md +0 -85
- package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +0 -3
- package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +0 -1
- package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +0 -3
- package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +0 -5
- package/examples/vitepress/force-app/main/default/classes/SampleClass.cls +0 -72
- package/examples/vitepress/force-app/main/default/classes/SampleEnum.cls +0 -30
- package/examples/vitepress/force-app/main/default/classes/SampleException.cls +0 -17
- package/examples/vitepress/force-app/main/default/classes/SampleInterface.cls +0 -46
- package/examples/vitepress/force-app/main/default/classes/Url.cls +0 -198
- package/examples/vitepress/package-lock.json +0 -2574
- package/examples/vitepress/package.json +0 -18
- package/examples/vitepress/sfdx-project.json +0 -12
- package/jest.d.ts +0 -7
- package/src/application/__tests__/apex-file-reader.spec.ts +0 -104
- package/src/application/apex-file-reader.ts +0 -42
- package/src/application/file-writer.ts +0 -25
- package/src/application/generators/markdown.ts +0 -53
- package/src/application/generators/openapi.ts +0 -56
- package/src/cli/args.ts +0 -43
- package/src/cli/commands/markdown.ts +0 -58
- package/src/core/manifest.ts +0 -90
- package/src/core/markdown/__test__/expect-extensions.ts +0 -32
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +0 -733
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +0 -385
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +0 -459
- package/src/core/markdown/__test__/generating-reference-guide.spec.ts +0 -184
- package/src/core/markdown/__test__/inheritance-chain.test.ts +0 -54
- package/src/core/markdown/__test__/test-helpers.ts +0 -22
- package/src/core/markdown/adapters/__tests__/documentables.spec.ts +0 -109
- package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +0 -112
- package/src/core/markdown/adapters/__tests__/references.spec.ts +0 -136
- package/src/core/markdown/adapters/apex-types.ts +0 -237
- package/src/core/markdown/adapters/documentables.ts +0 -116
- package/src/core/markdown/adapters/fields-and-properties.ts +0 -45
- package/src/core/markdown/adapters/inline.ts +0 -143
- package/src/core/markdown/adapters/methods-and-constructors.ts +0 -133
- package/src/core/markdown/adapters/renderable-bundle.ts +0 -144
- package/src/core/markdown/adapters/renderable-to-page-data.ts +0 -92
- package/src/core/markdown/adapters/type-utils.ts +0 -13
- package/src/core/markdown/adapters/types.d.ts +0 -182
- package/src/core/markdown/generate-docs.ts +0 -158
- package/src/core/markdown/reflection/error-handling.ts +0 -37
- package/src/core/markdown/reflection/filter-scope.ts +0 -13
- package/src/core/markdown/reflection/inheritance-chain-expanion.ts +0 -22
- package/src/core/markdown/reflection/inheritance-chain.ts +0 -23
- package/src/core/markdown/reflection/inherited-member-expansion.ts +0 -105
- package/src/core/markdown/reflection/reflect-source.ts +0 -41
- package/src/core/markdown/reflection/sort-members.ts +0 -59
- package/src/core/markdown/templates/class-template.ts +0 -75
- package/src/core/markdown/templates/constructors-partial-template.ts +0 -32
- package/src/core/markdown/templates/documentable-partial-template.ts +0 -26
- package/src/core/markdown/templates/enum-template.ts +0 -12
- package/src/core/markdown/templates/fieldsPartialTemplate.ts +0 -23
- package/src/core/markdown/templates/grouped-members-partial-template.ts +0 -6
- package/src/core/markdown/templates/hookable.ts +0 -7
- package/src/core/markdown/templates/interface-template.ts +0 -16
- package/src/core/markdown/templates/methods-partial-template.ts +0 -43
- package/src/core/markdown/templates/reference-guide.ts +0 -14
- package/src/core/markdown/templates/template.ts +0 -114
- package/src/core/markdown/templates/type-doc-partial.ts +0 -27
- package/src/core/markdown/utils.ts +0 -3
- package/src/core/openapi/file-container.ts +0 -13
- package/src/core/openapi/openapi-type-file.ts +0 -14
- package/src/core/parse-apex-metadata.ts +0 -14
- package/src/core/settings.ts +0 -56
- package/src/core/shared/types.d.ts +0 -92
- package/src/core/shared/utils.ts +0 -5
- package/src/defaults.ts +0 -8
- package/src/test-helpers/InterfaceMirrorBuilder.ts +0 -39
- package/src/util/fp.ts +0 -3
- /package/src/{core/__test__ → model/__tests__}/manifest.spec.ts +0 -0
- /package/src/{core/openapi → model}/apex-type-wrappers/ClassMirrorWrapper.ts +0 -0
- /package/src/{core/openapi → model}/apex-type-wrappers/MethodMirrorWrapper.ts +0 -0
- /package/src/{core → model}/openapi/__tests__/open-api.spec.ts +0 -0
- /package/src/{core → model}/openapi/apex-doc-types.ts +0 -0
- /package/src/{core → model}/openapi/open-api.ts +0 -0
- /package/src/{application → service}/file-system.ts +0 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClassMirror,
|
|
3
|
+
ConstructorMirror,
|
|
4
|
+
EnumMirror,
|
|
5
|
+
InterfaceMirror,
|
|
6
|
+
MethodMirror,
|
|
7
|
+
Type,
|
|
8
|
+
} from '@cparra/apex-reflection';
|
|
9
|
+
import { WalkerFactory } from '../service/walkers/walker-factory';
|
|
10
|
+
import { WalkerListener } from '../service/walkers/walker';
|
|
11
|
+
import { MarkdownFile } from './markdown-file';
|
|
12
|
+
import { declareType, declareMethod, declareField } from './markdown-generation-util';
|
|
13
|
+
import ClassFileGeneratorHelper from '../transpiler/markdown/class-file-generatorHelper';
|
|
14
|
+
import { FieldMirrorWithInheritance, MethodMirrorWithInheritance, PropertyMirrorWithInheritance } from './inheritance';
|
|
15
|
+
import { Settings } from '../settings';
|
|
16
|
+
|
|
17
|
+
interface GroupAware {
|
|
18
|
+
group?: string;
|
|
19
|
+
groupDescription?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface GroupMap {
|
|
23
|
+
[key: string]: GroupAware[];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class MarkdownTypeFile extends MarkdownFile implements WalkerListener {
|
|
27
|
+
constructor(private type: Type, private headingLevel: number = 1, headerContent?: string, private isInner = false) {
|
|
28
|
+
super(
|
|
29
|
+
`${Settings.getInstance().getNamespacePrefix()}${type.name}`,
|
|
30
|
+
ClassFileGeneratorHelper.getSanitizedGroup(type),
|
|
31
|
+
);
|
|
32
|
+
if (headerContent) {
|
|
33
|
+
this.addText(headerContent);
|
|
34
|
+
}
|
|
35
|
+
const walker = WalkerFactory.get(type);
|
|
36
|
+
walker.walk(this);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public onTypeDeclaration(typeMirror: Type): void {
|
|
40
|
+
let fullTypeName;
|
|
41
|
+
if (this.isInner) {
|
|
42
|
+
fullTypeName = typeMirror.name;
|
|
43
|
+
} else {
|
|
44
|
+
// If we are dealing with a class, we want to check if it has a class
|
|
45
|
+
// modifier and add it to the name.
|
|
46
|
+
if (this.isClass(typeMirror) && typeMirror.classModifier) {
|
|
47
|
+
fullTypeName = `${typeMirror.classModifier} ${Settings.getInstance().getNamespacePrefix()}${typeMirror.name}`;
|
|
48
|
+
} else {
|
|
49
|
+
fullTypeName = `${Settings.getInstance().getNamespacePrefix()}${typeMirror.name}`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
this.addTitle(fullTypeName, this.headingLevel);
|
|
53
|
+
declareType(this, typeMirror);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private isClass(typeMirror: Type): typeMirror is ClassMirror {
|
|
57
|
+
return typeMirror.type_name === 'class';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public onConstructorDeclaration(className: string, constructors: ConstructorMirror[]): void {
|
|
61
|
+
this.addTitle('Constructors', this.headingLevel + 1);
|
|
62
|
+
this.declareMethodWithGroupings(constructors, className);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public onFieldsDeclaration(fields: FieldMirrorWithInheritance[]): void {
|
|
66
|
+
this.addTitle('Fields', this.headingLevel + 1);
|
|
67
|
+
this.declareFieldOrProperty(fields);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public onPropertiesDeclaration(properties: PropertyMirrorWithInheritance[]): void {
|
|
71
|
+
this.addTitle('Properties', this.headingLevel + 1);
|
|
72
|
+
this.declareFieldOrProperty(properties);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public onMethodsDeclaration(methods: MethodMirror[]): void {
|
|
76
|
+
this.addTitle('Methods', this.headingLevel + 1);
|
|
77
|
+
this.declareMethodWithGroupings(methods);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public onInnerEnumsDeclaration(enums: EnumMirror[]): void {
|
|
81
|
+
this.addInnerTypes('Enums', enums);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public onInnerClassesDeclaration(classes: ClassMirror[]): void {
|
|
85
|
+
this.addInnerTypes('Classes', classes);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public onInnerInterfacesDeclaration(interfaces: InterfaceMirror[]): void {
|
|
89
|
+
this.addInnerTypes('Interfaces', interfaces, false);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private addInnerTypes(title: string, types: Type[], addSeparator = true) {
|
|
93
|
+
this.addTitle(title, this.headingLevel + 1);
|
|
94
|
+
types.forEach((currentType) => {
|
|
95
|
+
const innerFile = new MarkdownTypeFile(currentType, this.headingLevel + 2, undefined, true);
|
|
96
|
+
this.addText(innerFile._contents);
|
|
97
|
+
});
|
|
98
|
+
if (addSeparator) {
|
|
99
|
+
this.addHorizontalRule();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private hasGroupings(groupAware: GroupAware[]): boolean {
|
|
104
|
+
return !!groupAware.find((current) => !!current.group);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private declareMethodWithGroupings(
|
|
108
|
+
methods: ConstructorMirror[] | MethodMirrorWithInheritance[],
|
|
109
|
+
className = '',
|
|
110
|
+
): void {
|
|
111
|
+
const hasGroupings = this.hasGroupings(methods);
|
|
112
|
+
if (!hasGroupings) {
|
|
113
|
+
declareMethod(this, methods, this.headingLevel, className);
|
|
114
|
+
} else {
|
|
115
|
+
const groupedConstructors = this.group(methods);
|
|
116
|
+
for (const key in groupedConstructors) {
|
|
117
|
+
// For the group description, we can take the first one, since they all have the same description.
|
|
118
|
+
this.startGroup(key, groupedConstructors[key][0].groupDescription);
|
|
119
|
+
const constructorsForGroup = groupedConstructors[key] as (ConstructorMirror | MethodMirrorWithInheritance)[];
|
|
120
|
+
declareMethod(this, constructorsForGroup, this.headingLevel, className);
|
|
121
|
+
this.endGroup();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private declareFieldOrProperty(
|
|
127
|
+
fieldsOrProperties: FieldMirrorWithInheritance[] | PropertyMirrorWithInheritance[],
|
|
128
|
+
): void {
|
|
129
|
+
const hasGroupings = this.hasGroupings(fieldsOrProperties);
|
|
130
|
+
if (!hasGroupings) {
|
|
131
|
+
declareField(this, fieldsOrProperties, this.headingLevel, false);
|
|
132
|
+
} else {
|
|
133
|
+
const groupedFields = this.group(fieldsOrProperties);
|
|
134
|
+
for (const key in groupedFields) {
|
|
135
|
+
// For the group description, we can take the first one, since they all have the same description.
|
|
136
|
+
this.startGroup(key, groupedFields[key][0].groupDescription);
|
|
137
|
+
const fieldsForGroup = groupedFields[key] as (FieldMirrorWithInheritance | PropertyMirrorWithInheritance)[];
|
|
138
|
+
declareField(this, fieldsForGroup, this.headingLevel, true);
|
|
139
|
+
this.endGroup();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private startGroup(groupName: string, groupDescription?: string) {
|
|
145
|
+
this.headingLevel = this.headingLevel + 2;
|
|
146
|
+
this.addTitle(groupName, this.headingLevel);
|
|
147
|
+
if (groupDescription) {
|
|
148
|
+
this.addText(groupDescription);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private endGroup() {
|
|
153
|
+
this.headingLevel = this.headingLevel - 2;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private group(list: GroupAware[]) {
|
|
157
|
+
return list.reduce((groups: GroupMap, item) => {
|
|
158
|
+
const groupName: string = item.group ?? 'Other';
|
|
159
|
+
const group: GroupAware[] = groups[groupName] || [];
|
|
160
|
+
group.push(item);
|
|
161
|
+
groups[groupName] = group;
|
|
162
|
+
return groups;
|
|
163
|
+
}, {});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -56,14 +56,14 @@ export type RequestBodyContent = {
|
|
|
56
56
|
|
|
57
57
|
export type MediaTypeObject = {
|
|
58
58
|
schema?: SchemaObject;
|
|
59
|
-
example?:
|
|
59
|
+
example?: any;
|
|
60
60
|
examples?: { [index: string]: ExampleObject };
|
|
61
61
|
};
|
|
62
62
|
|
|
63
63
|
export type ExampleObject = {
|
|
64
64
|
summary?: string;
|
|
65
65
|
description?: string;
|
|
66
|
-
value?:
|
|
66
|
+
value?: any;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
// Responses
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OutputFile } from '../outputFile';
|
|
2
|
+
import { OpenApi } from './open-api';
|
|
3
|
+
import { Settings } from '../../settings';
|
|
4
|
+
|
|
5
|
+
export class OpenapiTypeFile extends OutputFile {
|
|
6
|
+
constructor(public openApiModel: OpenApi) {
|
|
7
|
+
super(Settings.getInstance().openApiFileName(), '');
|
|
8
|
+
this.addText(JSON.stringify({ ...openApiModel, namespace: undefined }, null, 2));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
fileExtension(): string {
|
|
12
|
+
return '.json';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import xss = require('xss');
|
|
2
|
+
import { Settings } from '../settings';
|
|
3
|
+
|
|
4
|
+
const xssFilter = new xss.FilterXSS({
|
|
5
|
+
whiteList: { br: [], p: [], ul: [], li: [], code: [], pre: [] },
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export abstract class OutputFile {
|
|
9
|
+
_contents = '';
|
|
10
|
+
|
|
11
|
+
constructor(public fileName: string, public dir: string) {}
|
|
12
|
+
|
|
13
|
+
abstract fileExtension(): string;
|
|
14
|
+
|
|
15
|
+
get body() {
|
|
16
|
+
return this._contents;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
addText(text: string, encodeHtml = true) {
|
|
20
|
+
const shouldEncode = encodeHtml && Settings.getInstance().sanitizeHtml;
|
|
21
|
+
const textToAdd = shouldEncode ? xssFilter.process(text) : text;
|
|
22
|
+
this._contents += textToAdd;
|
|
23
|
+
this.addBlankLine();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
addBlankLine() {
|
|
27
|
+
this._contents += '\n';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -4,6 +4,7 @@ export type TypeBundle = { type: Type; isChild: boolean; parentType?: Type };
|
|
|
4
4
|
|
|
5
5
|
export class TypesRepository {
|
|
6
6
|
private static instance: TypesRepository;
|
|
7
|
+
private scopedTypes: Type[] = [];
|
|
7
8
|
private allTypes: Type[] = [];
|
|
8
9
|
|
|
9
10
|
public static getInstance(): TypesRepository {
|
|
@@ -51,4 +52,12 @@ export class TypesRepository {
|
|
|
51
52
|
}
|
|
52
53
|
return { type: foundType, isChild: false };
|
|
53
54
|
}
|
|
55
|
+
|
|
56
|
+
public populateScoped(types: Type[]) {
|
|
57
|
+
this.scopedTypes = types;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public getFromScopedByName(typeName: string): Type | undefined {
|
|
61
|
+
return this.scopedTypes.find((currentType: Type) => currentType.name === typeName);
|
|
62
|
+
}
|
|
54
63
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Settings, SettingsConfig } from '../../settings';
|
|
2
|
+
import { ApexFileReader } from '../apex-file-reader';
|
|
3
|
+
|
|
4
|
+
describe('File Reader', () => {
|
|
5
|
+
beforeEach(() => {
|
|
6
|
+
Settings.build({
|
|
7
|
+
sourceDirectory: '',
|
|
8
|
+
recursive: true,
|
|
9
|
+
scope: [],
|
|
10
|
+
outputDir: '',
|
|
11
|
+
targetGenerator: 'jekyll',
|
|
12
|
+
indexOnly: false,
|
|
13
|
+
defaultGroupName: 'Misc',
|
|
14
|
+
sanitizeHtml: true,
|
|
15
|
+
openApiFileName: 'openapi',
|
|
16
|
+
title: 'Classes',
|
|
17
|
+
includeMetadata: false,
|
|
18
|
+
} as SettingsConfig);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('returns an empty list when there are no files in the directory', () => {
|
|
22
|
+
const result = ApexFileReader.processFiles({
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
24
|
+
isDirectory(_: string): boolean {
|
|
25
|
+
return false;
|
|
26
|
+
},
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
joinPath(_: string): string {
|
|
29
|
+
return '';
|
|
30
|
+
},
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
+
readDirectory(_: string): string[] {
|
|
33
|
+
return [];
|
|
34
|
+
},
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
|
+
readFile(_: string): string {
|
|
37
|
+
return '';
|
|
38
|
+
},
|
|
39
|
+
exists(): boolean {
|
|
40
|
+
return true;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
expect(result.length).toBe(0);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('returns an empty list when there are no Apex files in the directory', () => {
|
|
47
|
+
const result = ApexFileReader.processFiles({
|
|
48
|
+
isDirectory(_: string): boolean {
|
|
49
|
+
return false;
|
|
50
|
+
},
|
|
51
|
+
joinPath(_: string): string {
|
|
52
|
+
return '';
|
|
53
|
+
},
|
|
54
|
+
readDirectory(_: string): string[] {
|
|
55
|
+
return ['SomeFile.md'];
|
|
56
|
+
},
|
|
57
|
+
readFile(_: string): string {
|
|
58
|
+
return '';
|
|
59
|
+
},
|
|
60
|
+
exists(): boolean {
|
|
61
|
+
return true;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
expect(result.length).toBe(0);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('returns the file contents for an Apex file', () => {
|
|
68
|
+
const result = ApexFileReader.processFiles({
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
70
|
+
isDirectory(_: string): boolean {
|
|
71
|
+
return false;
|
|
72
|
+
},
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
|
+
joinPath(_: string): string {
|
|
75
|
+
return '';
|
|
76
|
+
},
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
78
|
+
readDirectory(_: string): string[] {
|
|
79
|
+
return ['SomeApexFile.cls'];
|
|
80
|
+
},
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
82
|
+
readFile(_: string): string {
|
|
83
|
+
return 'public class MyClass{}';
|
|
84
|
+
},
|
|
85
|
+
exists(): boolean {
|
|
86
|
+
return true;
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
expect(result.length).toBe(1);
|
|
90
|
+
expect(result[0].rawTypeContent).toBe('public class MyClass{}');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createManifest } from '../manifest-factory';
|
|
2
2
|
import { Type } from '@cparra/apex-reflection';
|
|
3
3
|
import { TypeParser } from '../parser';
|
|
4
|
+
import ApexBundle from '../../model/apex-bundle';
|
|
4
5
|
|
|
5
6
|
class TestParser implements TypeParser {
|
|
6
7
|
parse(): Type[] {
|
|
@@ -9,7 +10,7 @@ class TestParser implements TypeParser {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
it('creates a manifest from the result of a type parser', () => {
|
|
12
|
-
const manifest = createManifest(new TestParser(), () => {
|
|
13
|
+
const manifest = createManifest(new TestParser(), (bundle: ApexBundle) => {
|
|
13
14
|
return {};
|
|
14
15
|
});
|
|
15
16
|
expect(manifest.types.length).toBe(0);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Settings } from '../settings';
|
|
2
|
+
import { FileSystem } from './file-system';
|
|
3
|
+
import ApexBundle from '../model/apex-bundle';
|
|
4
|
+
|
|
5
|
+
const APEX_FILE_EXTENSION = '.cls';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Reads from .cls files and returns their raw body.
|
|
9
|
+
*/
|
|
10
|
+
export class ApexFileReader {
|
|
11
|
+
/**
|
|
12
|
+
* Reads from .cls files and returns their raw body.
|
|
13
|
+
*/
|
|
14
|
+
static processFiles(fileSystem: FileSystem, rootPath: string = this.sourceDirectory): ApexBundle[] {
|
|
15
|
+
let bundles: ApexBundle[] = [];
|
|
16
|
+
|
|
17
|
+
const directoryContents = fileSystem.readDirectory(rootPath);
|
|
18
|
+
directoryContents.forEach((currentFilePath) => {
|
|
19
|
+
const currentPath = fileSystem.joinPath(rootPath, currentFilePath);
|
|
20
|
+
if (this.readRecursively && fileSystem.isDirectory(currentPath)) {
|
|
21
|
+
bundles = bundles.concat(this.processFiles(fileSystem, currentPath));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!this.isApexFile(currentFilePath)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const rawApexFile = fileSystem.readFile(currentPath);
|
|
29
|
+
const metadataPath = fileSystem.joinPath(rootPath, `${currentFilePath}-meta.xml`);
|
|
30
|
+
let rawMetadataFile = null;
|
|
31
|
+
if (Settings.getInstance().includeMetadata()) {
|
|
32
|
+
rawMetadataFile = fileSystem.exists(metadataPath) ? fileSystem.readFile(metadataPath) : null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
bundles.push(new ApexBundle(currentFilePath, rawApexFile, rawMetadataFile));
|
|
36
|
+
});
|
|
37
|
+
return bundles;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private static isApexFile(currentFile: string): boolean {
|
|
41
|
+
return currentFile.endsWith(APEX_FILE_EXTENSION);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private static get sourceDirectory() {
|
|
45
|
+
return Settings.getInstance().sourceDirectory;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private static get readRecursively() {
|
|
49
|
+
return Settings.getInstance().recursive;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { OutputFile } from '../model/outputFile';
|
|
4
|
+
import { OnBeforeFileWrite, Settings, TargetFile } from '../settings';
|
|
5
|
+
|
|
6
|
+
export class FileWriter {
|
|
7
|
+
static write(files: OutputFile[], onWriteCallback: (file: TargetFile) => void) {
|
|
8
|
+
const onBeforeFileWrite: OnBeforeFileWrite = (file: TargetFile) => Settings.getInstance().onBeforeFileWrite(file);
|
|
9
|
+
files.forEach((file) => {
|
|
10
|
+
const resolvedFile = this.getTargetLocation(file, onBeforeFileWrite);
|
|
11
|
+
const fullDir = path.join(resolvedFile.dir.baseDir, resolvedFile.dir.fileDir);
|
|
12
|
+
if (!fs.existsSync(fullDir)) {
|
|
13
|
+
fs.mkdirSync(fullDir, { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const filePath = path.join(fullDir, `${resolvedFile.name}${resolvedFile.extension}`);
|
|
17
|
+
fs.writeFileSync(filePath, file.body, 'utf8');
|
|
18
|
+
onWriteCallback(resolvedFile);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private static getTargetLocation(file: OutputFile, onBeforeFileWrite: OnBeforeFileWrite): TargetFile {
|
|
23
|
+
const targetFile: TargetFile = {
|
|
24
|
+
name: file.fileName,
|
|
25
|
+
extension: file.fileExtension(),
|
|
26
|
+
dir: {
|
|
27
|
+
baseDir: Settings.getInstance().outputDir,
|
|
28
|
+
fileDir: file.dir,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return onBeforeFileWrite(targetFile);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Manifest from '../manifest';
|
|
1
|
+
import Manifest from '../model/manifest';
|
|
2
2
|
import { TypeParser } from './parser';
|
|
3
3
|
import { ReflectionResult } from '@cparra/apex-reflection';
|
|
4
|
-
import
|
|
4
|
+
import ApexBundle from '../model/apex-bundle';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Builds a new Manifest object, sourcing its types from the received TypeParser.
|
|
@@ -10,7 +10,7 @@ import { SourceFile } from '../shared/types';
|
|
|
10
10
|
*/
|
|
11
11
|
export function createManifest(
|
|
12
12
|
typeParser: TypeParser,
|
|
13
|
-
reflect: (apexBundle:
|
|
13
|
+
reflect: (apexBundle: ApexBundle) => ReflectionResult,
|
|
14
14
|
): Manifest {
|
|
15
15
|
return new Manifest(typeParser.parse(reflect));
|
|
16
16
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { XMLParser } from 'fast-xml-parser';
|
|
2
|
+
|
|
3
|
+
export default class MetadataProcessor {
|
|
4
|
+
public static process(input: string) {
|
|
5
|
+
const map = new Map<string, string>();
|
|
6
|
+
const xml = new XMLParser().parse(input);
|
|
7
|
+
|
|
8
|
+
map.set('apiVersion', xml.ApexClass.apiVersion ?? '');
|
|
9
|
+
|
|
10
|
+
if (xml.ApexClass.status) {
|
|
11
|
+
map.set('status', xml.ApexClass.status);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return map;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { ClassMirror, InterfaceMirror, ReflectionResult, Type } from '@cparra/apex-reflection';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
2
|
+
import ApexBundle from '../model/apex-bundle';
|
|
3
|
+
import MetadataProcessor from './metadata-processor';
|
|
4
|
+
import { Logger } from '../util/logger';
|
|
5
5
|
|
|
6
6
|
export interface TypeParser {
|
|
7
|
-
parse(reflect: (apexBundle:
|
|
7
|
+
parse(reflect: (apexBundle: ApexBundle) => ReflectionResult): Type[];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
type NameAware = { name: string };
|
|
11
11
|
|
|
12
12
|
export class RawBodyParser implements TypeParser {
|
|
13
|
-
constructor(public typeBundles:
|
|
13
|
+
constructor(public typeBundles: ApexBundle[]) {}
|
|
14
14
|
|
|
15
|
-
parse(reflect: (apexBundle:
|
|
15
|
+
parse(reflect: (apexBundle: ApexBundle) => ReflectionResult): Type[] {
|
|
16
16
|
const types = this.typeBundles
|
|
17
17
|
.map((currentBundle) => {
|
|
18
18
|
Logger.log(`Parsing file: ${currentBundle.filePath}`);
|
|
19
19
|
const result = reflect(currentBundle);
|
|
20
|
-
if (!!result.typeMirror && !!currentBundle.
|
|
20
|
+
if (!!result.typeMirror && !!currentBundle.rawMetadataContent) {
|
|
21
21
|
// If successful and there is a metadata file
|
|
22
|
-
const metadataParams =
|
|
22
|
+
const metadataParams = MetadataProcessor.process(currentBundle.rawMetadataContent);
|
|
23
23
|
metadataParams.forEach((value, key) => {
|
|
24
24
|
const declaration = `${key}: ${value}`;
|
|
25
25
|
result.typeMirror?.annotations.push({
|
|
@@ -60,7 +60,7 @@ export class RawBodyParser implements TypeParser {
|
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
//
|
|
63
|
+
// If reaching here then we are dealing with an interface
|
|
64
64
|
let typeAsInterface = currentType as InterfaceMirror;
|
|
65
65
|
if (!typeAsInterface.extended_interfaces.length) {
|
|
66
66
|
typesWithFields.push(currentType);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Type } from '@cparra/apex-reflection';
|
|
2
|
+
|
|
3
|
+
export default class State {
|
|
4
|
+
private static instance: State;
|
|
5
|
+
private typeBeingProcessed?: Type;
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
8
|
+
private constructor() {}
|
|
9
|
+
|
|
10
|
+
public static getInstance(): State {
|
|
11
|
+
if (!State.instance) {
|
|
12
|
+
State.instance = new State();
|
|
13
|
+
}
|
|
14
|
+
return State.instance;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public setTypeBeingProcessed(typeToSet: Type): void {
|
|
18
|
+
this.typeBeingProcessed = typeToSet;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getTypeBeingProcessed(): Type | undefined {
|
|
22
|
+
return this.typeBeingProcessed;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Walker, WalkerListener } from './walker';
|
|
2
|
+
import { ClassMirror } from '@cparra/apex-reflection';
|
|
3
|
+
|
|
4
|
+
export class ClassWalker extends Walker {
|
|
5
|
+
walk(listener: WalkerListener): void {
|
|
6
|
+
listener.onTypeDeclaration(this.type);
|
|
7
|
+
const classMirror = this.type as ClassMirror;
|
|
8
|
+
if (classMirror.constructors.length) {
|
|
9
|
+
listener.onConstructorDeclaration(this.type.name, classMirror.constructors);
|
|
10
|
+
}
|
|
11
|
+
if (classMirror.fields.length) {
|
|
12
|
+
listener.onFieldsDeclaration(this.sortType(classMirror.fields));
|
|
13
|
+
}
|
|
14
|
+
if (classMirror.properties.length) {
|
|
15
|
+
listener.onPropertiesDeclaration(this.sortType(classMirror.properties));
|
|
16
|
+
}
|
|
17
|
+
if (classMirror.methods.length) {
|
|
18
|
+
listener.onMethodsDeclaration(this.sortType(classMirror.methods));
|
|
19
|
+
}
|
|
20
|
+
if (classMirror.enums.length) {
|
|
21
|
+
listener.onInnerEnumsDeclaration(this.sortType(classMirror.enums));
|
|
22
|
+
}
|
|
23
|
+
if (classMirror.classes.length) {
|
|
24
|
+
listener.onInnerClassesDeclaration(this.sortType(classMirror.classes));
|
|
25
|
+
}
|
|
26
|
+
if (classMirror.interfaces.length) {
|
|
27
|
+
listener.onInnerInterfacesDeclaration(this.sortType(classMirror.interfaces));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Walker, WalkerListener } from './walker';
|
|
2
|
+
import { InterfaceMirror } from '@cparra/apex-reflection';
|
|
3
|
+
|
|
4
|
+
export class InterfaceWalker extends Walker {
|
|
5
|
+
walk(listener: WalkerListener): void {
|
|
6
|
+
listener.onTypeDeclaration(this.type);
|
|
7
|
+
const interfaceMirror = this.type as InterfaceMirror;
|
|
8
|
+
if (interfaceMirror.methods.length) {
|
|
9
|
+
listener.onMethodsDeclaration(this.sortType(interfaceMirror.methods));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Type } from '@cparra/apex-reflection';
|
|
2
|
+
import { Walker } from './walker';
|
|
3
|
+
import { ClassWalker } from './class-walker';
|
|
4
|
+
import { EnumWalker } from './enum-walker';
|
|
5
|
+
import { InterfaceWalker } from './interface-walker';
|
|
6
|
+
|
|
7
|
+
export class WalkerFactory {
|
|
8
|
+
static get(type: Type): Walker {
|
|
9
|
+
switch (type.type_name) {
|
|
10
|
+
case 'class':
|
|
11
|
+
return new ClassWalker(type);
|
|
12
|
+
case 'enum':
|
|
13
|
+
return new EnumWalker(type);
|
|
14
|
+
case 'interface':
|
|
15
|
+
return new InterfaceWalker(type);
|
|
16
|
+
}
|
|
17
|
+
throw Error('Walker not found for type.');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ClassMirror,
|
|
3
|
+
ConstructorMirror,
|
|
4
|
+
EnumMirror,
|
|
5
|
+
FieldMirror,
|
|
6
|
+
InterfaceMirror,
|
|
7
|
+
MethodMirror,
|
|
8
|
+
PropertyMirror,
|
|
9
|
+
Type,
|
|
10
|
+
} from '@cparra/apex-reflection';
|
|
11
|
+
import { Settings } from '../../settings';
|
|
12
|
+
|
|
13
|
+
export interface WalkerListener {
|
|
14
|
+
onTypeDeclaration(typeMirror: Type): void;
|
|
15
|
+
|
|
16
|
+
onConstructorDeclaration(className: string, constructors: ConstructorMirror[]): void;
|
|
17
|
+
|
|
18
|
+
onFieldsDeclaration(fields: FieldMirror[]): void;
|
|
19
|
+
|
|
20
|
+
onPropertiesDeclaration(properties: PropertyMirror[]): void;
|
|
21
|
+
|
|
22
|
+
onMethodsDeclaration(methods: MethodMirror[]): void;
|
|
23
|
+
|
|
24
|
+
onInnerEnumsDeclaration(enums: EnumMirror[]): void;
|
|
25
|
+
|
|
26
|
+
onInnerClassesDeclaration(classes: ClassMirror[]): void;
|
|
27
|
+
|
|
28
|
+
onInnerInterfacesDeclaration(interfaces: InterfaceMirror[]): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export abstract class Walker {
|
|
32
|
+
constructor(public type: Type) {}
|
|
33
|
+
|
|
34
|
+
abstract walk(listener: WalkerListener): void;
|
|
35
|
+
|
|
36
|
+
protected sortType<T extends { name: string }>(types: T[]): T[] {
|
|
37
|
+
if (Settings.getInstance().sortMembersAlphabetically()) {
|
|
38
|
+
return types.sort((a, b) => a.name.localeCompare(b.name));
|
|
39
|
+
}
|
|
40
|
+
return types;
|
|
41
|
+
}
|
|
42
|
+
}
|