@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,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vitepress-example",
|
|
3
|
+
"scripts": {
|
|
4
|
+
"docs:clean": "rimraf --glob 'docs/!(.vitepress|index-frontmatter.md|api-examples.md|markdown-examples.md)'",
|
|
5
|
+
"apexdocs:build": "npm run docs:clean && ts-node ../../src/cli/generate.ts markdown",
|
|
6
|
+
"docs:build": "vitepress build docs",
|
|
7
|
+
"docs:gen": "npm run docs:clean && npm run docs:build",
|
|
8
|
+
"docs:dev": "vitepress dev docs",
|
|
9
|
+
"docs:preview": "vitepress preview docs"
|
|
10
|
+
},
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"ts-node": "^10.9.2",
|
|
13
|
+
"vitepress": "^1.3.1"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"rimraf": "^5.0.7"
|
|
17
|
+
}
|
|
18
|
+
}
|
package/jest.config.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
preset: 'ts-jest',
|
|
3
3
|
testEnvironment: 'node',
|
|
4
|
-
modulePathIgnorePatterns: ['<rootDir>/
|
|
4
|
+
modulePathIgnorePatterns: ['<rootDir>/dist/'],
|
|
5
|
+
moduleNameMapper: {
|
|
6
|
+
'^chalk$': '<rootDir>/__mocks__/chalk.js',
|
|
7
|
+
'^log-update$': '<rootDir>/__mocks__/log-update.js',
|
|
8
|
+
'#utils/(.*)$': '<rootDir>/src/util/$1',
|
|
9
|
+
},
|
|
5
10
|
};
|
package/jest.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cparra/apexdocs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.10",
|
|
4
4
|
"description": "Library with CLI capabilities to generate documentation for Salesforce Apex classes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"apex",
|
|
@@ -10,23 +10,18 @@
|
|
|
10
10
|
"apex-docs",
|
|
11
11
|
"docs"
|
|
12
12
|
],
|
|
13
|
-
"
|
|
13
|
+
"exports": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
14
15
|
"bin": {
|
|
15
|
-
"apexdocs
|
|
16
|
+
"apexdocs": "./dist/cli/generate.js"
|
|
16
17
|
},
|
|
17
|
-
"types": "lib/index.d.ts",
|
|
18
18
|
"scripts": {
|
|
19
|
-
"test": "jest
|
|
20
|
-
"build": "rimraf ./lib && npm run lint && tsc --
|
|
19
|
+
"test": "npm run build && jest",
|
|
20
|
+
"build": "rimraf ./lib && npm run lint && tsc --noEmit && pkgroll",
|
|
21
21
|
"lint": "eslint \"./src/**/*.{js,ts}\" --quiet --fix",
|
|
22
22
|
"prepare": "npm run build",
|
|
23
23
|
"version": "npm run format && git add -A src",
|
|
24
|
-
"postversion": "git push && git push --tags"
|
|
25
|
-
"docs:init": "docsify init docs",
|
|
26
|
-
"docs:serve": "docsify serve docs",
|
|
27
|
-
"execute:example": "rimraf ./docs/types && node lib/cli/generate.js -s examples/force-app -t docs/types --scope global public private protected -g docsify --defaultGroupName \"Misc Group\" --namespace nspc --title \"Sample Documentation\" --documentationRootDir types",
|
|
28
|
-
"execute:example:index:only": "node lib/cli/generate.js -s examples/force-app -t docs --scope global public private -g docsify --indexOnly",
|
|
29
|
-
"execute:example:openapi": "node lib/cli/generate.js -s examples/force-app -t docs -g openapi --openApiTitle \"Sample REST Api\" --namespace nspc --openApiFileName restapi"
|
|
24
|
+
"postversion": "git push && git push --tags"
|
|
30
25
|
},
|
|
31
26
|
"author": "Cesar Parra",
|
|
32
27
|
"license": "MIT",
|
|
@@ -35,26 +30,22 @@
|
|
|
35
30
|
"url": "https://github.com/cesarParra/apexdocs"
|
|
36
31
|
},
|
|
37
32
|
"devDependencies": {
|
|
38
|
-
"@
|
|
39
|
-
"@types/
|
|
40
|
-
"@types/
|
|
41
|
-
"@types/node": "^
|
|
42
|
-
"@types/shelljs": "^0.8.
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"prettier": "^2.4.1",
|
|
55
|
-
"rimraf": "^3.0.2",
|
|
56
|
-
"ts-jest": "^27.1.3",
|
|
57
|
-
"typescript": "^4.8.4"
|
|
33
|
+
"@eslint/js": "^9.6.0",
|
|
34
|
+
"@types/eslint__js": "^8.42.3",
|
|
35
|
+
"@types/jest": "^29.5.12",
|
|
36
|
+
"@types/node": "^20.14.10",
|
|
37
|
+
"@types/shelljs": "^0.8.15",
|
|
38
|
+
"eslint": "^8.57.0",
|
|
39
|
+
"eslint-config-prettier": "^9.1.0",
|
|
40
|
+
"husky": "^9.0.11",
|
|
41
|
+
"jest": "^29.7.0",
|
|
42
|
+
"lint-staged": "^15.2.7",
|
|
43
|
+
"pkgroll": "^2.4.2",
|
|
44
|
+
"prettier": "^3.3.2",
|
|
45
|
+
"rimraf": "^6.0.0",
|
|
46
|
+
"ts-jest": "^29.2.0",
|
|
47
|
+
"typescript": "^5.5.3",
|
|
48
|
+
"typescript-eslint": "^7.16.0"
|
|
58
49
|
},
|
|
59
50
|
"husky": {
|
|
60
51
|
"hooks": {
|
|
@@ -68,12 +59,19 @@
|
|
|
68
59
|
},
|
|
69
60
|
"dependencies": {
|
|
70
61
|
"@cparra/apex-reflection": "2.12.1",
|
|
62
|
+
"@types/js-yaml": "^4.0.9",
|
|
63
|
+
"@types/yargs": "^17.0.32",
|
|
71
64
|
"chalk": "^4.1.2",
|
|
72
65
|
"cosmiconfig": "^9.0.0",
|
|
73
|
-
"
|
|
66
|
+
"cosmiconfig-typescript-loader": "^5.0.0",
|
|
67
|
+
"fast-xml-parser": "^4.4.0",
|
|
68
|
+
"fp-ts": "^2.16.8",
|
|
69
|
+
"handlebars": "^4.7.8",
|
|
74
70
|
"js-yaml": "^4.1.0",
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
71
|
+
"type-fest": "^4.23.0",
|
|
72
|
+
"yargs": "^17.7.2"
|
|
73
|
+
},
|
|
74
|
+
"imports": {
|
|
75
|
+
"#utils/*": "./src/util/*.ts"
|
|
78
76
|
}
|
|
79
77
|
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import ApexBundle from '../model/apex-bundle';
|
|
12
|
-
import Manifest from '../model/manifest';
|
|
13
|
-
import { TypesRepository } from '../model/types-repository';
|
|
14
|
-
import { TypeTranspilerFactory } from '../transpiler/factory';
|
|
1
|
+
import markdown from './generators/markdown';
|
|
2
|
+
import openApi from './generators/openapi';
|
|
3
|
+
|
|
4
|
+
import { ApexFileReader } from './apex-file-reader';
|
|
5
|
+
import { DefaultFileSystem } from './file-system';
|
|
6
|
+
import { Logger } from '#utils/logger';
|
|
7
|
+
import { UnparsedSourceFile, UserDefinedConfig, UserDefinedMarkdownConfig } from '../core/shared/types';
|
|
8
|
+
import { pipe } from 'fp-ts/function';
|
|
9
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
10
|
+
import { ReflectionError } from '../core/markdown/reflection/reflect-source';
|
|
15
11
|
|
|
16
12
|
/**
|
|
17
13
|
* Application entry-point to generate documentation out of Apex source files.
|
|
@@ -20,64 +16,58 @@ export class Apexdocs {
|
|
|
20
16
|
/**
|
|
21
17
|
* Generates documentation out of Apex source files.
|
|
22
18
|
*/
|
|
23
|
-
static generate(): void {
|
|
24
|
-
Logger.
|
|
25
|
-
const fileBodies = ApexFileReader.processFiles(new DefaultFileSystem());
|
|
26
|
-
const manifest = createManifest(new RawBodyParser(fileBodies), this._reflectionWithLogger);
|
|
27
|
-
TypesRepository.getInstance().populateAll(manifest.types);
|
|
28
|
-
const filteredTypes = this.filterByScopes(manifest);
|
|
29
|
-
TypesRepository.getInstance().populateScoped(filteredTypes);
|
|
30
|
-
const processor = TypeTranspilerFactory.get(Settings.getInstance().targetGenerator);
|
|
31
|
-
Transpiler.generate(filteredTypes, processor);
|
|
32
|
-
const generatedFiles = processor.fileBuilder().files();
|
|
33
|
-
|
|
34
|
-
const files: TargetFile[] = [];
|
|
35
|
-
FileWriter.write(generatedFiles, (file: TargetFile) => {
|
|
36
|
-
Logger.logSingle(`${file.name} processed.`, false, 'green', false);
|
|
37
|
-
files.push(file);
|
|
38
|
-
});
|
|
19
|
+
static async generate(config: UserDefinedConfig): Promise<void> {
|
|
20
|
+
Logger.logSingle(`Generating ${config.targetGenerator} documentation...`);
|
|
39
21
|
|
|
40
|
-
|
|
22
|
+
try {
|
|
23
|
+
const fileBodies = await ApexFileReader.processFiles(
|
|
24
|
+
new DefaultFileSystem(),
|
|
25
|
+
config.sourceDir,
|
|
26
|
+
config.includeMetadata,
|
|
27
|
+
);
|
|
41
28
|
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
switch (config.targetGenerator) {
|
|
30
|
+
case 'markdown':
|
|
31
|
+
await generateMarkdownDocumentation(fileBodies, config)();
|
|
32
|
+
break;
|
|
33
|
+
case 'openapi':
|
|
34
|
+
openApi(fileBodies, config);
|
|
35
|
+
Logger.logSingle('✔️ Documentation generated successfully!');
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
Logger.logSingle(`❌ An error occurred while generating the documentation: ${error}`, 'red');
|
|
40
|
+
}
|
|
44
41
|
}
|
|
42
|
+
}
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
// we only keep classes annotated as @RestResource
|
|
57
|
-
filteredTypes = manifest.filteredByAccessModifierAndAnnotations([
|
|
58
|
-
'restresource',
|
|
59
|
-
'httpdelete',
|
|
60
|
-
'httpget',
|
|
61
|
-
'httppatch',
|
|
62
|
-
'httppost',
|
|
63
|
-
'httpput',
|
|
64
|
-
]);
|
|
65
|
-
filteredLogMessage = `Filtered ${
|
|
66
|
-
manifest.types.length - filteredTypes.length
|
|
67
|
-
} file(s), only keeping classes annotated as @RestResource.`;
|
|
68
|
-
}
|
|
69
|
-
Logger.clear();
|
|
44
|
+
function generateMarkdownDocumentation(fileBodies: UnparsedSourceFile[], config: UserDefinedMarkdownConfig) {
|
|
45
|
+
return pipe(
|
|
46
|
+
markdown(fileBodies, config),
|
|
47
|
+
TE.map(() => Logger.logSingle('✔️ Documentation generated successfully!')),
|
|
48
|
+
TE.mapLeft((error) => {
|
|
49
|
+
if (error._tag === 'HookError') {
|
|
50
|
+
Logger.error('Error(s) occurred while processing hooks. Please review the following issues:');
|
|
51
|
+
Logger.error(error.error);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
70
54
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
55
|
+
if (error._tag === 'FileWritingError') {
|
|
56
|
+
Logger.error(error.message);
|
|
57
|
+
Logger.error(error.error);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
75
60
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
61
|
+
const errorMessages = [
|
|
62
|
+
'Error(s) occurred while parsing files. Please review the following issues:',
|
|
63
|
+
...error.errors.map(formatReflectionError),
|
|
64
|
+
].join('\n');
|
|
65
|
+
|
|
66
|
+
Logger.error(errorMessages);
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function formatReflectionError(error: ReflectionError) {
|
|
72
|
+
return `Source file: ${error.file}\n${error.message}\n`;
|
|
83
73
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Settings, SettingsConfig } from '../../core/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: 'markdown',
|
|
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', async () => {
|
|
22
|
+
const result = await ApexFileReader.processFiles(
|
|
23
|
+
{
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
|
+
isDirectory(_: string): Promise<boolean> {
|
|
26
|
+
return Promise.resolve(false);
|
|
27
|
+
},
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
29
|
+
joinPath(_: string): string {
|
|
30
|
+
return '';
|
|
31
|
+
},
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
readDirectory(_: string): Promise<string[]> {
|
|
34
|
+
return Promise.resolve([]);
|
|
35
|
+
},
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
+
readFile(_: string): Promise<string> {
|
|
38
|
+
return Promise.resolve('');
|
|
39
|
+
},
|
|
40
|
+
exists(): boolean {
|
|
41
|
+
return true;
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
'',
|
|
45
|
+
false,
|
|
46
|
+
);
|
|
47
|
+
expect(result.length).toBe(0);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('returns an empty list when there are no Apex files in the directory', async () => {
|
|
51
|
+
const result = await ApexFileReader.processFiles(
|
|
52
|
+
{
|
|
53
|
+
isDirectory(): Promise<boolean> {
|
|
54
|
+
return Promise.resolve(false);
|
|
55
|
+
},
|
|
56
|
+
joinPath(): string {
|
|
57
|
+
return '';
|
|
58
|
+
},
|
|
59
|
+
readDirectory(): Promise<string[]> {
|
|
60
|
+
return Promise.resolve(['SomeFile.md']);
|
|
61
|
+
},
|
|
62
|
+
readFile(): Promise<string> {
|
|
63
|
+
return Promise.resolve('');
|
|
64
|
+
},
|
|
65
|
+
exists(): boolean {
|
|
66
|
+
return true;
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
'',
|
|
70
|
+
false,
|
|
71
|
+
);
|
|
72
|
+
expect(result.length).toBe(0);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('returns the file contents for an Apex file', async () => {
|
|
76
|
+
const result = await ApexFileReader.processFiles(
|
|
77
|
+
{
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
+
isDirectory(_: string): Promise<boolean> {
|
|
80
|
+
return Promise.resolve(false);
|
|
81
|
+
},
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
83
|
+
joinPath(_: string): string {
|
|
84
|
+
return 'SomeApexFile.cls';
|
|
85
|
+
},
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
87
|
+
readDirectory(_: string): Promise<string[]> {
|
|
88
|
+
return Promise.resolve(['SomeApexFile.cls']);
|
|
89
|
+
},
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
+
readFile(_: string): Promise<string> {
|
|
92
|
+
return Promise.resolve('public class MyClass{}');
|
|
93
|
+
},
|
|
94
|
+
exists(): boolean {
|
|
95
|
+
return true;
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
'',
|
|
99
|
+
false,
|
|
100
|
+
);
|
|
101
|
+
expect(result.length).toBe(1);
|
|
102
|
+
expect(result[0].content).toBe('public class MyClass{}');
|
|
103
|
+
});
|
|
104
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { FileSystem } from './file-system';
|
|
2
|
+
import { UnparsedSourceFile } from '../core/shared/types';
|
|
3
|
+
|
|
4
|
+
const APEX_FILE_EXTENSION = '.cls';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Reads from .cls files and returns their raw body.
|
|
8
|
+
*/
|
|
9
|
+
export class ApexFileReader {
|
|
10
|
+
/**
|
|
11
|
+
* Reads from .cls files and returns their raw body.
|
|
12
|
+
*/
|
|
13
|
+
static async processFiles(
|
|
14
|
+
fileSystem: FileSystem,
|
|
15
|
+
rootPath: string,
|
|
16
|
+
includeMetadata: boolean,
|
|
17
|
+
): Promise<UnparsedSourceFile[]> {
|
|
18
|
+
const filePaths = await this.getFilePaths(fileSystem, rootPath);
|
|
19
|
+
const apexFilePaths = filePaths.filter((filePath) => this.isApexFile(filePath));
|
|
20
|
+
const filePromises = apexFilePaths.map((filePath) => this.processFile(fileSystem, filePath, includeMetadata));
|
|
21
|
+
return Promise.all(filePromises);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private static async getFilePaths(fileSystem: FileSystem, rootPath: string): Promise<string[]> {
|
|
25
|
+
const directoryContents = await fileSystem.readDirectory(rootPath);
|
|
26
|
+
const paths: string[] = [];
|
|
27
|
+
for (const filePath of directoryContents) {
|
|
28
|
+
const currentPath = fileSystem.joinPath(rootPath, filePath);
|
|
29
|
+
if (await fileSystem.isDirectory(currentPath)) {
|
|
30
|
+
paths.push(...(await this.getFilePaths(fileSystem, currentPath)));
|
|
31
|
+
}
|
|
32
|
+
paths.push(currentPath);
|
|
33
|
+
}
|
|
34
|
+
return paths;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private static async processFile(
|
|
38
|
+
fileSystem: FileSystem,
|
|
39
|
+
filePath: string,
|
|
40
|
+
includeMetadata: boolean,
|
|
41
|
+
): Promise<UnparsedSourceFile> {
|
|
42
|
+
const rawTypeContent = await fileSystem.readFile(filePath);
|
|
43
|
+
const metadataPath = `${filePath}-meta.xml`;
|
|
44
|
+
let rawMetadataContent = null;
|
|
45
|
+
if (includeMetadata) {
|
|
46
|
+
rawMetadataContent = fileSystem.exists(metadataPath) ? await fileSystem.readFile(metadataPath) : null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return { filePath, content: rawTypeContent, metadataContent: rawMetadataContent };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private static isApexFile(currentFile: string): boolean {
|
|
53
|
+
return currentFile.endsWith(APEX_FILE_EXTENSION);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
|
|
4
|
+
export interface FileSystem {
|
|
5
|
+
isDirectory: (path: string) => Promise<boolean>;
|
|
6
|
+
readDirectory: (sourceDirectory: string) => Promise<string[]>;
|
|
7
|
+
readFile: (path: string) => Promise<string>;
|
|
8
|
+
joinPath: (...paths: string[]) => string;
|
|
9
|
+
exists: (path: string) => boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function stat(path: string): Promise<fs.Stats> {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
fs.stat(path, (err, stats) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
reject(err);
|
|
17
|
+
} else {
|
|
18
|
+
resolve(stats);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function readdir(path: string): Promise<string[]> {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
fs.readdir(path, (err, files) => {
|
|
27
|
+
if (err) {
|
|
28
|
+
reject(err);
|
|
29
|
+
} else {
|
|
30
|
+
resolve(files);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function readFile(path: string): Promise<string> {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
fs.readFile(path, (err, data) => {
|
|
39
|
+
if (err) {
|
|
40
|
+
reject(err);
|
|
41
|
+
} else {
|
|
42
|
+
resolve(data.toString());
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class DefaultFileSystem implements FileSystem {
|
|
49
|
+
async isDirectory(pathToRead: string): Promise<boolean> {
|
|
50
|
+
const stats = await stat(pathToRead);
|
|
51
|
+
return stats.isDirectory();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
readDirectory(sourceDirectory: string): Promise<string[]> {
|
|
55
|
+
return readdir(sourceDirectory);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
readFile(pathToRead: string): Promise<string> {
|
|
59
|
+
return readFile(pathToRead);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
joinPath(...paths: string[]): string {
|
|
63
|
+
return path.join(...paths);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
exists(path: string): boolean {
|
|
67
|
+
return fs.existsSync(path);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as fs from 'fs';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import * as TE from 'fp-ts/lib/TaskEither';
|
|
4
|
+
import { PageData } from '../core/shared/types';
|
|
5
|
+
import { pipe } from 'fp-ts/function';
|
|
6
|
+
|
|
7
|
+
const mkdir: (path: fs.PathLike, options: fs.MakeDirectoryOptions) => TE.TaskEither<NodeJS.ErrnoException, void> =
|
|
8
|
+
TE.taskify(fs.mkdir);
|
|
9
|
+
|
|
10
|
+
const writeFile: (
|
|
11
|
+
path: fs.PathOrFileDescriptor,
|
|
12
|
+
data: string,
|
|
13
|
+
options?: fs.WriteFileOptions,
|
|
14
|
+
) => TE.TaskEither<NodeJS.ErrnoException, void> = TE.taskify(fs.writeFile);
|
|
15
|
+
|
|
16
|
+
export function writeFiles(files: PageData[], outputDir: string, onWriteCallback?: (file: PageData) => void) {
|
|
17
|
+
return pipe(
|
|
18
|
+
files,
|
|
19
|
+
TE.traverseArray((file) => writeSingle(file, outputDir, onWriteCallback)),
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function writeSingle(file: PageData, outputDir: string, onWriteCallback?: (file: PageData) => void) {
|
|
24
|
+
const ensureDirectoryExists = ({ outputDocPath }: PageData) =>
|
|
25
|
+
mkdir(path.dirname(outputDocPath), { recursive: true });
|
|
26
|
+
|
|
27
|
+
const writeContents = (file: PageData) => writeFile(file.outputDocPath, file.content, 'utf8');
|
|
28
|
+
|
|
29
|
+
return pipe(
|
|
30
|
+
resolveTargetLocation(file, outputDir),
|
|
31
|
+
(file) => TE.right(file),
|
|
32
|
+
TE.tapIO(ensureDirectoryExists),
|
|
33
|
+
TE.flatMap(writeContents),
|
|
34
|
+
TE.map(() => onWriteCallback?.(file)),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function resolveTargetLocation(file: PageData, outputDir: string): PageData {
|
|
39
|
+
return {
|
|
40
|
+
...file,
|
|
41
|
+
outputDocPath: path.join(outputDir, file.outputDocPath),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { generateDocs } from '../../core/markdown/generate-docs';
|
|
2
|
+
import { pipe } from 'fp-ts/function';
|
|
3
|
+
import {
|
|
4
|
+
PageData,
|
|
5
|
+
PostHookDocumentationBundle,
|
|
6
|
+
UnparsedSourceFile,
|
|
7
|
+
UserDefinedMarkdownConfig,
|
|
8
|
+
} from '../../core/shared/types';
|
|
9
|
+
import { referenceGuideTemplate } from '../../core/markdown/templates/reference-guide';
|
|
10
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
11
|
+
import { isSkip } from '../../core/shared/utils';
|
|
12
|
+
import { writeFiles } from '../file-writer';
|
|
13
|
+
|
|
14
|
+
class FileWritingError {
|
|
15
|
+
readonly _tag = 'FileWritingError';
|
|
16
|
+
|
|
17
|
+
constructor(
|
|
18
|
+
public message: string,
|
|
19
|
+
public error: unknown,
|
|
20
|
+
) {}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default function generate(bundles: UnparsedSourceFile[], config: UserDefinedMarkdownConfig) {
|
|
24
|
+
return pipe(
|
|
25
|
+
generateDocumentationBundle(bundles, config),
|
|
26
|
+
TE.flatMap((files) => writeFilesToSystem(files, config.targetDir)),
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function generateDocumentationBundle(bundles: UnparsedSourceFile[], config: UserDefinedMarkdownConfig) {
|
|
31
|
+
return generateDocs(bundles, {
|
|
32
|
+
...config,
|
|
33
|
+
referenceGuideTemplate: referenceGuideTemplate,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function writeFilesToSystem(files: PostHookDocumentationBundle, outputDir: string) {
|
|
38
|
+
return pipe(
|
|
39
|
+
[files.referenceGuide, ...files.docs].filter((file) => !isSkip(file)),
|
|
40
|
+
(files) => writeFiles(files as PageData[], outputDir),
|
|
41
|
+
TE.mapLeft((error) => {
|
|
42
|
+
return new FileWritingError('An error occurred while writing files to the system.', error);
|
|
43
|
+
}),
|
|
44
|
+
);
|
|
45
|
+
}
|