@cparra/apexdocs 2.25.0 → 3.0.0-alpha.10
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/.github/workflows/ci.yaml +22 -0
- package/README.md +73 -12
- package/__mocks__/chalk.js +12 -0
- package/__mocks__/log-update.js +6 -0
- package/dist/cli/generate.js +3181 -0
- package/dist/defaults-DGKfeZq-.js +13 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.js +36 -0
- package/eslint.config.mjs +10 -0
- package/examples/markdown/.forceignore +12 -0
- package/examples/markdown/config/project-scratch-def.json +5 -0
- package/examples/markdown/docs/index.md +109 -0
- package/examples/markdown/docs/miscellaneous/BaseClass.md +16 -0
- package/examples/markdown/docs/miscellaneous/MultiInheritanceClass.md +72 -0
- package/examples/markdown/docs/miscellaneous/ParentInterface.md +15 -0
- package/examples/markdown/docs/miscellaneous/ReferencedEnum.md +8 -0
- package/examples/markdown/docs/miscellaneous/SampleException.md +24 -0
- package/examples/markdown/docs/miscellaneous/SampleInterface.md +116 -0
- package/examples/markdown/docs/miscellaneous/Url.md +309 -0
- package/examples/markdown/docs/sample-enums/SampleEnum.md +36 -0
- package/examples/markdown/docs/samplegroup/SampleClass.md +170 -0
- package/examples/markdown/force-app/classes/BaseClass.cls +3 -0
- package/examples/markdown/force-app/classes/MultiInheritanceClass.cls +1 -0
- package/examples/markdown/force-app/classes/ParentInterface.cls +3 -0
- package/examples/markdown/force-app/classes/ReferencedEnum.cls +3 -0
- package/examples/markdown/force-app/classes/SampleClass.cls +72 -0
- package/examples/markdown/force-app/classes/SampleEnum.cls +30 -0
- package/examples/markdown/force-app/classes/SampleException.cls +17 -0
- package/examples/markdown/force-app/classes/SampleInterface.cls +50 -0
- package/examples/markdown/force-app/classes/Url.cls +194 -0
- package/examples/markdown/package-lock.json +665 -0
- package/examples/markdown/package.json +20 -0
- package/examples/markdown/sfdx-project.json +12 -0
- package/examples/vitepress/.forceignore +12 -0
- package/examples/vitepress/apexdocs.config.ts +106 -0
- package/examples/vitepress/config/project-scratch-def.json +13 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js +259 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/@theme_index.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/_metadata.json +40 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js +11474 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-574YRH25.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js +9172 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/chunk-E5DZZB2I.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/package.json +3 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4339 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +567 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js +323 -0
- package/examples/vitepress/docs/.vitepress/cache/deps/vue.js.map +7 -0
- package/examples/vitepress/docs/.vitepress/config.mts +21 -0
- package/examples/vitepress/docs/.vitepress/sidebar.json +119 -0
- package/examples/vitepress/docs/api-examples.md +49 -0
- package/examples/vitepress/docs/index-frontmatter.md +16 -0
- package/examples/vitepress/docs/index.md +56 -0
- package/examples/vitepress/docs/markdown-examples.md +85 -0
- package/examples/vitepress/docs/miscellaneous/BaseClass.md +20 -0
- package/examples/vitepress/docs/miscellaneous/MultiInheritanceClass.md +76 -0
- package/examples/vitepress/docs/miscellaneous/ParentInterface.md +19 -0
- package/examples/vitepress/docs/miscellaneous/ReferencedEnum.md +15 -0
- package/examples/vitepress/docs/miscellaneous/SampleException.md +28 -0
- package/examples/vitepress/docs/miscellaneous/SampleInterface.md +116 -0
- package/examples/vitepress/docs/miscellaneous/Url.md +317 -0
- package/examples/vitepress/docs/sample-enums/SampleEnum.md +40 -0
- package/examples/vitepress/docs/samplegroup/SampleClass.md +174 -0
- package/examples/vitepress/force-app/main/default/classes/BaseClass.cls +3 -0
- package/examples/vitepress/force-app/main/default/classes/MultiInheritanceClass.cls +1 -0
- package/examples/vitepress/force-app/main/default/classes/ParentInterface.cls +3 -0
- package/examples/vitepress/force-app/main/default/classes/ReferencedEnum.cls +5 -0
- package/examples/vitepress/force-app/main/default/classes/SampleClass.cls +72 -0
- package/examples/vitepress/force-app/main/default/classes/SampleEnum.cls +30 -0
- package/examples/vitepress/force-app/main/default/classes/SampleException.cls +17 -0
- package/examples/vitepress/force-app/main/default/classes/SampleInterface.cls +46 -0
- package/examples/vitepress/force-app/main/default/classes/Url.cls +198 -0
- package/examples/vitepress/package-lock.json +2574 -0
- package/examples/vitepress/package.json +18 -0
- package/examples/vitepress/sfdx-project.json +12 -0
- package/jest.config.js +6 -1
- package/jest.d.ts +7 -0
- package/package.json +34 -36
- package/src/application/Apexdocs.ts +58 -68
- package/src/application/__tests__/apex-file-reader.spec.ts +104 -0
- package/src/application/apex-file-reader.ts +55 -0
- package/src/application/file-system.ts +69 -0
- package/src/application/file-writer.ts +43 -0
- package/src/application/generators/markdown.ts +45 -0
- package/src/application/generators/openapi.ts +60 -0
- package/src/cli/args.ts +43 -0
- package/src/cli/commands/markdown.ts +53 -0
- package/src/cli/generate.ts +10 -131
- package/src/core/manifest.ts +90 -0
- package/src/core/markdown/__test__/expect-extensions.ts +32 -0
- package/src/core/markdown/__test__/generating-class-docs.spec.ts +733 -0
- package/src/core/markdown/__test__/generating-enum-docs.spec.ts +385 -0
- package/src/core/markdown/__test__/generating-interface-docs.spec.ts +461 -0
- package/src/core/markdown/__test__/generating-reference-guide.spec.ts +180 -0
- package/src/core/markdown/__test__/inheritance-chain.test.ts +54 -0
- package/src/core/markdown/__test__/test-helpers.ts +23 -0
- package/src/core/markdown/adapters/__tests__/documentables.spec.ts +109 -0
- package/src/core/markdown/adapters/__tests__/interface-adapter.spec.ts +148 -0
- package/src/core/markdown/adapters/__tests__/link-generator.spec.ts +130 -0
- package/src/core/markdown/adapters/__tests__/references.spec.ts +136 -0
- package/src/core/markdown/adapters/apex-types.ts +238 -0
- package/src/core/markdown/adapters/documentables.ts +115 -0
- package/src/core/markdown/adapters/fields-and-properties.ts +45 -0
- package/src/core/markdown/adapters/generate-link.ts +82 -0
- package/src/core/markdown/adapters/inline.ts +143 -0
- package/src/core/markdown/adapters/methods-and-constructors.ts +133 -0
- package/src/core/markdown/adapters/reference-guide.ts +37 -0
- package/src/core/markdown/adapters/renderable-bundle.ts +61 -0
- package/src/core/markdown/adapters/renderable-to-page-data.ts +89 -0
- package/src/core/markdown/adapters/type-utils.ts +13 -0
- package/src/core/markdown/adapters/types.d.ts +180 -0
- package/src/core/markdown/generate-docs.ts +212 -0
- package/src/core/markdown/reflection/filter-scope.ts +13 -0
- package/src/core/markdown/reflection/inheritance-chain-expanion.ts +22 -0
- package/src/core/markdown/reflection/inheritance-chain.ts +23 -0
- package/src/core/markdown/reflection/inherited-member-expansion.ts +105 -0
- package/src/core/markdown/reflection/reflect-source.ts +123 -0
- package/src/core/markdown/reflection/sort-members.ts +59 -0
- package/src/core/markdown/templates/class-template.ts +75 -0
- package/src/core/markdown/templates/constructors-partial-template.ts +32 -0
- package/src/core/markdown/templates/documentable-partial-template.ts +26 -0
- package/src/core/markdown/templates/enum-template.ts +12 -0
- package/src/core/markdown/templates/fieldsPartialTemplate.ts +23 -0
- package/src/core/markdown/templates/grouped-members-partial-template.ts +6 -0
- package/src/core/markdown/templates/hookable.ts +7 -0
- package/src/core/markdown/templates/interface-template.ts +16 -0
- package/src/core/markdown/templates/methods-partial-template.ts +43 -0
- package/src/core/markdown/templates/reference-guide.ts +14 -0
- package/src/core/markdown/templates/template.ts +114 -0
- package/src/core/markdown/templates/type-doc-partial.ts +27 -0
- package/src/core/markdown/utils.ts +3 -0
- package/src/{service → core/openapi}/__tests__/manifest-factory.spec.ts +1 -2
- package/src/{transpiler → core}/openapi/__tests__/open-api-docs-processor.spec.ts +1 -1
- package/src/{model → core/openapi}/apex-type-wrappers/__tests__/ClassMirrorWrapper.spec.ts +3 -3
- package/src/core/openapi/file-container.ts +13 -0
- package/src/{service → core/openapi}/manifest-factory.ts +3 -3
- package/src/{transpiler → core}/openapi/open-api-docs-processor.ts +10 -11
- package/src/{model → core}/openapi/open-api-types.ts +2 -2
- package/src/core/openapi/openapi-type-file.ts +12 -0
- package/src/{service → core/openapi}/parser.ts +7 -21
- package/src/{transpiler → core}/openapi/parsers/Builder.ts +3 -3
- package/src/{transpiler → core}/openapi/parsers/MethodParser.ts +6 -6
- package/src/{transpiler → core}/openapi/parsers/ParameterObjectBuilder.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/ReferenceBuilder.ts +7 -6
- package/src/{transpiler → core}/openapi/parsers/RequestBodyBuilder.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/ResponsesBuilder.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/__tests__/MethodParser.spec.ts +1 -1
- package/src/{transpiler → core}/openapi/parsers/__tests__/ParameterObjectBuilder.spec.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/__tests__/ReferenceBuilder.spec.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/__tests__/RequestBodyBuilder.spec.ts +2 -2
- package/src/{transpiler → core}/openapi/parsers/__tests__/ResponsesBuilder.spec.ts +1 -1
- package/src/{transpiler → core/openapi}/transpiler.ts +2 -6
- package/src/{model → core/openapi}/types-repository.ts +0 -9
- package/src/core/parse-apex-metadata.ts +30 -0
- package/src/core/settings.ts +56 -0
- package/src/core/shared/types.d.ts +147 -0
- package/src/core/shared/utils.ts +5 -0
- package/src/defaults.ts +9 -0
- package/src/index.ts +36 -1
- package/src/test-helpers/ClassMirrorBuilder.ts +14 -1
- package/src/test-helpers/FieldMirrorBuilder.ts +1 -1
- package/src/test-helpers/InterfaceMirrorBuilder.ts +39 -0
- package/src/test-helpers/MethodMirrorBuilder.ts +46 -6
- package/src/test-helpers/SettingsBuilder.ts +1 -4
- package/src/util/error-logger.ts +4 -4
- package/src/util/fp.ts +3 -0
- package/src/util/logger.ts +12 -25
- package/src/util/string-utils.ts +0 -4
- package/tsconfig.json +8 -3
- package/.eslintrc.js +0 -12
- package/apexdocs.config.ts +0 -13
- package/docs/.nojekyll +0 -0
- package/docs/README.md +0 -1
- package/docs/index.html +0 -22
- package/docs/restapi.json +0 -589
- package/docs/types/Classes/nspc.AnotherInterface.md +0 -22
- package/docs/types/Classes/nspc.ChildClass.md +0 -97
- package/docs/types/Main/nspc.GroupedClass.md +0 -10
- package/docs/types/Main/nspc.SampleClass.md +0 -190
- package/docs/types/Misc-Group/nspc.EscapedAnnotations.md +0 -4
- package/docs/types/Misc-Group/nspc.GrandparentClass.md +0 -13
- package/docs/types/Misc-Group/nspc.InterfaceWithInheritance.md +0 -29
- package/docs/types/Misc-Group/nspc.MemberGrouping.md +0 -13
- package/docs/types/Misc-Group/nspc.ParentClass.md +0 -37
- package/docs/types/Misc-Group/nspc.Reference1.md +0 -18
- package/docs/types/Misc-Group/nspc.Reference2.md +0 -12
- package/docs/types/Misc-Group/nspc.Reference3.md +0 -7
- package/docs/types/Misc-Group/nspc.Reference4.md +0 -7
- package/docs/types/Misc-Group/nspc.Reference5.md +0 -7
- package/docs/types/Misc-Group/nspc.Reference6.md +0 -9
- package/docs/types/Misc-Group/nspc.Reference7.md +0 -7
- package/docs/types/Misc-Group/nspc.SampleClassWithoutModifier.md +0 -11
- package/docs/types/Misc-Group/nspc.SampleRestResource.md +0 -211
- package/docs/types/Misc-Group/nspc.SampleRestResourceWithInnerClass.md +0 -34
- package/docs/types/Misc-Group/nspc.SampleRestResourceWithoutApexDocs.md +0 -14
- package/docs/types/README.md +0 -97
- package/docs/types/Sample-Interfaces/nspc.SampleInterface.md +0 -23
- package/examples/includes/header.md +0 -3
- package/lib/application/Apexdocs.d.ts +0 -13
- package/lib/application/Apexdocs.js +0 -77
- package/lib/application/Apexdocs.js.map +0 -1
- package/lib/cli/generate.d.ts +0 -2
- package/lib/cli/generate.js +0 -131
- package/lib/cli/generate.js.map +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -18
- package/lib/index.js.map +0 -1
- package/lib/model/apex-bundle.d.ts +0 -6
- package/lib/model/apex-bundle.js +0 -11
- package/lib/model/apex-bundle.js.map +0 -1
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.d.ts +0 -7
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.js +0 -14
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.js.map +0 -1
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.d.ts +0 -7
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.js +0 -12
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.js.map +0 -1
- package/lib/model/inheritance.d.ts +0 -8
- package/lib/model/inheritance.js +0 -3
- package/lib/model/inheritance.js.map +0 -1
- 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/lib/model/manifest.d.ts +0 -22
- package/lib/model/manifest.js +0 -47
- package/lib/model/manifest.js.map +0 -1
- package/lib/model/markdown-file.d.ts +0 -16
- package/lib/model/markdown-file.js +0 -107
- package/lib/model/markdown-file.js.map +0 -1
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.d.ts +0 -8
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +0 -44
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +0 -1
- package/lib/model/markdown-generation-util/field-declaration-util.d.ts +0 -3
- package/lib/model/markdown-generation-util/field-declaration-util.js +0 -55
- package/lib/model/markdown-generation-util/field-declaration-util.js.map +0 -1
- package/lib/model/markdown-generation-util/index.d.ts +0 -3
- package/lib/model/markdown-generation-util/index.js +0 -20
- package/lib/model/markdown-generation-util/index.js.map +0 -1
- package/lib/model/markdown-generation-util/method-declaration-util.d.ts +0 -4
- package/lib/model/markdown-generation-util/method-declaration-util.js +0 -115
- package/lib/model/markdown-generation-util/method-declaration-util.js.map +0 -1
- package/lib/model/markdown-generation-util/type-declaration-util.d.ts +0 -3
- package/lib/model/markdown-generation-util/type-declaration-util.js +0 -82
- package/lib/model/markdown-generation-util/type-declaration-util.js.map +0 -1
- package/lib/model/markdown-home-file.d.ts +0 -11
- package/lib/model/markdown-home-file.js +0 -54
- package/lib/model/markdown-home-file.js.map +0 -1
- package/lib/model/markdown-type-file.d.ts +0 -26
- package/lib/model/markdown-type-file.js +0 -134
- package/lib/model/markdown-type-file.js.map +0 -1
- package/lib/model/openapi/apex-doc-types.d.ts +0 -19
- package/lib/model/openapi/apex-doc-types.js +0 -5
- package/lib/model/openapi/apex-doc-types.js.map +0 -1
- package/lib/model/openapi/open-api-types.d.ts +0 -93
- package/lib/model/openapi/open-api-types.js +0 -3
- package/lib/model/openapi/open-api-types.js.map +0 -1
- package/lib/model/openapi/open-api.d.ts +0 -16
- package/lib/model/openapi/open-api.js +0 -34
- package/lib/model/openapi/open-api.js.map +0 -1
- package/lib/model/openapi/openapi-type-file.d.ts +0 -7
- package/lib/model/openapi/openapi-type-file.js +0 -17
- package/lib/model/openapi/openapi-type-file.js.map +0 -1
- package/lib/model/outputFile.d.ts +0 -10
- package/lib/model/outputFile.js +0 -29
- package/lib/model/outputFile.js.map +0 -1
- package/lib/model/types-repository.d.ts +0 -16
- package/lib/model/types-repository.js +0 -54
- package/lib/model/types-repository.js.map +0 -1
- package/lib/service/apex-file-reader.d.ts +0 -14
- package/lib/service/apex-file-reader.js +0 -46
- package/lib/service/apex-file-reader.js.map +0 -1
- package/lib/service/file-system.d.ts +0 -14
- package/lib/service/file-system.js +0 -25
- package/lib/service/file-system.js.map +0 -1
- package/lib/service/file-writer.d.ts +0 -6
- package/lib/service/file-writer.js +0 -34
- package/lib/service/file-writer.js.map +0 -1
- package/lib/service/manifest-factory.d.ts +0 -10
- package/lib/service/manifest-factory.js +0 -14
- package/lib/service/manifest-factory.js.map +0 -1
- package/lib/service/metadata-processor.d.ts +0 -3
- package/lib/service/metadata-processor.js +0 -17
- package/lib/service/metadata-processor.js.map +0 -1
- package/lib/service/parser.d.ts +0 -21
- package/lib/service/parser.js +0 -135
- package/lib/service/parser.js.map +0 -1
- package/lib/service/state.d.ts +0 -9
- package/lib/service/state.js +0 -20
- package/lib/service/state.js.map +0 -1
- package/lib/service/walkers/class-walker.d.ts +0 -4
- package/lib/service/walkers/class-walker.js +0 -33
- package/lib/service/walkers/class-walker.js.map +0 -1
- package/lib/service/walkers/enum-walker.d.ts +0 -4
- package/lib/service/walkers/enum-walker.js +0 -11
- package/lib/service/walkers/enum-walker.js.map +0 -1
- package/lib/service/walkers/interface-walker.d.ts +0 -4
- package/lib/service/walkers/interface-walker.js +0 -15
- package/lib/service/walkers/interface-walker.js.map +0 -1
- package/lib/service/walkers/walker-factory.d.ts +0 -5
- package/lib/service/walkers/walker-factory.js +0 -21
- package/lib/service/walkers/walker-factory.js.map +0 -1
- package/lib/service/walkers/walker.d.ts +0 -19
- package/lib/service/walkers/walker.js +0 -17
- package/lib/service/walkers/walker.js.map +0 -1
- package/lib/settings.d.ts +0 -64
- package/lib/settings.js +0 -89
- package/lib/settings.js.map +0 -1
- package/lib/test-helpers/AnnotationBuilder.d.ts +0 -12
- package/lib/test-helpers/AnnotationBuilder.js +0 -31
- package/lib/test-helpers/AnnotationBuilder.js.map +0 -1
- package/lib/test-helpers/ClassMirrorBuilder.d.ts +0 -18
- package/lib/test-helpers/ClassMirrorBuilder.js +0 -54
- package/lib/test-helpers/ClassMirrorBuilder.js.map +0 -1
- package/lib/test-helpers/DocCommentAnnotationBuilder.d.ts +0 -8
- package/lib/test-helpers/DocCommentAnnotationBuilder.js +0 -26
- package/lib/test-helpers/DocCommentAnnotationBuilder.js.map +0 -1
- package/lib/test-helpers/DocCommentBuilder.d.ts +0 -12
- package/lib/test-helpers/DocCommentBuilder.js +0 -38
- package/lib/test-helpers/DocCommentBuilder.js.map +0 -1
- package/lib/test-helpers/FieldMirrorBuilder.d.ts +0 -18
- package/lib/test-helpers/FieldMirrorBuilder.js +0 -54
- package/lib/test-helpers/FieldMirrorBuilder.js.map +0 -1
- package/lib/test-helpers/MethodMirrorBuilder.d.ts +0 -10
- package/lib/test-helpers/MethodMirrorBuilder.js +0 -37
- package/lib/test-helpers/MethodMirrorBuilder.js.map +0 -1
- package/lib/test-helpers/SettingsBuilder.d.ts +0 -8
- package/lib/test-helpers/SettingsBuilder.js +0 -27
- package/lib/test-helpers/SettingsBuilder.js.map +0 -1
- package/lib/transpiler/factory.d.ts +0 -6
- package/lib/transpiler/factory.js +0 -32
- package/lib/transpiler/factory.js.map +0 -1
- package/lib/transpiler/file-container.d.ts +0 -6
- package/lib/transpiler/file-container.js +0 -16
- package/lib/transpiler/file-container.js.map +0 -1
- package/lib/transpiler/generator-choices.d.ts +0 -1
- package/lib/transpiler/generator-choices.js +0 -3
- package/lib/transpiler/generator-choices.js.map +0 -1
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +0 -8
- package/lib/transpiler/markdown/class-file-generatorHelper.js +0 -56
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +0 -1
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +0 -6
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js +0 -13
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js.map +0 -1
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +0 -11
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +0 -51
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +0 -1
- package/lib/transpiler/markdown/markdown-transpiler-base.d.ts +0 -11
- package/lib/transpiler/markdown/markdown-transpiler-base.js +0 -24
- package/lib/transpiler/markdown/markdown-transpiler-base.js.map +0 -1
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +0 -6
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +0 -14
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +0 -1
- package/lib/transpiler/openapi/open-api-docs-processor.d.ts +0 -13
- package/lib/transpiler/openapi/open-api-docs-processor.js +0 -75
- package/lib/transpiler/openapi/open-api-docs-processor.js.map +0 -1
- package/lib/transpiler/openapi/parsers/Builder.d.ts +0 -16
- package/lib/transpiler/openapi/parsers/Builder.js +0 -30
- package/lib/transpiler/openapi/parsers/Builder.js.map +0 -1
- package/lib/transpiler/openapi/parsers/MethodParser.d.ts +0 -20
- package/lib/transpiler/openapi/parsers/MethodParser.js +0 -167
- package/lib/transpiler/openapi/parsers/MethodParser.js.map +0 -1
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.d.ts +0 -7
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.js +0 -11
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.js.map +0 -1
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.d.ts +0 -39
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +0 -226
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +0 -1
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.d.ts +0 -10
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.js +0 -20
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.js.map +0 -1
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.d.ts +0 -7
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js +0 -22
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js.map +0 -1
- package/lib/transpiler/processor-type-transpiler.d.ts +0 -10
- package/lib/transpiler/processor-type-transpiler.js +0 -9
- package/lib/transpiler/processor-type-transpiler.js.map +0 -1
- package/lib/transpiler/transpiler.d.ts +0 -5
- package/lib/transpiler/transpiler.js +0 -27
- package/lib/transpiler/transpiler.js.map +0 -1
- package/lib/util/error-logger.d.ts +0 -8
- package/lib/util/error-logger.js +0 -90
- package/lib/util/error-logger.js.map +0 -1
- package/lib/util/logger.d.ts +0 -21
- package/lib/util/logger.js +0 -58
- package/lib/util/logger.js.map +0 -1
- package/lib/util/string-utils.d.ts +0 -2
- package/lib/util/string-utils.js +0 -15
- package/lib/util/string-utils.js.map +0 -1
- package/src/model/__tests__/manifest-diff.spec.ts +0 -147
- package/src/model/apex-bundle.ts +0 -3
- package/src/model/inheritance.ts +0 -7
- package/src/model/manifest-diff.ts +0 -94
- package/src/model/manifest.ts +0 -74
- package/src/model/markdown-file.ts +0 -121
- package/src/model/markdown-generation-util/doc-comment-annotation-util.ts +0 -50
- package/src/model/markdown-generation-util/field-declaration-util.ts +0 -71
- package/src/model/markdown-generation-util/index.ts +0 -3
- package/src/model/markdown-generation-util/method-declaration-util.ts +0 -166
- package/src/model/markdown-generation-util/type-declaration-util.ts +0 -91
- package/src/model/markdown-home-file.ts +0 -58
- package/src/model/markdown-type-file.ts +0 -165
- package/src/model/openapi/openapi-type-file.ts +0 -14
- package/src/model/outputFile.ts +0 -29
- package/src/service/__tests__/apex-file-reader.spec.ts +0 -92
- package/src/service/apex-file-reader.ts +0 -51
- package/src/service/file-system.ts +0 -33
- package/src/service/file-writer.ts +0 -34
- package/src/service/metadata-processor.ts +0 -16
- package/src/service/state.ts +0 -24
- package/src/service/walkers/class-walker.ts +0 -30
- package/src/service/walkers/enum-walker.ts +0 -7
- package/src/service/walkers/interface-walker.ts +0 -12
- package/src/service/walkers/walker-factory.ts +0 -19
- package/src/service/walkers/walker.ts +0 -42
- package/src/settings.ts +0 -147
- package/src/transpiler/factory.ts +0 -33
- package/src/transpiler/file-container.ts +0 -13
- package/src/transpiler/generator-choices.ts +0 -1
- package/src/transpiler/markdown/class-file-generatorHelper.ts +0 -58
- package/src/transpiler/markdown/docsify/docsify-docs-processor.ts +0 -12
- package/src/transpiler/markdown/jekyll/jekyll-docsProcessor.ts +0 -50
- package/src/transpiler/markdown/markdown-transpiler-base.ts +0 -28
- package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +0 -12
- package/src/transpiler/processor-type-transpiler.ts +0 -18
- /package/src/{model/__tests__ → core/__test__}/manifest.spec.ts +0 -0
- /package/src/{model → core}/openapi/__tests__/open-api.spec.ts +0 -0
- /package/src/{model → core}/openapi/apex-doc-types.ts +0 -0
- /package/src/{model → core/openapi}/apex-type-wrappers/ClassMirrorWrapper.ts +0 -0
- /package/src/{model → core/openapi}/apex-type-wrappers/MethodMirrorWrapper.ts +0 -0
- /package/src/{model → core}/openapi/open-api.ts +0 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { pipe } from 'fp-ts/function';
|
|
2
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
3
|
+
import yaml from 'js-yaml';
|
|
4
|
+
|
|
5
|
+
import { apply } from '#utils/fp';
|
|
6
|
+
import {
|
|
7
|
+
DocPageData,
|
|
8
|
+
DocumentationBundle,
|
|
9
|
+
Frontmatter,
|
|
10
|
+
PostHookDocumentationBundle,
|
|
11
|
+
ReferenceGuidePageData,
|
|
12
|
+
UnparsedSourceFile,
|
|
13
|
+
TransformDocPage,
|
|
14
|
+
TransformDocs,
|
|
15
|
+
TransformReferenceGuide,
|
|
16
|
+
UserDefinedMarkdownConfig,
|
|
17
|
+
DocPageReference,
|
|
18
|
+
TransformReference,
|
|
19
|
+
ParsedFile,
|
|
20
|
+
} from '../shared/types';
|
|
21
|
+
import { parsedFilesToRenderableBundle } from './adapters/renderable-bundle';
|
|
22
|
+
import { reflectBundles } from './reflection/reflect-source';
|
|
23
|
+
import { addInheritanceChainToTypes } from './reflection/inheritance-chain-expanion';
|
|
24
|
+
import { addInheritedMembersToTypes } from './reflection/inherited-member-expansion';
|
|
25
|
+
import { convertToDocumentationBundle } from './adapters/renderable-to-page-data';
|
|
26
|
+
import { filterScope } from './reflection/filter-scope';
|
|
27
|
+
import { Template } from './templates/template';
|
|
28
|
+
import { hookableTemplate } from './templates/hookable';
|
|
29
|
+
import { sortMembers } from './reflection/sort-members';
|
|
30
|
+
import { isSkip } from '../shared/utils';
|
|
31
|
+
import { parsedFilesToReferenceGuide } from './adapters/reference-guide';
|
|
32
|
+
|
|
33
|
+
export type MarkdownGeneratorConfig = Pick<
|
|
34
|
+
UserDefinedMarkdownConfig,
|
|
35
|
+
| 'targetDir'
|
|
36
|
+
| 'scope'
|
|
37
|
+
| 'namespace'
|
|
38
|
+
| 'defaultGroupName'
|
|
39
|
+
| 'transformReferenceGuide'
|
|
40
|
+
| 'transformDocs'
|
|
41
|
+
| 'transformDocPage'
|
|
42
|
+
| 'transformReference'
|
|
43
|
+
| 'linkingStrategy'
|
|
44
|
+
> & {
|
|
45
|
+
referenceGuideTemplate: string;
|
|
46
|
+
sortMembersAlphabetically: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export class HookError {
|
|
50
|
+
readonly _tag = 'HookError';
|
|
51
|
+
|
|
52
|
+
constructor(public error: unknown) {}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function generateDocs(apexBundles: UnparsedSourceFile[], config: MarkdownGeneratorConfig) {
|
|
56
|
+
const filterOutOfScope = apply(filterScope, config.scope);
|
|
57
|
+
const convertToReferences = apply(parsedFilesToReferenceGuide, config);
|
|
58
|
+
const convertToRenderableBundle = apply(parsedFilesToRenderableBundle, config);
|
|
59
|
+
const convertToDocumentationBundleForTemplate = apply(convertToDocumentationBundle, config.referenceGuideTemplate);
|
|
60
|
+
const sortTypeMembers = apply(sortMembers, config.sortMembersAlphabetically);
|
|
61
|
+
|
|
62
|
+
return pipe(
|
|
63
|
+
apexBundles,
|
|
64
|
+
reflectBundles,
|
|
65
|
+
TE.map(filterOutOfScope),
|
|
66
|
+
TE.map(addInheritedMembersToTypes),
|
|
67
|
+
TE.map(addInheritanceChainToTypes),
|
|
68
|
+
TE.map(sortTypeMembers),
|
|
69
|
+
TE.bindTo('parsedFiles'),
|
|
70
|
+
TE.bind('references', ({ parsedFiles }) => TE.right(convertToReferences(parsedFiles))),
|
|
71
|
+
TE.flatMap(({ parsedFiles, references }) => transformReferenceHook(config)({ references, parsedFiles })),
|
|
72
|
+
TE.map(({ parsedFiles, references }) => convertToRenderableBundle(parsedFiles, references)),
|
|
73
|
+
TE.map(convertToDocumentationBundleForTemplate),
|
|
74
|
+
TE.flatMap(transformDocumentationBundleHook(config)),
|
|
75
|
+
TE.map(postHookCompile),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function transformReferenceHook(config: MarkdownGeneratorConfig) {
|
|
80
|
+
async function _execute(
|
|
81
|
+
references: Record<string, DocPageReference>,
|
|
82
|
+
parsedFiles: ParsedFile[],
|
|
83
|
+
transformReference?: TransformReference | undefined,
|
|
84
|
+
): Promise<{
|
|
85
|
+
references: Record<string, DocPageReference>;
|
|
86
|
+
parsedFiles: ParsedFile[];
|
|
87
|
+
}> {
|
|
88
|
+
return {
|
|
89
|
+
references: await execTransformReferenceHook(Object.values(references), transformReference),
|
|
90
|
+
parsedFiles,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return ({ references, parsedFiles }: { references: Record<string, DocPageReference>; parsedFiles: ParsedFile[] }) =>
|
|
95
|
+
TE.tryCatch(
|
|
96
|
+
() => _execute(references, parsedFiles, config.transformReference),
|
|
97
|
+
(error) => new HookError(error),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function transformDocumentationBundleHook(config: MarkdownGeneratorConfig) {
|
|
102
|
+
return (bundle: DocumentationBundle) =>
|
|
103
|
+
TE.tryCatch(
|
|
104
|
+
() => documentationBundleHook(bundle, config),
|
|
105
|
+
(error) => new HookError(error),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Configurable hooks
|
|
110
|
+
function passThroughHook<T>(value: T): T {
|
|
111
|
+
return value;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const execTransformReferenceHook = async (
|
|
115
|
+
references: DocPageReference[],
|
|
116
|
+
hook: TransformReference = passThroughHook,
|
|
117
|
+
): Promise<Record<string, DocPageReference>> => {
|
|
118
|
+
const hooked = references.map<Promise<DocPageReference>>(async (reference) => {
|
|
119
|
+
const hookedResult = await hook(reference);
|
|
120
|
+
return {
|
|
121
|
+
...reference,
|
|
122
|
+
...hookedResult,
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
const awaited = await Promise.all(hooked);
|
|
126
|
+
|
|
127
|
+
return awaited.reduce<Record<string, DocPageReference>>((acc, reference) => {
|
|
128
|
+
acc[reference.source.name] = reference;
|
|
129
|
+
return acc;
|
|
130
|
+
}, {});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const documentationBundleHook = async (
|
|
134
|
+
bundle: DocumentationBundle,
|
|
135
|
+
config: MarkdownGeneratorConfig,
|
|
136
|
+
): Promise<PostHookDocumentationBundle> => {
|
|
137
|
+
return {
|
|
138
|
+
referenceGuide: await transformReferenceGuide(bundle.referenceGuide, config.transformReferenceGuide),
|
|
139
|
+
docs: await transformDocs(bundle.docs, config.transformDocs, config.transformDocPage),
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const transformReferenceGuide = async (
|
|
144
|
+
referenceGuide: ReferenceGuidePageData,
|
|
145
|
+
hook: TransformReferenceGuide = passThroughHook,
|
|
146
|
+
) => {
|
|
147
|
+
const result = await hook(referenceGuide);
|
|
148
|
+
if (isSkip(result)) {
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
...referenceGuide,
|
|
154
|
+
...(await hook(referenceGuide)),
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const transformDocs = async (
|
|
159
|
+
docs: DocPageData[],
|
|
160
|
+
transformDocsHook: TransformDocs = passThroughHook,
|
|
161
|
+
transformDocPageHook: TransformDocPage = passThroughHook,
|
|
162
|
+
): Promise<Awaited<DocPageData[]>> => {
|
|
163
|
+
const transformed = await transformDocsHook(docs);
|
|
164
|
+
return Promise.all(transformed.map((doc) => transformDocPage(doc, transformDocPageHook)));
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const transformDocPage = async (doc: DocPageData, hook: TransformDocPage = passThroughHook) => {
|
|
168
|
+
return {
|
|
169
|
+
...doc,
|
|
170
|
+
...(await hook(doc)),
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
function postHookCompile(bundle: PostHookDocumentationBundle) {
|
|
175
|
+
return {
|
|
176
|
+
referenceGuide: isSkip(bundle.referenceGuide)
|
|
177
|
+
? bundle.referenceGuide
|
|
178
|
+
: {
|
|
179
|
+
...bundle.referenceGuide,
|
|
180
|
+
content: Template.getInstance().compile({
|
|
181
|
+
source: {
|
|
182
|
+
frontmatter: toFrontmatterString(bundle.referenceGuide.frontmatter),
|
|
183
|
+
content: bundle.referenceGuide.content,
|
|
184
|
+
},
|
|
185
|
+
template: hookableTemplate,
|
|
186
|
+
}),
|
|
187
|
+
},
|
|
188
|
+
docs: bundle.docs.map((doc) => ({
|
|
189
|
+
...doc,
|
|
190
|
+
content: Template.getInstance().compile({
|
|
191
|
+
source: {
|
|
192
|
+
frontmatter: toFrontmatterString(doc.frontmatter),
|
|
193
|
+
content: doc.content,
|
|
194
|
+
},
|
|
195
|
+
template: hookableTemplate,
|
|
196
|
+
}),
|
|
197
|
+
})),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function toFrontmatterString(frontmatter: Frontmatter): string {
|
|
202
|
+
if (typeof frontmatter === 'string') {
|
|
203
|
+
return frontmatter;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
if (!frontmatter) {
|
|
207
|
+
return '';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
const yamlString = yaml.dump(frontmatter);
|
|
211
|
+
return `---\n${yamlString}---\n`;
|
|
212
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ParsedFile } from '../../shared/types';
|
|
2
|
+
import Manifest from '../../manifest';
|
|
3
|
+
|
|
4
|
+
export function filterScope(scopes: string[], parsedFiles: ParsedFile[]): ParsedFile[] {
|
|
5
|
+
return parsedFiles
|
|
6
|
+
.filter(({ type }) => Manifest.shouldFilterType(type, scopes))
|
|
7
|
+
.map((parsedFile) => {
|
|
8
|
+
return {
|
|
9
|
+
...parsedFile,
|
|
10
|
+
type: Manifest.filterSingleType(parsedFile.type, scopes, false),
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ClassMirror, Type } from '@cparra/apex-reflection';
|
|
2
|
+
import { createInheritanceChain } from './inheritance-chain';
|
|
3
|
+
import { ParsedFile } from '../../shared/types';
|
|
4
|
+
import { parsedFilesToTypes } from '../utils';
|
|
5
|
+
|
|
6
|
+
export const addInheritanceChainToTypes = (parsedFiles: ParsedFile[]): ParsedFile[] =>
|
|
7
|
+
parsedFiles.map((parsedFile) => ({
|
|
8
|
+
...parsedFile,
|
|
9
|
+
type: addInheritanceChain(parsedFile.type, parsedFilesToTypes(parsedFiles)),
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
function addInheritanceChain<T extends Type>(current: T, repository: Type[]): T {
|
|
13
|
+
if (current.type_name === 'enum' || current.type_name === 'interface') {
|
|
14
|
+
return current;
|
|
15
|
+
} else {
|
|
16
|
+
const inheritanceChain = createInheritanceChain(repository, current as ClassMirror);
|
|
17
|
+
return {
|
|
18
|
+
...current,
|
|
19
|
+
inheritanceChain,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ClassMirror, Type } from '@cparra/apex-reflection';
|
|
2
|
+
import { pipe } from 'fp-ts/function';
|
|
3
|
+
import * as O from 'fp-ts/Option';
|
|
4
|
+
|
|
5
|
+
export function createInheritanceChain(repository: Type[], classMirror: ClassMirror): string[] {
|
|
6
|
+
return pipe(
|
|
7
|
+
O.fromNullable(classMirror.extended_class),
|
|
8
|
+
O.match(
|
|
9
|
+
() => [],
|
|
10
|
+
(extendedClassName) => inheritanceChainFromParentClassName(repository, extendedClassName),
|
|
11
|
+
),
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function inheritanceChainFromParentClassName(repository: Type[], className: string): string[] {
|
|
16
|
+
return pipe(
|
|
17
|
+
O.fromNullable(repository.find((type) => type.name.toLowerCase() === className.toLowerCase())),
|
|
18
|
+
O.match(
|
|
19
|
+
() => [className],
|
|
20
|
+
(extendedClass: Type) => [className, ...createInheritanceChain(repository, extendedClass as ClassMirror)],
|
|
21
|
+
),
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ClassMirror, InterfaceMirror, Type } from '@cparra/apex-reflection';
|
|
2
|
+
import { ParsedFile } from '../../shared/types';
|
|
3
|
+
import { pipe } from 'fp-ts/function';
|
|
4
|
+
import { parsedFilesToTypes } from '../utils';
|
|
5
|
+
|
|
6
|
+
export const addInheritedMembersToTypes = (parsedFiles: ParsedFile[]) =>
|
|
7
|
+
parsedFiles.map((parsedFile) => addInheritedMembers(parsedFilesToTypes(parsedFiles), parsedFile));
|
|
8
|
+
|
|
9
|
+
export function addInheritedMembers(repository: Type[], parsedFile: ParsedFile): ParsedFile {
|
|
10
|
+
function addInheritedMembersToType<T extends Type>(repository: Type[], current: T): T {
|
|
11
|
+
if (current.type_name === 'enum') {
|
|
12
|
+
return current;
|
|
13
|
+
} else if (current.type_name === 'interface') {
|
|
14
|
+
return addInheritedInterfaceMethods(current as InterfaceMirror, repository) as T;
|
|
15
|
+
} else {
|
|
16
|
+
return addInheritedClassMembers(current as ClassMirror, repository) as T;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
...parsedFile,
|
|
22
|
+
type: addInheritedMembersToType(repository, parsedFile.type),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function addInheritedInterfaceMethods(interfaceMirror: InterfaceMirror, repository: Type[]): InterfaceMirror {
|
|
27
|
+
function methodAlreadyExists(memberName: string, members: { name: string }[]) {
|
|
28
|
+
return members.some((member) => member.name.toLowerCase() === memberName.toLowerCase());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function parentExtractor(interfaceMirror: InterfaceMirror): string[] {
|
|
32
|
+
return interfaceMirror.extended_interfaces;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const parents = getParents(parentExtractor, interfaceMirror, repository);
|
|
36
|
+
return {
|
|
37
|
+
...interfaceMirror,
|
|
38
|
+
methods: parents.reduce(
|
|
39
|
+
(acc, currentValue) => [
|
|
40
|
+
...acc,
|
|
41
|
+
...currentValue.methods
|
|
42
|
+
.filter((method) => !methodAlreadyExists(method.name, acc))
|
|
43
|
+
.map((method) => ({
|
|
44
|
+
...method,
|
|
45
|
+
inherited: true,
|
|
46
|
+
})),
|
|
47
|
+
],
|
|
48
|
+
interfaceMirror.methods,
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function addInheritedClassMembers(classMirror: ClassMirror, repository: Type[]): ClassMirror {
|
|
54
|
+
function memberAlreadyExists(memberName: string, members: { name: string }[]) {
|
|
55
|
+
return members.some((member) => member.name.toLowerCase() === memberName.toLowerCase());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function parentExtractor(classMirror: ClassMirror): string[] {
|
|
59
|
+
return classMirror.extended_class ? [classMirror.extended_class] : [];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function filterMember<T extends { name: string; access_modifier: string }>(members: T[], existing: T[]): T[] {
|
|
63
|
+
return members
|
|
64
|
+
.filter((member) => member.access_modifier.toLowerCase() !== 'private')
|
|
65
|
+
.filter((member) => !memberAlreadyExists(member.name, existing))
|
|
66
|
+
.map((member) => ({
|
|
67
|
+
...member,
|
|
68
|
+
inherited: true,
|
|
69
|
+
}));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const parents = getParents(parentExtractor, classMirror, repository);
|
|
73
|
+
return {
|
|
74
|
+
...classMirror,
|
|
75
|
+
fields: parents.reduce(
|
|
76
|
+
(acc, currentValue) => [...acc, ...filterMember(currentValue.fields, acc)],
|
|
77
|
+
classMirror.fields,
|
|
78
|
+
),
|
|
79
|
+
properties: parents.reduce(
|
|
80
|
+
(acc, currentValue) => [...acc, ...filterMember(currentValue.properties, acc)],
|
|
81
|
+
classMirror.properties,
|
|
82
|
+
),
|
|
83
|
+
methods: parents.reduce(
|
|
84
|
+
(acc, currentValue) => [...acc, ...filterMember(currentValue.methods, acc)],
|
|
85
|
+
classMirror.methods,
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function getParents<T extends Type>(
|
|
91
|
+
extendedNamesExtractor: (current: T) => string[],
|
|
92
|
+
current: T,
|
|
93
|
+
repository: Type[],
|
|
94
|
+
): T[] {
|
|
95
|
+
return pipe(
|
|
96
|
+
extendedNamesExtractor(current),
|
|
97
|
+
(interfaces: string[]) => interfaces.map((interfaceName) => repository.find((type) => type.name === interfaceName)),
|
|
98
|
+
(interfaces = []) => interfaces.filter((type) => type !== undefined) as T[],
|
|
99
|
+
(interfaces) =>
|
|
100
|
+
interfaces.reduce<T[]>(
|
|
101
|
+
(acc, current) => [...acc, ...getParents(extendedNamesExtractor, current, repository)],
|
|
102
|
+
interfaces,
|
|
103
|
+
),
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ParsedFile, UnparsedSourceFile } from '../../shared/types';
|
|
2
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
3
|
+
import * as E from 'fp-ts/Either';
|
|
4
|
+
import * as T from 'fp-ts/Task';
|
|
5
|
+
import * as A from 'fp-ts/lib/Array';
|
|
6
|
+
import { Annotation, reflect as mirrorReflection, Type } from '@cparra/apex-reflection';
|
|
7
|
+
import { pipe } from 'fp-ts/function';
|
|
8
|
+
import * as O from 'fp-ts/Option';
|
|
9
|
+
import { parseApexMetadata } from '../../parse-apex-metadata';
|
|
10
|
+
import { ParsingError } from '@cparra/apex-reflection';
|
|
11
|
+
import { apply } from '#utils/fp';
|
|
12
|
+
import { Semigroup } from 'fp-ts/Semigroup';
|
|
13
|
+
|
|
14
|
+
export class ReflectionErrors {
|
|
15
|
+
readonly _tag = 'ReflectionErrors';
|
|
16
|
+
|
|
17
|
+
constructor(public errors: ReflectionError[]) {}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class ReflectionError {
|
|
21
|
+
constructor(
|
|
22
|
+
public file: string,
|
|
23
|
+
public message: string,
|
|
24
|
+
) {}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function reflectAsync(rawSource: string): Promise<Type> {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
const result = mirrorReflection(rawSource);
|
|
30
|
+
if (result.typeMirror) {
|
|
31
|
+
return resolve(result.typeMirror);
|
|
32
|
+
} else if (result.error) {
|
|
33
|
+
return reject(result.error);
|
|
34
|
+
} else {
|
|
35
|
+
return reject(new Error('Unknown error'));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function reflectBundles(apexBundles: UnparsedSourceFile[]) {
|
|
41
|
+
const semiGroupReflectionError: Semigroup<ReflectionErrors> = {
|
|
42
|
+
concat: (x, y) => new ReflectionErrors([...x.errors, ...y.errors]),
|
|
43
|
+
};
|
|
44
|
+
const Ap = TE.getApplicativeTaskValidation(T.ApplyPar, semiGroupReflectionError);
|
|
45
|
+
|
|
46
|
+
return pipe(apexBundles, A.traverse(Ap)(reflectBundle));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function reflectBundle(apexBundle: UnparsedSourceFile): TE.TaskEither<ReflectionErrors, ParsedFile> {
|
|
50
|
+
const convertToParsedFile: (typeMirror: Type) => ParsedFile = apply(toParsedFile, apexBundle.filePath);
|
|
51
|
+
const withMetadata = apply(addMetadata, apexBundle.metadataContent);
|
|
52
|
+
|
|
53
|
+
return pipe(apexBundle, reflectAsTask, TE.map(convertToParsedFile), TE.flatMap(withMetadata));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function reflectAsTask(apexBundle: UnparsedSourceFile): TE.TaskEither<ReflectionErrors, Type> {
|
|
57
|
+
return TE.tryCatch(
|
|
58
|
+
() => reflectAsync(apexBundle.content),
|
|
59
|
+
(error) =>
|
|
60
|
+
new ReflectionErrors([new ReflectionError(apexBundle.filePath, (error as ParsingError | Error).message)]),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function toParsedFile(filePath: string, typeMirror: Type): ParsedFile {
|
|
65
|
+
return {
|
|
66
|
+
source: {
|
|
67
|
+
filePath: filePath,
|
|
68
|
+
name: typeMirror.name,
|
|
69
|
+
type: typeMirror.type_name,
|
|
70
|
+
},
|
|
71
|
+
type: typeMirror,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function addMetadata(
|
|
76
|
+
rawMetadataContent: string | null,
|
|
77
|
+
parsedFile: ParsedFile,
|
|
78
|
+
): TE.TaskEither<ReflectionErrors, ParsedFile> {
|
|
79
|
+
return TE.fromEither(
|
|
80
|
+
pipe(
|
|
81
|
+
parsedFile.type,
|
|
82
|
+
(type) => addFileMetadataToTypeAnnotation(type, rawMetadataContent),
|
|
83
|
+
E.map((type) => ({ ...parsedFile, type })),
|
|
84
|
+
E.mapLeft((error) => errorToReflectionErrors(error, parsedFile.source.filePath)),
|
|
85
|
+
),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function errorToReflectionErrors(error: Error, filePath: string): ReflectionErrors {
|
|
90
|
+
return new ReflectionErrors([new ReflectionError(filePath, error.message)]);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function addFileMetadataToTypeAnnotation(type: Type, metadata: string | null): E.Either<Error, Type> {
|
|
94
|
+
const concatAnnotationToType = apply(concatAnnotations, type);
|
|
95
|
+
|
|
96
|
+
return pipe(
|
|
97
|
+
O.fromNullable(metadata),
|
|
98
|
+
O.map(concatAnnotationToType),
|
|
99
|
+
O.getOrElse(() => E.right(type)),
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function concatAnnotations(type: Type, metadataInput: string): E.Either<Error, Type> {
|
|
104
|
+
return pipe(
|
|
105
|
+
metadataInput,
|
|
106
|
+
parseApexMetadata,
|
|
107
|
+
E.map((metadataMap) => ({
|
|
108
|
+
...type,
|
|
109
|
+
annotations: [...type.annotations, ...mapToAnnotations(metadataMap)],
|
|
110
|
+
})),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function mapToAnnotations(metadata: Map<string, string>): Annotation[] {
|
|
115
|
+
return Array.from(metadata.entries()).map(([key, value]) => {
|
|
116
|
+
const declaration = `${key}: ${value}`;
|
|
117
|
+
return {
|
|
118
|
+
name: declaration,
|
|
119
|
+
type: declaration,
|
|
120
|
+
rawDeclaration: declaration,
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ClassMirror, EnumMirror, InterfaceMirror, Type } from '@cparra/apex-reflection';
|
|
2
|
+
import { ParsedFile } from '../../shared/types';
|
|
3
|
+
|
|
4
|
+
type Named = { name: string };
|
|
5
|
+
|
|
6
|
+
export function sortMembers(shouldSortMembers: boolean, parsedFiles: ParsedFile[]): ParsedFile[] {
|
|
7
|
+
return parsedFiles.map((parsedFile) => ({
|
|
8
|
+
...parsedFile,
|
|
9
|
+
type: sortTypeMember(parsedFile.type, shouldSortMembers),
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function sortByNames<T extends Named>(shouldSort: boolean, a: T, b: T): number {
|
|
14
|
+
if (shouldSort) {
|
|
15
|
+
return a.name.localeCompare(b.name);
|
|
16
|
+
}
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function sortNamed<T extends Named>(shouldSort: boolean, items: T[]): T[] {
|
|
21
|
+
return items.sort((a, b) => sortByNames(shouldSort, a, b));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function sortTypeMember(type: Type, shouldSort: boolean): Type {
|
|
25
|
+
switch (type.type_name) {
|
|
26
|
+
case 'enum':
|
|
27
|
+
return sortEnumValues(shouldSort, type as EnumMirror);
|
|
28
|
+
case 'interface':
|
|
29
|
+
return sortInterfaceMethods(shouldSort, type as InterfaceMirror);
|
|
30
|
+
case 'class':
|
|
31
|
+
return sortClassMembers(shouldSort, type as ClassMirror);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function sortEnumValues(shouldSort: boolean, enumType: EnumMirror): EnumMirror {
|
|
36
|
+
return {
|
|
37
|
+
...enumType,
|
|
38
|
+
values: sortNamed(shouldSort, enumType.values),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function sortInterfaceMethods(shouldSort: boolean, interfaceType: InterfaceMirror): InterfaceMirror {
|
|
43
|
+
return {
|
|
44
|
+
...interfaceType,
|
|
45
|
+
methods: sortNamed(shouldSort, interfaceType.methods),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function sortClassMembers(shouldSort: boolean, classType: ClassMirror): ClassMirror {
|
|
50
|
+
return {
|
|
51
|
+
...classType,
|
|
52
|
+
fields: sortNamed(shouldSort, classType.fields),
|
|
53
|
+
classes: sortNamed(shouldSort, classType.classes),
|
|
54
|
+
enums: sortNamed(shouldSort, classType.enums),
|
|
55
|
+
interfaces: sortNamed(shouldSort, classType.interfaces),
|
|
56
|
+
methods: sortNamed(shouldSort, classType.methods),
|
|
57
|
+
properties: sortNamed(shouldSort, classType.properties),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export const classMarkdownTemplate = `
|
|
2
|
+
{{ heading headingLevel heading }}
|
|
3
|
+
{{#if classModifier}}
|
|
4
|
+
\`{{classModifier}}\`
|
|
5
|
+
{{/if}}
|
|
6
|
+
|
|
7
|
+
{{> typeDocumentation}}
|
|
8
|
+
|
|
9
|
+
{{#if extends.length}}
|
|
10
|
+
**Inheritance**
|
|
11
|
+
|
|
12
|
+
{{#each extends}}{{link this}}{{#unless @last}} < {{/unless}}{{/each}}
|
|
13
|
+
{{/if}}
|
|
14
|
+
|
|
15
|
+
{{#if implements}}
|
|
16
|
+
**Implements**
|
|
17
|
+
|
|
18
|
+
{{#each implements}}
|
|
19
|
+
{{link this}}{{#unless @last}}, {{/unless}}
|
|
20
|
+
{{/each}}
|
|
21
|
+
{{/if}}
|
|
22
|
+
|
|
23
|
+
{{#if fields.value}}
|
|
24
|
+
{{#if fields.isGrouped}}
|
|
25
|
+
{{> groupedMembersPartialTemplate fields subTemplate="fieldsPartialTemplate"}}
|
|
26
|
+
{{else}}
|
|
27
|
+
{{> fieldsPartialTemplate fields}}
|
|
28
|
+
{{/if}}
|
|
29
|
+
{{/if}}
|
|
30
|
+
|
|
31
|
+
{{#if properties.value}}
|
|
32
|
+
{{#if properties.isGrouped}}
|
|
33
|
+
{{> groupedMembersPartialTemplate properties subTemplate="fieldsPartialTemplate"}}
|
|
34
|
+
{{else}}
|
|
35
|
+
{{> fieldsPartialTemplate properties}}
|
|
36
|
+
{{/if}}
|
|
37
|
+
{{/if}}
|
|
38
|
+
|
|
39
|
+
{{#if constructors.value}}
|
|
40
|
+
{{#if constructors.isGrouped}}
|
|
41
|
+
{{> groupedMembersPartialTemplate constructors subTemplate="constructorsPartialTemplate"}}
|
|
42
|
+
{{else}}
|
|
43
|
+
{{> constructorsPartialTemplate constructors}}
|
|
44
|
+
{{/if}}
|
|
45
|
+
{{/if}}
|
|
46
|
+
|
|
47
|
+
{{#if methods.value}}
|
|
48
|
+
{{#if methods.isGrouped}}
|
|
49
|
+
{{> groupedMembersPartialTemplate methods subTemplate="methodsPartialTemplate"}}
|
|
50
|
+
{{else}}
|
|
51
|
+
{{> methodsPartialTemplate methods}}
|
|
52
|
+
{{/if}}
|
|
53
|
+
{{/if}}
|
|
54
|
+
|
|
55
|
+
{{#if innerClasses.value}}
|
|
56
|
+
{{ heading innerClasses.headingLevel innerClasses.heading }}
|
|
57
|
+
{{#each innerClasses.value}}
|
|
58
|
+
{{> classTemplate this}}
|
|
59
|
+
{{/each}}
|
|
60
|
+
{{/if}}
|
|
61
|
+
|
|
62
|
+
{{#if innerEnums.value}}
|
|
63
|
+
{{ heading innerEnums.headingLevel innerEnums.heading }}
|
|
64
|
+
{{#each innerEnums.value}}
|
|
65
|
+
{{> enumTemplate this}}
|
|
66
|
+
{{/each}}
|
|
67
|
+
{{/if}}
|
|
68
|
+
|
|
69
|
+
{{#if innerInterfaces.value}}
|
|
70
|
+
{{ heading innerInterfaces.headingLevel innerInterfaces.heading }}
|
|
71
|
+
{{#each innerInterfaces.value}}
|
|
72
|
+
{{> interfaceTemplate this}}
|
|
73
|
+
{{/each}}
|
|
74
|
+
{{/if}}
|
|
75
|
+
`.trim();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export const constructorsPartialTemplate = `
|
|
2
|
+
{{ heading headingLevel heading }}
|
|
3
|
+
{{#each value}}
|
|
4
|
+
{{{ heading headingLevel (inlineCode heading) }}}
|
|
5
|
+
|
|
6
|
+
{{#> documentablePartialTemplate}}
|
|
7
|
+
|
|
8
|
+
{{ heading signature.headingLevel signature.heading }}
|
|
9
|
+
{{ code signature.value }}
|
|
10
|
+
|
|
11
|
+
{{#if parameters.value}}
|
|
12
|
+
{{ heading parameters.headingLevel parameters.heading }}
|
|
13
|
+
| Name | Type | Description |
|
|
14
|
+
|------|------|-------------|
|
|
15
|
+
{{#each parameters.value}}
|
|
16
|
+
| {{name}} | {{link type}} | {{description}} |
|
|
17
|
+
{{/each}}
|
|
18
|
+
{{/if}}
|
|
19
|
+
|
|
20
|
+
{{#if throws.value}}
|
|
21
|
+
{{ heading throws.headingLevel throws.heading }}
|
|
22
|
+
{{#each throws.value}}
|
|
23
|
+
{{link this.type}}: {{this.description}}
|
|
24
|
+
|
|
25
|
+
{{/each}}
|
|
26
|
+
{{/if}}
|
|
27
|
+
{{/documentablePartialTemplate}}
|
|
28
|
+
|
|
29
|
+
{{#unless @last}}---{{/unless}}
|
|
30
|
+
|
|
31
|
+
{{/each}}
|
|
32
|
+
`.trim();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const documentablePartialTemplate = `
|
|
2
|
+
{{#each doc.annotations}}
|
|
3
|
+
\`{{this}}\`
|
|
4
|
+
{{/each}}
|
|
5
|
+
|
|
6
|
+
{{{renderContent doc.description}}}
|
|
7
|
+
|
|
8
|
+
{{#each doc.customTags}}
|
|
9
|
+
**{{splitAndCapitalize name}}**
|
|
10
|
+
|
|
11
|
+
{{{renderContent description}}}
|
|
12
|
+
|
|
13
|
+
{{/each}}
|
|
14
|
+
|
|
15
|
+
{{> @partial-block}}
|
|
16
|
+
|
|
17
|
+
{{#if doc.mermaid.value}}
|
|
18
|
+
{{ heading doc.mermaid.headingLevel doc.mermaid.heading }}
|
|
19
|
+
{{code doc.mermaid.value}}
|
|
20
|
+
{{/if}}
|
|
21
|
+
|
|
22
|
+
{{#if doc.example.value}}
|
|
23
|
+
{{ heading doc.example.headingLevel doc.example.heading }}
|
|
24
|
+
{{{renderContent doc.example.value}}}
|
|
25
|
+
{{/if}}
|
|
26
|
+
`.trim();
|