@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,238 @@
|
|
|
1
|
+
import { ClassMirror, EnumMirror, InterfaceMirror, Type } from '@cparra/apex-reflection';
|
|
2
|
+
import {
|
|
3
|
+
RenderableType,
|
|
4
|
+
RenderableClass,
|
|
5
|
+
RenderableEnum,
|
|
6
|
+
RenderableInterface,
|
|
7
|
+
RenderableSection,
|
|
8
|
+
GroupedMember,
|
|
9
|
+
ClassMirrorWithInheritanceChain,
|
|
10
|
+
FieldMirrorWithInheritance,
|
|
11
|
+
PropertyMirrorWithInheritance,
|
|
12
|
+
GetRenderableContentByTypeName,
|
|
13
|
+
} from './types';
|
|
14
|
+
import { adaptDescribable, adaptDocumentable } from './documentables';
|
|
15
|
+
import { adaptConstructor, adaptMethod } from './methods-and-constructors';
|
|
16
|
+
import { adaptFieldOrProperty } from './fields-and-properties';
|
|
17
|
+
import { MarkdownGeneratorConfig } from '../generate-docs';
|
|
18
|
+
import { SourceFileMetadata } from '../../shared/types';
|
|
19
|
+
|
|
20
|
+
type GetReturnRenderable<T extends Type> = T extends InterfaceMirror
|
|
21
|
+
? RenderableInterface
|
|
22
|
+
: T extends ClassMirror
|
|
23
|
+
? RenderableClass
|
|
24
|
+
: RenderableEnum;
|
|
25
|
+
|
|
26
|
+
export function typeToRenderable<T extends Type>(
|
|
27
|
+
parsedFile: { source: SourceFileMetadata; type: T },
|
|
28
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
29
|
+
config: MarkdownGeneratorConfig,
|
|
30
|
+
): GetReturnRenderable<T> & { filePath: string; namespace?: string } {
|
|
31
|
+
function getRenderable(): RenderableInterface | RenderableClass | RenderableEnum {
|
|
32
|
+
const { type } = parsedFile;
|
|
33
|
+
switch (type.type_name) {
|
|
34
|
+
case 'enum':
|
|
35
|
+
return enumTypeToEnumSource(type as EnumMirror, linkGenerator) as RenderableEnum;
|
|
36
|
+
case 'interface':
|
|
37
|
+
return interfaceTypeToInterfaceSource(type as InterfaceMirror, linkGenerator) as RenderableInterface;
|
|
38
|
+
case 'class':
|
|
39
|
+
return classTypeToClassSource(type as ClassMirrorWithInheritanceChain, linkGenerator) as RenderableClass;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...(getRenderable() as GetReturnRenderable<T>),
|
|
45
|
+
filePath: parsedFile.source.filePath,
|
|
46
|
+
namespace: config.namespace,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function baseTypeAdapter(
|
|
51
|
+
type: EnumMirror | InterfaceMirror | ClassMirror,
|
|
52
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
53
|
+
baseHeadingLevel: number,
|
|
54
|
+
): RenderableType {
|
|
55
|
+
function getHeading(type: Type): string {
|
|
56
|
+
const suffixMap = {
|
|
57
|
+
class: 'Class',
|
|
58
|
+
interface: 'Interface',
|
|
59
|
+
enum: 'Enum',
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return `${type.name} ${suffixMap[type.type_name]}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
headingLevel: baseHeadingLevel,
|
|
67
|
+
heading: getHeading(type),
|
|
68
|
+
doc: adaptDocumentable(type, linkGenerator, baseHeadingLevel + 1),
|
|
69
|
+
name: type.name,
|
|
70
|
+
meta: {
|
|
71
|
+
accessModifier: type.access_modifier,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function enumTypeToEnumSource(
|
|
77
|
+
enumType: EnumMirror,
|
|
78
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
79
|
+
baseHeadingLevel: number = 1,
|
|
80
|
+
): RenderableEnum {
|
|
81
|
+
return {
|
|
82
|
+
type: 'enum',
|
|
83
|
+
...baseTypeAdapter(enumType, linkGenerator, baseHeadingLevel),
|
|
84
|
+
values: {
|
|
85
|
+
headingLevel: baseHeadingLevel + 1,
|
|
86
|
+
heading: 'Values',
|
|
87
|
+
value: enumType.values.map((value) => ({
|
|
88
|
+
...adaptDescribable(value.docComment?.descriptionLines, linkGenerator),
|
|
89
|
+
value: value.name,
|
|
90
|
+
})),
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function interfaceTypeToInterfaceSource(
|
|
96
|
+
interfaceType: InterfaceMirror,
|
|
97
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
98
|
+
baseHeadingLevel: number = 1,
|
|
99
|
+
): RenderableInterface {
|
|
100
|
+
return {
|
|
101
|
+
type: 'interface',
|
|
102
|
+
...baseTypeAdapter(interfaceType, linkGenerator, baseHeadingLevel),
|
|
103
|
+
extends: interfaceType.extended_interfaces.map(linkGenerator),
|
|
104
|
+
methods: {
|
|
105
|
+
headingLevel: baseHeadingLevel + 1,
|
|
106
|
+
heading: 'Methods',
|
|
107
|
+
value: interfaceType.methods.map((method) => adaptMethod(method, linkGenerator, baseHeadingLevel + 2)),
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function classTypeToClassSource(
|
|
113
|
+
classType: ClassMirrorWithInheritanceChain,
|
|
114
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
115
|
+
baseHeadingLevel: number = 1,
|
|
116
|
+
): RenderableClass {
|
|
117
|
+
return {
|
|
118
|
+
type: 'class',
|
|
119
|
+
...baseTypeAdapter(classType, linkGenerator, baseHeadingLevel),
|
|
120
|
+
classModifier: classType.classModifier,
|
|
121
|
+
sharingModifier: classType.sharingModifier,
|
|
122
|
+
implements: classType.implemented_interfaces.map(linkGenerator),
|
|
123
|
+
extends: classType.inheritanceChain.map(linkGenerator),
|
|
124
|
+
methods: adaptMembers('Methods', classType.methods, adaptMethod, linkGenerator, baseHeadingLevel + 1),
|
|
125
|
+
constructors: adaptMembers(
|
|
126
|
+
'Constructors',
|
|
127
|
+
classType.constructors,
|
|
128
|
+
(constructor, linkGenerator, baseHeadingLevel) =>
|
|
129
|
+
adaptConstructor(classType.name, constructor, linkGenerator, baseHeadingLevel),
|
|
130
|
+
linkGenerator,
|
|
131
|
+
baseHeadingLevel + 1,
|
|
132
|
+
),
|
|
133
|
+
fields: adaptMembers(
|
|
134
|
+
'Fields',
|
|
135
|
+
classType.fields as FieldMirrorWithInheritance[],
|
|
136
|
+
adaptFieldOrProperty,
|
|
137
|
+
linkGenerator,
|
|
138
|
+
baseHeadingLevel + 1,
|
|
139
|
+
),
|
|
140
|
+
properties: adaptMembers(
|
|
141
|
+
'Properties',
|
|
142
|
+
classType.properties as PropertyMirrorWithInheritance[],
|
|
143
|
+
adaptFieldOrProperty,
|
|
144
|
+
linkGenerator,
|
|
145
|
+
baseHeadingLevel + 1,
|
|
146
|
+
),
|
|
147
|
+
innerClasses: {
|
|
148
|
+
headingLevel: baseHeadingLevel + 1,
|
|
149
|
+
heading: 'Classes',
|
|
150
|
+
value: classType.classes.map((innerClass) =>
|
|
151
|
+
classTypeToClassSource({ ...innerClass, inheritanceChain: [] }, linkGenerator, baseHeadingLevel + 2),
|
|
152
|
+
),
|
|
153
|
+
},
|
|
154
|
+
innerEnums: {
|
|
155
|
+
headingLevel: baseHeadingLevel + 1,
|
|
156
|
+
heading: 'Enums',
|
|
157
|
+
value: classType.enums.map((innerEnum) => enumTypeToEnumSource(innerEnum, linkGenerator, baseHeadingLevel + 2)),
|
|
158
|
+
},
|
|
159
|
+
innerInterfaces: {
|
|
160
|
+
headingLevel: baseHeadingLevel + 1,
|
|
161
|
+
heading: 'Interfaces',
|
|
162
|
+
value: classType.interfaces.map((innerInterface) =>
|
|
163
|
+
interfaceTypeToInterfaceSource(innerInterface, linkGenerator, baseHeadingLevel + 2),
|
|
164
|
+
),
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
type Groupable = { group?: string; groupDescription?: string };
|
|
170
|
+
|
|
171
|
+
function adaptMembers<T extends Groupable, K>(
|
|
172
|
+
heading: string,
|
|
173
|
+
members: T[],
|
|
174
|
+
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
175
|
+
linkFromTypeNameGenerator: GetRenderableContentByTypeName,
|
|
176
|
+
headingLevel: number,
|
|
177
|
+
): RenderableSection<K[] | GroupedMember<K>[]> & { isGrouped: boolean } {
|
|
178
|
+
return {
|
|
179
|
+
headingLevel,
|
|
180
|
+
heading,
|
|
181
|
+
isGrouped: hasGroup(members),
|
|
182
|
+
value: hasGroup(members)
|
|
183
|
+
? toGroupedMembers(members, adapter, linkFromTypeNameGenerator, headingLevel + 1)
|
|
184
|
+
: toFlat(members, adapter, linkFromTypeNameGenerator, headingLevel + 1),
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function hasGroup(members: Groupable[]): boolean {
|
|
189
|
+
return members.some((member) => member.group);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function toFlat<T extends Groupable, K>(
|
|
193
|
+
members: T[],
|
|
194
|
+
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
195
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
196
|
+
baseHeadingLevel: number,
|
|
197
|
+
): K[] {
|
|
198
|
+
return members.map((member) => adapter(member, linkGenerator, baseHeadingLevel));
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function toGroupedMembers<T extends Groupable, K>(
|
|
202
|
+
members: T[],
|
|
203
|
+
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
204
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
205
|
+
baseHeadingLevel: number,
|
|
206
|
+
): GroupedMember<K>[] {
|
|
207
|
+
const groupedMembers = groupByGroupName(members);
|
|
208
|
+
return Object.entries(groupedMembers).map(([groupName, members]) =>
|
|
209
|
+
singleGroup(baseHeadingLevel, groupName, adapter, members, linkGenerator),
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function groupByGroupName<T extends Groupable>(members: T[]): Record<string, T[]> {
|
|
214
|
+
return members.reduce(
|
|
215
|
+
(acc, member) => {
|
|
216
|
+
const groupName = member.group ?? 'Other';
|
|
217
|
+
acc[groupName] = acc[groupName] ?? [];
|
|
218
|
+
acc[groupName].push(member);
|
|
219
|
+
return acc;
|
|
220
|
+
},
|
|
221
|
+
{} as Record<string, T[]>,
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function singleGroup<T extends Groupable, K>(
|
|
226
|
+
headingLevel: number,
|
|
227
|
+
groupName: string,
|
|
228
|
+
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
229
|
+
members: T[],
|
|
230
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
231
|
+
): GroupedMember<K> {
|
|
232
|
+
return {
|
|
233
|
+
headingLevel: headingLevel,
|
|
234
|
+
heading: groupName,
|
|
235
|
+
groupDescription: members[0].groupDescription, // All fields in the group have the same description
|
|
236
|
+
value: toFlat(members, adapter, linkGenerator, headingLevel + 1),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { CustomTag, RenderableDocumentation, RenderableContent } from './types';
|
|
2
|
+
import { Describable, Documentable, GetRenderableContentByTypeName } from './types';
|
|
3
|
+
import { replaceInlineReferences } from './inline';
|
|
4
|
+
import { isEmptyLine } from './type-utils';
|
|
5
|
+
|
|
6
|
+
export function adaptDescribable(
|
|
7
|
+
describable: Describable,
|
|
8
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
9
|
+
): {
|
|
10
|
+
description?: RenderableContent[];
|
|
11
|
+
} {
|
|
12
|
+
return {
|
|
13
|
+
description: describableToRenderableContent(describable, linkGenerator),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function describableToRenderableContent(
|
|
18
|
+
describable: Describable,
|
|
19
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
20
|
+
): RenderableContent[] | undefined {
|
|
21
|
+
if (!describable) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let content: RenderableContent[] = [];
|
|
26
|
+
for (let i = 0; i < describable.length; i++) {
|
|
27
|
+
const line = describable[i];
|
|
28
|
+
// The language might or might not be present after ```
|
|
29
|
+
const codeBlockMatch = line.match(/^```([a-zA-Z]*)$/);
|
|
30
|
+
if (codeBlockMatch) {
|
|
31
|
+
// Check if the language is present, if not, fallback to "apex"
|
|
32
|
+
const language = codeBlockMatch[1] || 'apex';
|
|
33
|
+
const codeBlockLines: string[] = [];
|
|
34
|
+
i++;
|
|
35
|
+
while (i < describable.length) {
|
|
36
|
+
const currentLine = describable[i];
|
|
37
|
+
if (currentLine.trim() === '```') {
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
codeBlockLines.push(currentLine);
|
|
41
|
+
i++;
|
|
42
|
+
}
|
|
43
|
+
content = [
|
|
44
|
+
...content,
|
|
45
|
+
{
|
|
46
|
+
__type: 'code-block',
|
|
47
|
+
language,
|
|
48
|
+
content: codeBlockLines,
|
|
49
|
+
},
|
|
50
|
+
{ __type: 'empty-line' },
|
|
51
|
+
];
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
content = [
|
|
56
|
+
...content,
|
|
57
|
+
...replaceInlineReferences(line, linkGenerator),
|
|
58
|
+
{
|
|
59
|
+
__type: 'empty-line',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
return (
|
|
64
|
+
content
|
|
65
|
+
// If the last element is an empty line, remove it
|
|
66
|
+
.filter((line, index, lines) => !(isEmptyLine(line) && index === lines.length - 1))
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function adaptDocumentable(
|
|
71
|
+
documentable: Documentable,
|
|
72
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
73
|
+
subHeadingLevel: number,
|
|
74
|
+
): RenderableDocumentation {
|
|
75
|
+
function extractCustomTags(type: Documentable): CustomTag[] {
|
|
76
|
+
const baseTags = ['description', 'group', 'author', 'date', 'see', 'example', 'throws', 'exception'];
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
type.docComment?.annotations
|
|
80
|
+
.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase()))
|
|
81
|
+
.map<CustomTag>((currentAnnotation) => ({
|
|
82
|
+
...adaptDescribable(currentAnnotation.bodyLines, linkGenerator),
|
|
83
|
+
name: currentAnnotation.name,
|
|
84
|
+
})) ?? []
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function extractAnnotationBody(type: Documentable, annotationName: string): string | undefined {
|
|
89
|
+
return type.docComment?.annotations.find(
|
|
90
|
+
(currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName,
|
|
91
|
+
)?.body;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function extractSeeAnnotations(type: Documentable): string[] {
|
|
95
|
+
return (
|
|
96
|
+
type.docComment?.annotations
|
|
97
|
+
.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === 'see')
|
|
98
|
+
.map((currentAnnotation) => currentAnnotation.body) ?? []
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
...adaptDescribable(documentable.docComment?.descriptionLines, linkGenerator),
|
|
103
|
+
annotations: documentable.annotations.map((annotation) => annotation.type.toUpperCase()),
|
|
104
|
+
customTags: extractCustomTags(documentable),
|
|
105
|
+
example: {
|
|
106
|
+
headingLevel: subHeadingLevel,
|
|
107
|
+
heading: 'Example',
|
|
108
|
+
value: describableToRenderableContent(documentable.docComment?.exampleAnnotation?.bodyLines, linkGenerator),
|
|
109
|
+
},
|
|
110
|
+
group: extractAnnotationBody(documentable, 'group'),
|
|
111
|
+
author: extractAnnotationBody(documentable, 'author'),
|
|
112
|
+
date: extractAnnotationBody(documentable, 'date'),
|
|
113
|
+
sees: extractSeeAnnotations(documentable).map(linkGenerator),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CodeBlock,
|
|
3
|
+
FieldMirrorWithInheritance,
|
|
4
|
+
PropertyMirrorWithInheritance,
|
|
5
|
+
RenderableField,
|
|
6
|
+
GetRenderableContentByTypeName,
|
|
7
|
+
} from './types';
|
|
8
|
+
import { adaptDocumentable } from './documentables';
|
|
9
|
+
|
|
10
|
+
export function adaptFieldOrProperty(
|
|
11
|
+
field: FieldMirrorWithInheritance | PropertyMirrorWithInheritance,
|
|
12
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
13
|
+
baseHeadingLevel: number,
|
|
14
|
+
): RenderableField {
|
|
15
|
+
function buildSignature(): CodeBlock {
|
|
16
|
+
const { access_modifier, name } = field;
|
|
17
|
+
const memberModifiers = field.memberModifiers.join(' ');
|
|
18
|
+
const codeContents = `${access_modifier} ${memberModifiers} ${name}`
|
|
19
|
+
// remove double spaces
|
|
20
|
+
.replace(/ {2}/g, ' ');
|
|
21
|
+
return {
|
|
22
|
+
__type: 'code-block',
|
|
23
|
+
language: 'apex',
|
|
24
|
+
content: [codeContents],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
headingLevel: baseHeadingLevel,
|
|
30
|
+
doc: adaptDocumentable(field, linkGenerator, baseHeadingLevel + 1),
|
|
31
|
+
heading: field.name,
|
|
32
|
+
type: {
|
|
33
|
+
headingLevel: baseHeadingLevel + 1,
|
|
34
|
+
heading: 'Type',
|
|
35
|
+
value: linkGenerator(field.typeReference.rawDeclaration),
|
|
36
|
+
},
|
|
37
|
+
inherited: field.inherited,
|
|
38
|
+
accessModifier: field.access_modifier,
|
|
39
|
+
signature: {
|
|
40
|
+
headingLevel: baseHeadingLevel + 1,
|
|
41
|
+
heading: 'Signature',
|
|
42
|
+
value: buildSignature(),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { StringOrLink } from './types';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { LinkingStrategy } from '../../shared/types';
|
|
4
|
+
|
|
5
|
+
export type LinkingStrategyFn = (
|
|
6
|
+
references: Record<string, { referencePath: string; displayName: string } | undefined>,
|
|
7
|
+
from: string,
|
|
8
|
+
referenceName: string,
|
|
9
|
+
) => StringOrLink;
|
|
10
|
+
|
|
11
|
+
export const generateLink = (strategy: LinkingStrategy): LinkingStrategyFn => {
|
|
12
|
+
switch (strategy) {
|
|
13
|
+
case 'relative':
|
|
14
|
+
return generateRelativeLink;
|
|
15
|
+
case 'no-link':
|
|
16
|
+
return generateNoLink;
|
|
17
|
+
case 'none':
|
|
18
|
+
return returnReferenceAsIs;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const generateRelativeLink = (
|
|
23
|
+
references: Record<string, { referencePath: string; displayName: string } | undefined>,
|
|
24
|
+
from: string, // The name of the file for which the reference is being generated
|
|
25
|
+
referenceName: string,
|
|
26
|
+
): StringOrLink => {
|
|
27
|
+
function getRelativePath(fromPath: string, toPath: string) {
|
|
28
|
+
return path.relative(path.parse(path.join('/', fromPath)).dir, path.join('/', toPath));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const referenceTo = references[referenceName];
|
|
32
|
+
if (!referenceTo) {
|
|
33
|
+
return referenceName;
|
|
34
|
+
}
|
|
35
|
+
// When linking from the base path (e.g. the reference guide/index page), the reference path is the same as the output
|
|
36
|
+
// path.
|
|
37
|
+
if (referenceTo && from === '__base__') {
|
|
38
|
+
return {
|
|
39
|
+
__type: 'link',
|
|
40
|
+
title: referenceTo.displayName,
|
|
41
|
+
url: getRelativePath('', referenceTo.referencePath),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const referenceFrom = references[from];
|
|
46
|
+
|
|
47
|
+
if (!referenceFrom) {
|
|
48
|
+
return referenceTo.displayName;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
__type: 'link',
|
|
53
|
+
title: referenceTo.displayName,
|
|
54
|
+
url: getRelativePath(referenceFrom.referencePath, referenceTo.referencePath),
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const generateNoLink = (
|
|
59
|
+
references: Record<string, { referencePath: string; displayName: string } | undefined>,
|
|
60
|
+
_from: string,
|
|
61
|
+
referenceName: string,
|
|
62
|
+
): StringOrLink => {
|
|
63
|
+
const referenceTo = references[referenceName];
|
|
64
|
+
return referenceTo ? referenceTo.displayName : referenceName;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const returnReferenceAsIs = (
|
|
68
|
+
references: Record<string, { referencePath: string; displayName: string } | undefined>,
|
|
69
|
+
_from: string,
|
|
70
|
+
referenceName: string,
|
|
71
|
+
): StringOrLink => {
|
|
72
|
+
const referenceTo = references[referenceName];
|
|
73
|
+
if (!referenceTo) {
|
|
74
|
+
return referenceName;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
__type: 'link',
|
|
79
|
+
title: referenceTo.displayName,
|
|
80
|
+
url: referenceTo.referencePath,
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { InlineCode, Link, RenderableContent } from './types';
|
|
2
|
+
import { pipe } from 'fp-ts/function';
|
|
3
|
+
import { apply } from '#utils/fp';
|
|
4
|
+
|
|
5
|
+
type InlineRenderableContent = InlineCode | Link | string;
|
|
6
|
+
|
|
7
|
+
type ToInlineRenderableContent = (typeName: string) => InlineRenderableContent;
|
|
8
|
+
|
|
9
|
+
function defaultGetEmailByReference(email: string): Link {
|
|
10
|
+
return {
|
|
11
|
+
__type: 'link',
|
|
12
|
+
title: email,
|
|
13
|
+
url: `mailto:${email}`,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function replaceInlineReferences(
|
|
18
|
+
text: string,
|
|
19
|
+
linkReplacer: ToInlineRenderableContent,
|
|
20
|
+
emailReplacer: ToInlineRenderableContent = defaultGetEmailByReference,
|
|
21
|
+
): RenderableContent[] {
|
|
22
|
+
const inlineLinks = apply(replaceInlineLinks, linkReplacer);
|
|
23
|
+
const inlineEmails = apply(replaceInlineEmails, emailReplacer);
|
|
24
|
+
|
|
25
|
+
return pipe(inlineCode([text]), inlineLinks, inlineEmails);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function inlineCode(renderableContents: RenderableContent[]): RenderableContent[] {
|
|
29
|
+
return renderableContents.flatMap((renderableContent) => inlineCodeContent(renderableContent));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Replace string that is inline code with InlineCode
|
|
33
|
+
// Inline code is any text that backticks surround
|
|
34
|
+
function inlineCodeContent(renderableContent: RenderableContent): RenderableContent[] {
|
|
35
|
+
if (typeof renderableContent !== 'string') {
|
|
36
|
+
return [renderableContent];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function inlineCodeLink(text: string): InlineCode {
|
|
40
|
+
return {
|
|
41
|
+
__type: 'inline-code',
|
|
42
|
+
content: text,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const text = renderableContent;
|
|
47
|
+
|
|
48
|
+
// Matches any text surrounded by backticks
|
|
49
|
+
const codeFormatRegEx = '`([^`]*)`';
|
|
50
|
+
const matches = match(codeFormatRegEx, text);
|
|
51
|
+
return createRenderableContents(matches, text, inlineCodeLink);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function replaceInlineLinks(
|
|
55
|
+
getLinkByTypeName: ToInlineRenderableContent,
|
|
56
|
+
renderableContents: RenderableContent[],
|
|
57
|
+
): RenderableContent[] {
|
|
58
|
+
return renderableContents.flatMap((renderableContent) => inlineLinkContent(renderableContent, getLinkByTypeName));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function inlineLinkContent(
|
|
62
|
+
renderableContent: RenderableContent,
|
|
63
|
+
getLinkByTypeName: ToInlineRenderableContent,
|
|
64
|
+
): RenderableContent[] {
|
|
65
|
+
if (typeof renderableContent !== 'string') {
|
|
66
|
+
return [renderableContent];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const text = renderableContent;
|
|
70
|
+
|
|
71
|
+
// Matches either `<<ClassName>>` or `{@link ClassName}`
|
|
72
|
+
const linkFormatRegEx = '{@link (.*?)}|<<([^>]+)>>';
|
|
73
|
+
const matches = match(linkFormatRegEx, text);
|
|
74
|
+
return createRenderableContents(matches, text, getLinkByTypeName);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function replaceInlineEmails(
|
|
78
|
+
getLinkByTypeName: ToInlineRenderableContent,
|
|
79
|
+
renderableContents: RenderableContent[],
|
|
80
|
+
): RenderableContent[] {
|
|
81
|
+
return renderableContents.flatMap((renderableContent) => inlineEmailContent(renderableContent, getLinkByTypeName));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function inlineEmailContent(
|
|
85
|
+
renderableContent: RenderableContent,
|
|
86
|
+
getLinkByTypeName: ToInlineRenderableContent,
|
|
87
|
+
): RenderableContent[] {
|
|
88
|
+
if (typeof renderableContent !== 'string') {
|
|
89
|
+
return [renderableContent];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const text = renderableContent;
|
|
93
|
+
|
|
94
|
+
// Parsing references using the format '{@email email}'
|
|
95
|
+
const linkFormatRegEx = '{@email (.*?)}';
|
|
96
|
+
const matches = match(linkFormatRegEx, text);
|
|
97
|
+
return createRenderableContents(matches, text, getLinkByTypeName);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function match(regex: string, text: string) {
|
|
101
|
+
const expression = new RegExp(regex, 'gi');
|
|
102
|
+
let match;
|
|
103
|
+
const matches = [];
|
|
104
|
+
|
|
105
|
+
do {
|
|
106
|
+
match = expression.exec(text);
|
|
107
|
+
if (match) {
|
|
108
|
+
matches.push(match);
|
|
109
|
+
}
|
|
110
|
+
} while (match);
|
|
111
|
+
|
|
112
|
+
return matches;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function createRenderableContents(matches: RegExpExecArray[], text: string, linker: ToInlineRenderableContent) {
|
|
116
|
+
if (matches.length === 0) {
|
|
117
|
+
return [text];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const result: RenderableContent[] = [];
|
|
121
|
+
let lastIndex = 0;
|
|
122
|
+
for (const match of matches) {
|
|
123
|
+
const index = match.index;
|
|
124
|
+
const length = match[0].length;
|
|
125
|
+
|
|
126
|
+
// loop through the matches (skip the first one, which is the full match)
|
|
127
|
+
// until we find the first capturing group that has a value
|
|
128
|
+
const capturedGroup = match.slice(1).find((group) => group);
|
|
129
|
+
if (!capturedGroup) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
result.push(text.slice(lastIndex, index));
|
|
133
|
+
result.push(linker(capturedGroup));
|
|
134
|
+
|
|
135
|
+
lastIndex = index + length;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (lastIndex < text.length) {
|
|
139
|
+
result.push(text.slice(lastIndex));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return result;
|
|
143
|
+
}
|