@cparra/apexdocs 2.24.0 → 2.25.0-alpha.1
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/.github/workflows/close_stale.yml +22 -22
- package/.prettierrc.js +7 -7
- package/LICENSE +21 -21
- package/README.md +742 -718
- package/__mocks__/chalk.js +12 -0
- package/__mocks__/log-update.js +6 -0
- package/apexdocs.config.ts +13 -13
- package/docs/{README.md → __old/README.md} +1 -1
- package/docs/{restapi.json → __old/restapi.json} +589 -589
- package/docs/{types → __old/types}/Classes/nspc.ChildClass.md +97 -97
- package/docs/{types → __old/types}/Main/nspc.SampleClass.md +189 -189
- package/eslint.config.mjs +10 -0
- package/examples/force-app/main/default/classes/AnotherInterface.cls +16 -16
- package/examples/force-app/main/default/classes/ChildClass.cls +42 -42
- package/examples/force-app/main/default/classes/EscapedAnnotations.cls +5 -5
- package/examples/force-app/main/default/classes/GrandparentClass.cls +4 -4
- package/examples/force-app/main/default/classes/GroupedClass.cls +8 -8
- package/examples/force-app/main/default/classes/MemberGrouping.cls +17 -17
- package/examples/force-app/main/default/classes/ParentClass.cls +16 -16
- package/examples/force-app/main/default/classes/SampleClass.cls +166 -166
- package/examples/force-app/main/default/classes/SampleClass.cls-meta.xml +5 -5
- package/examples/force-app/main/default/classes/SampleClassWithoutModifier.cls +9 -9
- package/examples/force-app/main/default/classes/SampleInterface.cls +16 -16
- package/examples/force-app/main/default/restapi/SampleRestResource.cls +195 -195
- package/examples/force-app/main/default/restapi/SampleRestResourceToSkip.cls +35 -35
- package/examples/force-app/main/default/restapi/SampleRestResourceWithInnerClass.cls +24 -24
- package/examples/force-app/main/default/restapi/SampleRestResourceWithoutApexDocs.cls +15 -15
- package/examples/force-app/main/default/restapi/references/Reference1.cls +9 -9
- package/examples/force-app/main/default/restapi/references/Reference2.cls +9 -9
- package/examples/force-app/main/default/restapi/references/Reference3.cls +3 -3
- package/examples/force-app/main/default/restapi/references/Reference4.cls +3 -3
- package/examples/force-app/main/default/restapi/references/Reference5.cls +3 -3
- package/examples/force-app/main/default/restapi/references/Reference6.cls +6 -6
- package/examples/force-app/main/default/restapi/references/Reference7.cls +3 -3
- package/examples/includes/header.md +3 -3
- package/examples/plain-markdown/.forceignore +12 -0
- package/examples/plain-markdown/config/project-scratch-def.json +5 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.BaseClass.md +16 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.ParentInterface.md +15 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.ReferencedEnum.md +8 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleException.md +7 -0
- package/examples/plain-markdown/docs/Miscellaneous/ns.SampleInterface.md +115 -0
- package/examples/plain-markdown/docs/Sample-Enums/ns.SampleEnum.md +36 -0
- package/examples/plain-markdown/docs/SampleGroup/ns.SampleClass.md +173 -0
- package/examples/plain-markdown/docs/index.md +36 -0
- package/examples/plain-markdown/force-app/classes/BaseClass.cls +3 -0
- package/examples/plain-markdown/force-app/classes/ParentInterface.cls +3 -0
- package/examples/plain-markdown/force-app/classes/ReferencedEnum.cls +3 -0
- package/examples/plain-markdown/force-app/classes/SampleClass.cls +72 -0
- package/examples/plain-markdown/force-app/classes/SampleEnum.cls +30 -0
- package/examples/plain-markdown/force-app/classes/SampleException.cls +1 -0
- package/examples/plain-markdown/force-app/classes/SampleInterface.cls +46 -0
- package/examples/plain-markdown/package-lock.json +665 -0
- package/examples/plain-markdown/package.json +20 -0
- package/examples/plain-markdown/sfdx-project.json +12 -0
- package/examples/plain-markdown/template.md +3 -0
- package/jest.config.js +9 -5
- package/jest.d.ts +7 -0
- package/lib/__spec__/core/expect-extensions.d.ts +3 -0
- package/lib/__spec__/core/expect-extensions.js +54 -0
- package/lib/__spec__/core/expect-extensions.js.map +1 -0
- package/lib/__spec__/core/generating-class-docs.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-class-docs.spec.js +427 -0
- package/lib/__spec__/core/generating-class-docs.spec.js.map +1 -0
- package/lib/__spec__/core/generating-enum-docs.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-enum-docs.spec.js +303 -0
- package/lib/__spec__/core/generating-enum-docs.spec.js.map +1 -0
- package/lib/__spec__/core/generating-interface-docs.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-interface-docs.spec.js +361 -0
- package/lib/__spec__/core/generating-interface-docs.spec.js.map +1 -0
- package/lib/__spec__/core/generating-reference-guide.spec.d.ts +1 -0
- package/lib/__spec__/core/generating-reference-guide.spec.js +161 -0
- package/lib/__spec__/core/generating-reference-guide.spec.js.map +1 -0
- package/lib/adapters/apex-types.d.ts +7 -0
- package/lib/adapters/apex-types.js +112 -0
- package/lib/adapters/apex-types.js.map +1 -0
- package/lib/adapters/documentables.d.ts +7 -0
- package/lib/adapters/documentables.js +56 -0
- package/lib/adapters/documentables.js.map +1 -0
- package/lib/adapters/fields-and-properties.d.ts +4 -0
- package/lib/adapters/fields-and-properties.js +32 -0
- package/lib/adapters/fields-and-properties.js.map +1 -0
- package/lib/adapters/methods-and-constructors.d.ts +5 -0
- package/lib/adapters/methods-and-constructors.js +92 -0
- package/lib/adapters/methods-and-constructors.js.map +1 -0
- package/lib/adapters/references.d.ts +5 -0
- package/lib/adapters/references.js +82 -0
- package/lib/adapters/references.js.map +1 -0
- package/lib/adapters/type-utils.d.ts +2 -0
- package/lib/adapters/type-utils.js +7 -0
- package/lib/adapters/type-utils.js.map +1 -0
- package/lib/application/Apexdocs.d.ts +13 -13
- package/lib/application/Apexdocs.js +79 -76
- package/lib/application/Apexdocs.js.map +1 -1
- package/lib/cli/generate.d.ts +2 -2
- package/lib/cli/generate.js +156 -130
- package/lib/cli/generate.js.map +1 -1
- package/lib/core/generate-docs.d.ts +23 -0
- package/lib/core/generate-docs.js +241 -0
- package/lib/core/generate-docs.js.map +1 -0
- package/lib/core/template.d.ts +10 -0
- package/lib/core/template.js +92 -0
- package/lib/core/template.js.map +1 -0
- package/lib/core/templates/reference-guide.d.ts +1 -0
- package/lib/core/templates/reference-guide.js +18 -0
- package/lib/core/templates/reference-guide.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +28 -17
- package/lib/index.js.map +1 -1
- package/lib/model/apex-bundle.d.ts +6 -6
- package/lib/model/apex-bundle.js +10 -10
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.d.ts +7 -7
- package/lib/model/apex-type-wrappers/ClassMirrorWrapper.js +13 -13
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.d.ts +7 -7
- package/lib/model/apex-type-wrappers/MethodMirrorWrapper.js +11 -11
- package/lib/model/inheritance.d.ts +8 -8
- package/lib/model/inheritance.js +2 -2
- package/lib/model/manifest.d.ts +22 -22
- package/lib/model/manifest.js +52 -46
- package/lib/model/manifest.js.map +1 -1
- package/lib/model/markdown-file.d.ts +16 -16
- package/lib/model/markdown-file.js +110 -106
- package/lib/model/markdown-file.js.map +1 -1
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.d.ts +8 -8
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js +45 -43
- package/lib/model/markdown-generation-util/doc-comment-annotation-util.js.map +1 -1
- package/lib/model/markdown-generation-util/field-declaration-util.d.ts +3 -3
- package/lib/model/markdown-generation-util/field-declaration-util.js +53 -54
- package/lib/model/markdown-generation-util/field-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/index.d.ts +3 -3
- package/lib/model/markdown-generation-util/index.js +19 -19
- package/lib/model/markdown-generation-util/method-declaration-util.d.ts +4 -4
- package/lib/model/markdown-generation-util/method-declaration-util.js +113 -114
- package/lib/model/markdown-generation-util/method-declaration-util.js.map +1 -1
- package/lib/model/markdown-generation-util/type-declaration-util.d.ts +3 -3
- package/lib/model/markdown-generation-util/type-declaration-util.js +80 -81
- package/lib/model/markdown-generation-util/type-declaration-util.js.map +1 -1
- package/lib/model/markdown-home-file.d.ts +11 -11
- package/lib/model/markdown-home-file.js +56 -53
- package/lib/model/markdown-home-file.js.map +1 -1
- package/lib/model/markdown-type-file.d.ts +26 -26
- package/lib/model/markdown-type-file.js +136 -133
- package/lib/model/markdown-type-file.js.map +1 -1
- package/lib/model/openapi/apex-doc-types.d.ts +19 -19
- package/lib/model/openapi/apex-doc-types.js +4 -4
- package/lib/model/openapi/open-api-types.d.ts +93 -93
- package/lib/model/openapi/open-api-types.js +2 -2
- package/lib/model/openapi/open-api.d.ts +16 -16
- package/lib/model/openapi/open-api.js +33 -33
- package/lib/model/openapi/open-api.js.map +1 -1
- package/lib/model/openapi/openapi-type-file.d.ts +7 -7
- package/lib/model/openapi/openapi-type-file.js +16 -16
- package/lib/model/outputFile.d.ts +10 -10
- package/lib/model/outputFile.js +21 -28
- package/lib/model/outputFile.js.map +1 -1
- package/lib/model/types-repository.d.ts +16 -16
- package/lib/model/types-repository.js +53 -53
- package/lib/model/types-repository.js.map +1 -1
- package/lib/service/apex-file-reader.d.ts +14 -14
- package/lib/service/apex-file-reader.js +48 -45
- package/lib/service/apex-file-reader.js.map +1 -1
- package/lib/service/file-system.d.ts +14 -14
- package/lib/service/file-system.js +47 -24
- package/lib/service/file-system.js.map +1 -1
- package/lib/service/file-writer.d.ts +6 -6
- package/lib/service/file-writer.js +56 -33
- package/lib/service/file-writer.js.map +1 -1
- package/lib/service/manifest-factory.d.ts +10 -10
- package/lib/service/manifest-factory.js +15 -13
- package/lib/service/manifest-factory.js.map +1 -1
- package/lib/service/metadata-processor.d.ts +3 -3
- package/lib/service/metadata-processor.js +16 -16
- package/lib/service/metadata-processor.js.map +1 -1
- package/lib/service/parser.d.ts +21 -21
- package/lib/service/parser.js +137 -134
- package/lib/service/parser.js.map +1 -1
- package/lib/service/state.d.ts +9 -9
- package/lib/service/state.js +19 -19
- package/lib/service/state.js.map +1 -1
- package/lib/service/walkers/class-walker.d.ts +4 -4
- package/lib/service/walkers/class-walker.js +32 -32
- package/lib/service/walkers/class-walker.js.map +1 -1
- package/lib/service/walkers/enum-walker.d.ts +4 -4
- package/lib/service/walkers/enum-walker.js +10 -10
- package/lib/service/walkers/interface-walker.d.ts +4 -4
- package/lib/service/walkers/interface-walker.js +14 -14
- package/lib/service/walkers/interface-walker.js.map +1 -1
- package/lib/service/walkers/walker-factory.d.ts +5 -5
- package/lib/service/walkers/walker-factory.js +20 -20
- package/lib/service/walkers/walker-factory.js.map +1 -1
- package/lib/service/walkers/walker.d.ts +19 -19
- package/lib/service/walkers/walker.js +16 -16
- package/lib/service/walkers/walker.js.map +1 -1
- package/lib/settings.d.ts +64 -64
- package/lib/settings.js +88 -88
- package/lib/settings.js.map +1 -1
- package/lib/test-helpers/AnnotationBuilder.d.ts +12 -12
- package/lib/test-helpers/AnnotationBuilder.js +30 -30
- package/lib/test-helpers/ClassMirrorBuilder.d.ts +18 -18
- package/lib/test-helpers/ClassMirrorBuilder.js +53 -53
- package/lib/test-helpers/DocCommentAnnotationBuilder.d.ts +8 -8
- package/lib/test-helpers/DocCommentAnnotationBuilder.js +25 -25
- package/lib/test-helpers/DocCommentBuilder.d.ts +12 -12
- package/lib/test-helpers/DocCommentBuilder.js +37 -37
- package/lib/test-helpers/FieldMirrorBuilder.d.ts +18 -18
- package/lib/test-helpers/FieldMirrorBuilder.js +53 -53
- package/lib/test-helpers/InterfaceMirrorBuilder.d.ts +16 -0
- package/lib/test-helpers/InterfaceMirrorBuilder.js +43 -0
- package/lib/test-helpers/InterfaceMirrorBuilder.js.map +1 -0
- package/lib/test-helpers/MethodMirrorBuilder.d.ts +29 -10
- package/lib/test-helpers/MethodMirrorBuilder.js +71 -36
- package/lib/test-helpers/MethodMirrorBuilder.js.map +1 -1
- package/lib/test-helpers/SettingsBuilder.d.ts +8 -8
- package/lib/test-helpers/SettingsBuilder.js +26 -26
- package/lib/transpiler/factory.d.ts +6 -6
- package/lib/transpiler/factory.js +34 -31
- package/lib/transpiler/factory.js.map +1 -1
- package/lib/transpiler/file-container.d.ts +6 -6
- package/lib/transpiler/file-container.js +15 -15
- package/lib/transpiler/generator-choices.d.ts +1 -1
- package/lib/transpiler/generator-choices.js +2 -2
- package/lib/transpiler/markdown/class-file-generatorHelper.d.ts +11 -8
- package/lib/transpiler/markdown/class-file-generatorHelper.js +74 -55
- package/lib/transpiler/markdown/class-file-generatorHelper.js.map +1 -1
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.d.ts +6 -6
- package/lib/transpiler/markdown/docsify/docsify-docs-processor.js +12 -12
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.d.ts +11 -11
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js +50 -50
- package/lib/transpiler/markdown/jekyll/jekyll-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/markdown-transpiler-base.d.ts +11 -11
- package/lib/transpiler/markdown/markdown-transpiler-base.js +26 -23
- package/lib/transpiler/markdown/markdown-transpiler-base.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/class-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/class-template.js +77 -0
- package/lib/transpiler/markdown/plain-markdown/class-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js +36 -0
- package/lib/transpiler/markdown/plain-markdown/constructors-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js +28 -0
- package/lib/transpiler/markdown/plain-markdown/documentable-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/enum-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/enum-template.js +16 -0
- package/lib/transpiler/markdown/plain-markdown/enum-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js +27 -0
- package/lib/transpiler/markdown/plain-markdown/fieldsPartialTemplate.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.js +10 -0
- package/lib/transpiler/markdown/plain-markdown/grouped-members-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.js +20 -0
- package/lib/transpiler/markdown/plain-markdown/interface-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js +47 -0
- package/lib/transpiler/markdown/plain-markdown/methods-partial-template.js.map +1 -0
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.d.ts +9 -6
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js +41 -13
- package/lib/transpiler/markdown/plain-markdown/plain-docsProcessor.js.map +1 -1
- package/lib/transpiler/markdown/plain-markdown/type-doc-partial.d.ts +1 -0
- package/lib/transpiler/markdown/plain-markdown/type-doc-partial.js +31 -0
- package/lib/transpiler/markdown/plain-markdown/type-doc-partial.js.map +1 -0
- package/lib/transpiler/openapi/open-api-docs-processor.d.ts +13 -13
- package/lib/transpiler/openapi/open-api-docs-processor.js +77 -74
- package/lib/transpiler/openapi/open-api-docs-processor.js.map +1 -1
- package/lib/transpiler/openapi/parsers/Builder.d.ts +16 -16
- package/lib/transpiler/openapi/parsers/Builder.js +29 -29
- package/lib/transpiler/openapi/parsers/Builder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/MethodParser.d.ts +20 -20
- package/lib/transpiler/openapi/parsers/MethodParser.js +189 -166
- package/lib/transpiler/openapi/parsers/MethodParser.js.map +1 -1
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.d.ts +7 -7
- package/lib/transpiler/openapi/parsers/ParameterObjectBuilder.js +10 -10
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.d.ts +39 -39
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js +249 -225
- package/lib/transpiler/openapi/parsers/ReferenceBuilder.js.map +1 -1
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.d.ts +10 -10
- package/lib/transpiler/openapi/parsers/RequestBodyBuilder.js +19 -19
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.d.ts +7 -7
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js +21 -21
- package/lib/transpiler/openapi/parsers/ResponsesBuilder.js.map +1 -1
- package/lib/transpiler/processor-type-transpiler.d.ts +10 -10
- package/lib/transpiler/processor-type-transpiler.js +8 -8
- package/lib/transpiler/transpiler.d.ts +5 -5
- package/lib/transpiler/transpiler.js +29 -26
- package/lib/transpiler/transpiler.js.map +1 -1
- package/lib/util/error-logger.d.ts +8 -8
- package/lib/util/error-logger.js +89 -89
- package/lib/util/error-logger.js.map +1 -1
- package/lib/util/logger.d.ts +21 -21
- package/lib/util/logger.js +60 -57
- package/lib/util/logger.js.map +1 -1
- package/lib/util/string-utils.d.ts +2 -2
- package/lib/util/string-utils.js +14 -14
- package/lib/util/string-utils.js.map +1 -1
- package/package.json +79 -78
- package/src/__spec__/core/expect-extensions.ts +32 -0
- package/src/__spec__/core/generating-class-docs.spec.ts +511 -0
- package/src/__spec__/core/generating-enum-docs.spec.ts +355 -0
- package/src/__spec__/core/generating-interface-docs.spec.ts +431 -0
- package/src/__spec__/core/generating-reference-guide.spec.ts +163 -0
- package/src/adapters/__tests__/interface-adapter.spec.ts +80 -0
- package/src/adapters/__tests__/references.spec.ts +115 -0
- package/src/adapters/apex-types.ts +224 -0
- package/src/adapters/documentables.ts +93 -0
- package/src/adapters/fields-and-properties.ts +38 -0
- package/src/adapters/methods-and-constructors.ts +117 -0
- package/src/adapters/references.ts +113 -0
- package/src/adapters/type-utils.ts +5 -0
- package/src/adapters/types.d.ts +8 -0
- package/src/cli/generate.ts +96 -93
- package/src/core/generate-docs.ts +357 -0
- package/src/core/renderable/types.d.ts +131 -0
- package/src/core/template.ts +108 -0
- package/src/core/templates/reference-guide.ts +14 -0
- package/src/index.ts +3 -1
- package/src/model/__tests__/manifest.spec.ts +1 -0
- package/src/model/manifest.ts +15 -5
- package/src/model/markdown-file.ts +6 -5
- package/src/model/markdown-generation-util/doc-comment-annotation-util.ts +1 -1
- package/src/model/markdown-generation-util/method-declaration-util.ts +1 -1
- package/src/model/openapi/open-api-types.ts +2 -2
- package/src/model/outputFile.ts +2 -11
- package/src/service/__tests__/apex-file-reader.spec.ts +4 -4
- package/src/service/__tests__/manifest-factory.spec.ts +1 -2
- package/src/service/parser.ts +1 -1
- package/src/test-helpers/FieldMirrorBuilder.ts +1 -1
- package/src/test-helpers/InterfaceMirrorBuilder.ts +44 -0
- package/src/test-helpers/MethodMirrorBuilder.ts +46 -6
- package/src/transpiler/markdown/class-file-generatorHelper.ts +22 -2
- package/src/transpiler/markdown/plain-markdown/class-template.ts +73 -0
- package/src/transpiler/markdown/plain-markdown/constructors-partial-template.ts +32 -0
- package/src/transpiler/markdown/plain-markdown/documentable-partial-template.ts +24 -0
- package/src/transpiler/markdown/plain-markdown/enum-template.ts +12 -0
- package/src/transpiler/markdown/plain-markdown/fieldsPartialTemplate.ts +23 -0
- package/src/transpiler/markdown/plain-markdown/grouped-members-partial-template.ts +6 -0
- package/src/transpiler/markdown/plain-markdown/interface-template.ts +16 -0
- package/src/transpiler/markdown/plain-markdown/methods-partial-template.ts +43 -0
- package/src/transpiler/markdown/plain-markdown/plain-docsProcessor.ts +30 -0
- package/src/transpiler/markdown/plain-markdown/type-doc-partial.ts +27 -0
- package/src/transpiler/openapi/parsers/Builder.ts +1 -1
- package/src/transpiler/openapi/parsers/MethodParser.ts +1 -1
- package/src/transpiler/openapi/parsers/ReferenceBuilder.ts +4 -3
- package/src/util/error-logger.ts +4 -4
- package/src/util/logger.ts +3 -3
- package/tsconfig.json +21 -20
- package/tslint.json +5 -5
- package/.eslintrc.js +0 -12
- package/lib/model/manifest-diff.d.ts +0 -27
- package/lib/model/manifest-diff.js +0 -69
- package/lib/model/manifest-diff.js.map +0 -1
- package/src/model/__tests__/manifest-diff.spec.ts +0 -139
- package/src/model/manifest-diff.ts +0 -94
- /package/docs/{index.html → __old/index.html} +0 -0
- /package/docs/{types → __old/types}/Classes/nspc.AnotherInterface.md +0 -0
- /package/docs/{types → __old/types}/Main/nspc.GroupedClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.EscapedAnnotations.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.GrandparentClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.InterfaceWithInheritance.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.MemberGrouping.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.ParentClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference1.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference2.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference3.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference4.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference5.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference6.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.Reference7.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleClassWithoutModifier.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleRestResource.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleRestResourceWithInnerClass.md +0 -0
- /package/docs/{types → __old/types}/Misc-Group/nspc.SampleRestResourceWithoutApexDocs.md +0 -0
- /package/docs/{types → __old/types}/README.md +0 -0
- /package/docs/{types → __old/types}/Sample-Interfaces/nspc.SampleInterface.md +0 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { replaceInlineReferences } from '../references';
|
|
2
|
+
import { Link } from '../../core/renderable/types';
|
|
3
|
+
|
|
4
|
+
function getFileLink(typeName: string): Link {
|
|
5
|
+
return {
|
|
6
|
+
title: typeName,
|
|
7
|
+
url: `/api/${typeName}.html`,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getEmailLink(typeName: string) {
|
|
12
|
+
return {
|
|
13
|
+
title: typeName,
|
|
14
|
+
url: `mailto:${typeName}`,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
describe('reference utilities', () => {
|
|
19
|
+
it('returns a RenderableContent array with the full string when there are no links', () => {
|
|
20
|
+
const text = 'This is a test';
|
|
21
|
+
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
22
|
+
|
|
23
|
+
const expected = ['This is a test'];
|
|
24
|
+
|
|
25
|
+
expect(result).toEqual(expected);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('replace inline links', () => {
|
|
29
|
+
it('replaces links in the format of <<ClassName>>', () => {
|
|
30
|
+
const text = 'This is a test <<ClassName>>.';
|
|
31
|
+
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
32
|
+
|
|
33
|
+
const expected = [
|
|
34
|
+
'This is a test ',
|
|
35
|
+
{
|
|
36
|
+
title: 'ClassName',
|
|
37
|
+
url: '/api/ClassName.html',
|
|
38
|
+
},
|
|
39
|
+
'.',
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
expect(result).toEqual(expected);
|
|
43
|
+
});
|
|
44
|
+
it('replaces links in the format of {@link ClassName}', () => {
|
|
45
|
+
function getFileLinkByTypeName(typeName: string): Link {
|
|
46
|
+
return {
|
|
47
|
+
title: typeName,
|
|
48
|
+
url: `/api/${typeName}.html`,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const text = 'This is a test {@link ClassName}';
|
|
53
|
+
const result = replaceInlineReferences(text, getFileLinkByTypeName, getEmailLink);
|
|
54
|
+
|
|
55
|
+
const expected = [
|
|
56
|
+
'This is a test ',
|
|
57
|
+
{
|
|
58
|
+
title: 'ClassName',
|
|
59
|
+
url: '/api/ClassName.html',
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
expect(result).toEqual(expected);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe('replace inline emails', () => {
|
|
68
|
+
it('replaces emails in the format of {@email email-address}', () => {
|
|
69
|
+
function getLinkByTypeName(typeName: string) {
|
|
70
|
+
return {
|
|
71
|
+
title: typeName,
|
|
72
|
+
url: `mailto:${typeName}`,
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const text = 'This is an email {@email example@example.com}';
|
|
77
|
+
const result = replaceInlineReferences(text, getFileLink, getLinkByTypeName);
|
|
78
|
+
|
|
79
|
+
const expected = [
|
|
80
|
+
'This is an email ',
|
|
81
|
+
{
|
|
82
|
+
title: 'example@example.com',
|
|
83
|
+
url: 'mailto:example@example.com',
|
|
84
|
+
},
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
expect(result).toEqual(expected);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('replaces both links and emails in the same string', () => {
|
|
92
|
+
const text = 'This is a test <<ClassName>>, and {@link AnotherClass}, and an email {@email testerson}';
|
|
93
|
+
const result = replaceInlineReferences(text, getFileLink, getEmailLink);
|
|
94
|
+
|
|
95
|
+
const expected = [
|
|
96
|
+
'This is a test ',
|
|
97
|
+
{
|
|
98
|
+
title: 'ClassName',
|
|
99
|
+
url: '/api/ClassName.html',
|
|
100
|
+
},
|
|
101
|
+
', and ',
|
|
102
|
+
{
|
|
103
|
+
title: 'AnotherClass',
|
|
104
|
+
url: '/api/AnotherClass.html',
|
|
105
|
+
},
|
|
106
|
+
', and an email ',
|
|
107
|
+
{
|
|
108
|
+
title: 'testerson',
|
|
109
|
+
url: 'mailto:testerson',
|
|
110
|
+
},
|
|
111
|
+
];
|
|
112
|
+
|
|
113
|
+
expect(result).toEqual(expected);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { ClassMirror, EnumMirror, InterfaceMirror, Type } from '@cparra/apex-reflection';
|
|
2
|
+
import {
|
|
3
|
+
RenderableType,
|
|
4
|
+
RenderableClass,
|
|
5
|
+
RenderableEnum,
|
|
6
|
+
RenderableInterface,
|
|
7
|
+
Renderable,
|
|
8
|
+
RenderableSection,
|
|
9
|
+
GroupedMember,
|
|
10
|
+
} from '../core/renderable/types';
|
|
11
|
+
import { adaptDescribable, adaptDocumentable } from './documentables';
|
|
12
|
+
import { GetRenderableContentByTypeName, linkFromTypeNameGenerator } from './references';
|
|
13
|
+
import { FieldMirrorWithInheritance, PropertyMirrorWithInheritance } from '../model/inheritance';
|
|
14
|
+
import { adaptConstructor, adaptMethod } from './methods-and-constructors';
|
|
15
|
+
import { adaptFieldOrProperty } from './fields-and-properties';
|
|
16
|
+
|
|
17
|
+
function baseTypeAdapter(
|
|
18
|
+
type: EnumMirror | InterfaceMirror | ClassMirror,
|
|
19
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
20
|
+
baseHeadingLevel: number,
|
|
21
|
+
): RenderableType {
|
|
22
|
+
function getHeading(type: Type): string {
|
|
23
|
+
const suffixMap = {
|
|
24
|
+
class: 'Class',
|
|
25
|
+
interface: 'Interface',
|
|
26
|
+
enum: 'Enum',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return `${type.name} ${suffixMap[type.type_name]}`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return {
|
|
33
|
+
headingLevel: baseHeadingLevel,
|
|
34
|
+
heading: getHeading(type),
|
|
35
|
+
doc: adaptDocumentable(type, linkGenerator, baseHeadingLevel + 1),
|
|
36
|
+
name: type.name,
|
|
37
|
+
meta: {
|
|
38
|
+
accessModifier: type.access_modifier,
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function typeToRenderableType(
|
|
44
|
+
type: Type,
|
|
45
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
46
|
+
namespace?: string,
|
|
47
|
+
): Renderable {
|
|
48
|
+
function getRenderable() {
|
|
49
|
+
switch (type.type_name) {
|
|
50
|
+
case 'enum':
|
|
51
|
+
return enumTypeToEnumSource(type as EnumMirror, linkGenerator);
|
|
52
|
+
case 'interface':
|
|
53
|
+
return interfaceTypeToInterfaceSource(type as InterfaceMirror, linkGenerator);
|
|
54
|
+
case 'class':
|
|
55
|
+
return classTypeToClassSource(type as ClassMirror, linkGenerator);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
...getRenderable(),
|
|
61
|
+
namespace,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function enumTypeToEnumSource(
|
|
66
|
+
enumType: EnumMirror,
|
|
67
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
68
|
+
baseHeadingLevel: number = 1,
|
|
69
|
+
): RenderableEnum {
|
|
70
|
+
return {
|
|
71
|
+
type: 'enum',
|
|
72
|
+
...baseTypeAdapter(enumType, linkGenerator, baseHeadingLevel),
|
|
73
|
+
values: {
|
|
74
|
+
headingLevel: baseHeadingLevel + 1,
|
|
75
|
+
heading: 'Values',
|
|
76
|
+
value: enumType.values.map((value) => ({
|
|
77
|
+
...adaptDescribable(value.docComment?.descriptionLines, linkGenerator),
|
|
78
|
+
value: value.name,
|
|
79
|
+
})),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function interfaceTypeToInterfaceSource(
|
|
85
|
+
interfaceType: InterfaceMirror,
|
|
86
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
87
|
+
baseHeadingLevel: number = 1,
|
|
88
|
+
): RenderableInterface {
|
|
89
|
+
return {
|
|
90
|
+
type: 'interface',
|
|
91
|
+
...baseTypeAdapter(interfaceType, linkGenerator, baseHeadingLevel),
|
|
92
|
+
extends: interfaceType.extended_interfaces.map(linkFromTypeNameGenerator),
|
|
93
|
+
methods: {
|
|
94
|
+
headingLevel: baseHeadingLevel + 1,
|
|
95
|
+
heading: 'Methods',
|
|
96
|
+
value: interfaceType.methods.map((method) => adaptMethod(method, linkGenerator, baseHeadingLevel + 2)),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function classTypeToClassSource(
|
|
102
|
+
classType: ClassMirror,
|
|
103
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
104
|
+
baseHeadingLevel: number = 1,
|
|
105
|
+
): RenderableClass {
|
|
106
|
+
return {
|
|
107
|
+
type: 'class',
|
|
108
|
+
...baseTypeAdapter(classType, linkGenerator, baseHeadingLevel),
|
|
109
|
+
classModifier: classType.classModifier,
|
|
110
|
+
sharingModifier: classType.sharingModifier,
|
|
111
|
+
implements: classType.implemented_interfaces.map(linkFromTypeNameGenerator),
|
|
112
|
+
extends: classType.extended_class ? linkFromTypeNameGenerator(classType.extended_class) : undefined,
|
|
113
|
+
methods: adaptMembers('Methods', classType.methods, adaptMethod, linkFromTypeNameGenerator, baseHeadingLevel + 1),
|
|
114
|
+
constructors: adaptMembers(
|
|
115
|
+
'Constructors',
|
|
116
|
+
classType.constructors,
|
|
117
|
+
(constructor, linkGenerator, baseHeadingLevel) =>
|
|
118
|
+
adaptConstructor(classType.name, constructor, linkGenerator, baseHeadingLevel),
|
|
119
|
+
linkFromTypeNameGenerator,
|
|
120
|
+
baseHeadingLevel + 1,
|
|
121
|
+
),
|
|
122
|
+
fields: adaptMembers(
|
|
123
|
+
'Fields',
|
|
124
|
+
classType.fields as FieldMirrorWithInheritance[],
|
|
125
|
+
adaptFieldOrProperty,
|
|
126
|
+
linkFromTypeNameGenerator,
|
|
127
|
+
baseHeadingLevel + 1,
|
|
128
|
+
),
|
|
129
|
+
properties: adaptMembers(
|
|
130
|
+
'Properties',
|
|
131
|
+
classType.properties as PropertyMirrorWithInheritance[],
|
|
132
|
+
adaptFieldOrProperty,
|
|
133
|
+
linkFromTypeNameGenerator,
|
|
134
|
+
baseHeadingLevel + 1,
|
|
135
|
+
),
|
|
136
|
+
innerClasses: {
|
|
137
|
+
headingLevel: baseHeadingLevel + 1,
|
|
138
|
+
heading: 'Classes',
|
|
139
|
+
value: classType.classes.map((innerClass) =>
|
|
140
|
+
classTypeToClassSource(innerClass, linkGenerator, baseHeadingLevel + 2),
|
|
141
|
+
),
|
|
142
|
+
},
|
|
143
|
+
innerEnums: {
|
|
144
|
+
headingLevel: baseHeadingLevel + 1,
|
|
145
|
+
heading: 'Enums',
|
|
146
|
+
value: classType.enums.map((innerEnum) => enumTypeToEnumSource(innerEnum, linkGenerator, baseHeadingLevel + 2)),
|
|
147
|
+
},
|
|
148
|
+
innerInterfaces: {
|
|
149
|
+
headingLevel: baseHeadingLevel + 1,
|
|
150
|
+
heading: 'Interfaces',
|
|
151
|
+
value: classType.interfaces.map((innerInterface) =>
|
|
152
|
+
interfaceTypeToInterfaceSource(innerInterface, linkGenerator, baseHeadingLevel + 2),
|
|
153
|
+
),
|
|
154
|
+
},
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
type Groupable = { group?: string; groupDescription?: string };
|
|
159
|
+
|
|
160
|
+
function adaptMembers<T extends Groupable, K>(
|
|
161
|
+
heading: string,
|
|
162
|
+
members: T[],
|
|
163
|
+
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
164
|
+
linkFromTypeNameGenerator: GetRenderableContentByTypeName,
|
|
165
|
+
headingLevel: number,
|
|
166
|
+
): RenderableSection<K[] | GroupedMember<K>[]> & { isGrouped: boolean } {
|
|
167
|
+
return {
|
|
168
|
+
headingLevel,
|
|
169
|
+
heading,
|
|
170
|
+
isGrouped: hasGroup(members),
|
|
171
|
+
value: hasGroup(members)
|
|
172
|
+
? toGroupedMembers(members, adapter, linkFromTypeNameGenerator, headingLevel + 1)
|
|
173
|
+
: toFlat(members, adapter, linkFromTypeNameGenerator, headingLevel + 1),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function hasGroup(members: Groupable[]): boolean {
|
|
178
|
+
return members.some((member) => member.group);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function toFlat<T extends Groupable, K>(
|
|
182
|
+
members: T[],
|
|
183
|
+
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
184
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
185
|
+
baseHeadingLevel: number,
|
|
186
|
+
): K[] {
|
|
187
|
+
return members.map((member) => adapter(member, linkGenerator, baseHeadingLevel));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function toGroupedMembers<T extends Groupable, K>(
|
|
191
|
+
members: T[],
|
|
192
|
+
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
193
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
194
|
+
baseHeadingLevel: number,
|
|
195
|
+
): GroupedMember<K>[] {
|
|
196
|
+
const groupedMembers = groupByGroupName(members);
|
|
197
|
+
return Object.entries(groupedMembers).map(([groupName, members]) =>
|
|
198
|
+
singleGroup(baseHeadingLevel, groupName, adapter, members, linkGenerator),
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function groupByGroupName<T extends Groupable>(members: T[]): Record<string, T[]> {
|
|
203
|
+
return members.reduce((acc, member) => {
|
|
204
|
+
const groupName = member.group ?? 'Other';
|
|
205
|
+
acc[groupName] = acc[groupName] ?? [];
|
|
206
|
+
acc[groupName].push(member);
|
|
207
|
+
return acc;
|
|
208
|
+
}, {} as Record<string, T[]>);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function singleGroup<T extends Groupable, K>(
|
|
212
|
+
headingLevel: number,
|
|
213
|
+
groupName: string,
|
|
214
|
+
adapter: (member: T, linkGenerator: GetRenderableContentByTypeName, baseHeadingLevel: number) => K,
|
|
215
|
+
members: T[],
|
|
216
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
217
|
+
): GroupedMember<K> {
|
|
218
|
+
return {
|
|
219
|
+
headingLevel: headingLevel,
|
|
220
|
+
heading: groupName,
|
|
221
|
+
groupDescription: members[0].groupDescription, // All fields in the group have the same description
|
|
222
|
+
value: toFlat(members, adapter, linkGenerator, headingLevel + 1),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { CustomTag, RenderableDocumentation, RenderableContent } from '../core/renderable/types';
|
|
2
|
+
import { Describable, Documentable } from './types';
|
|
3
|
+
import { GetRenderableContentByTypeName, replaceInlineReferences } from './references';
|
|
4
|
+
import { isEmptyLine } from './type-utils';
|
|
5
|
+
|
|
6
|
+
export function adaptDescribable(
|
|
7
|
+
describable: Describable,
|
|
8
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
9
|
+
): {
|
|
10
|
+
description?: RenderableContent[];
|
|
11
|
+
} {
|
|
12
|
+
function describableToRenderableContent(describable: Describable): RenderableContent[] | undefined {
|
|
13
|
+
if (!describable) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
describable
|
|
19
|
+
.map<RenderableContent[]>((line) => [
|
|
20
|
+
...replaceInlineReferences(line, linkGenerator),
|
|
21
|
+
{
|
|
22
|
+
type: 'empty-line',
|
|
23
|
+
},
|
|
24
|
+
])
|
|
25
|
+
.flatMap((line) => line)
|
|
26
|
+
// If the last element is an empty line, remove it
|
|
27
|
+
.filter((line, index, lines) => !(isEmptyLine(line) && index === lines.length - 1))
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
description: describableToRenderableContent(describable),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function adaptDocumentable(
|
|
37
|
+
documentable: Documentable,
|
|
38
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
39
|
+
subHeadingLevel: number,
|
|
40
|
+
): RenderableDocumentation {
|
|
41
|
+
function extractCustomTags(type: Documentable): CustomTag[] {
|
|
42
|
+
const baseTags = ['description', 'group', 'author', 'date', 'see', 'example', 'mermaid', 'throws', 'exception'];
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
type.docComment?.annotations
|
|
46
|
+
.filter((currentAnnotation) => !baseTags.includes(currentAnnotation.name.toLowerCase()))
|
|
47
|
+
.map<CustomTag>((currentAnnotation) => ({
|
|
48
|
+
...adaptDescribable(currentAnnotation.bodyLines, linkGenerator),
|
|
49
|
+
name: currentAnnotation.name,
|
|
50
|
+
})) ?? []
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function extractAnnotationBodyLines(type: Documentable, annotationName: string): string[] | undefined {
|
|
55
|
+
return type.docComment?.annotations.find(
|
|
56
|
+
(currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName,
|
|
57
|
+
)?.bodyLines;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function extractAnnotationBody(type: Documentable, annotationName: string): string | undefined {
|
|
61
|
+
return type.docComment?.annotations.find(
|
|
62
|
+
(currentAnnotation) => currentAnnotation.name.toLowerCase() === annotationName,
|
|
63
|
+
)?.body;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function extractSeeAnnotations(type: Documentable): string[] {
|
|
67
|
+
return (
|
|
68
|
+
type.docComment?.annotations
|
|
69
|
+
.filter((currentAnnotation) => currentAnnotation.name.toLowerCase() === 'see')
|
|
70
|
+
.map((currentAnnotation) => currentAnnotation.body) ?? []
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
...adaptDescribable(documentable.docComment?.descriptionLines, linkGenerator),
|
|
76
|
+
annotations: documentable.annotations.map((annotation) => annotation.type.toUpperCase()),
|
|
77
|
+
customTags: extractCustomTags(documentable),
|
|
78
|
+
mermaid: {
|
|
79
|
+
headingLevel: subHeadingLevel,
|
|
80
|
+
heading: 'Diagram',
|
|
81
|
+
value: extractAnnotationBodyLines(documentable, 'mermaid'),
|
|
82
|
+
},
|
|
83
|
+
example: {
|
|
84
|
+
headingLevel: subHeadingLevel,
|
|
85
|
+
heading: 'Example',
|
|
86
|
+
value: documentable.docComment?.exampleAnnotation?.bodyLines,
|
|
87
|
+
},
|
|
88
|
+
group: extractAnnotationBody(documentable, 'group'),
|
|
89
|
+
author: extractAnnotationBody(documentable, 'author'),
|
|
90
|
+
date: extractAnnotationBody(documentable, 'date'),
|
|
91
|
+
sees: extractSeeAnnotations(documentable).map(linkGenerator),
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { FieldMirrorWithInheritance, PropertyMirrorWithInheritance } from '../model/inheritance';
|
|
2
|
+
import { RenderableField } from '../core/renderable/types';
|
|
3
|
+
import { adaptDocumentable } from './documentables';
|
|
4
|
+
import { GetRenderableContentByTypeName, linkFromTypeNameGenerator } from './references';
|
|
5
|
+
|
|
6
|
+
export function adaptFieldOrProperty(
|
|
7
|
+
field: FieldMirrorWithInheritance | PropertyMirrorWithInheritance,
|
|
8
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
9
|
+
baseHeadingLevel: number,
|
|
10
|
+
): RenderableField {
|
|
11
|
+
function buildSignature() {
|
|
12
|
+
const { access_modifier, name } = field;
|
|
13
|
+
const memberModifiers = field.memberModifiers.join(' ');
|
|
14
|
+
return (
|
|
15
|
+
`${access_modifier} ${memberModifiers} ${name}`
|
|
16
|
+
// remove double spaces
|
|
17
|
+
.replace(/ {2}/g, ' ')
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
headingLevel: baseHeadingLevel,
|
|
23
|
+
doc: adaptDocumentable(field, linkGenerator, baseHeadingLevel + 1),
|
|
24
|
+
heading: field.name,
|
|
25
|
+
type: {
|
|
26
|
+
headingLevel: baseHeadingLevel + 1,
|
|
27
|
+
heading: 'Type',
|
|
28
|
+
value: linkFromTypeNameGenerator(field.typeReference.rawDeclaration),
|
|
29
|
+
},
|
|
30
|
+
inherited: field.inherited,
|
|
31
|
+
accessModifier: field.access_modifier,
|
|
32
|
+
signature: {
|
|
33
|
+
headingLevel: baseHeadingLevel + 1,
|
|
34
|
+
heading: 'Signature',
|
|
35
|
+
value: [buildSignature()],
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { ConstructorMirror, MethodMirror, ParameterMirror, ThrowsAnnotation } from '@cparra/apex-reflection';
|
|
2
|
+
import { RenderableConstructor, RenderableMethod } from '../core/renderable/types';
|
|
3
|
+
import { MethodMirrorWithInheritance } from '../model/inheritance';
|
|
4
|
+
import { adaptDescribable, adaptDocumentable } from './documentables';
|
|
5
|
+
import { GetRenderableContentByTypeName, linkFromTypeNameGenerator } from './references';
|
|
6
|
+
import { Documentable } from './types';
|
|
7
|
+
|
|
8
|
+
export function adaptMethod(
|
|
9
|
+
method: MethodMirror,
|
|
10
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
11
|
+
baseHeadingLevel: number,
|
|
12
|
+
): RenderableMethod {
|
|
13
|
+
function buildTitle(method: MethodMirrorWithInheritance): string {
|
|
14
|
+
const { name, parameters } = method;
|
|
15
|
+
const parametersString = parameters.map((param) => param.name).join(', ');
|
|
16
|
+
return `${name}(${parametersString})`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function buildSignature(method: MethodMirrorWithInheritance): string {
|
|
20
|
+
const { access_modifier, typeReference, name, memberModifiers } = method;
|
|
21
|
+
const parameters = method.parameters
|
|
22
|
+
.map((param) => `${param.typeReference.rawDeclaration} ${param.name}`)
|
|
23
|
+
.join(', ');
|
|
24
|
+
const members = memberModifiers.length > 0 ? `${memberModifiers.join(' ')} ` : '';
|
|
25
|
+
return `${access_modifier} ${members}${typeReference.rawDeclaration} ${name}(${parameters})`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
headingLevel: baseHeadingLevel,
|
|
30
|
+
doc: adaptDocumentable(method, linkGenerator, baseHeadingLevel + 1),
|
|
31
|
+
heading: buildTitle(method as MethodMirrorWithInheritance),
|
|
32
|
+
signature: {
|
|
33
|
+
headingLevel: baseHeadingLevel + 1,
|
|
34
|
+
heading: 'Signature',
|
|
35
|
+
value: [buildSignature(method as MethodMirrorWithInheritance)],
|
|
36
|
+
},
|
|
37
|
+
returnType: {
|
|
38
|
+
headingLevel: baseHeadingLevel + 1,
|
|
39
|
+
heading: 'Return Type',
|
|
40
|
+
value: {
|
|
41
|
+
...adaptDescribable(method.docComment?.returnAnnotation?.bodyLines, linkGenerator),
|
|
42
|
+
type: linkFromTypeNameGenerator(method.typeReference.rawDeclaration),
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
throws: {
|
|
46
|
+
headingLevel: baseHeadingLevel + 1,
|
|
47
|
+
heading: 'Throws',
|
|
48
|
+
value: method.docComment?.throwsAnnotations.map((thrown) => mapThrows(thrown)),
|
|
49
|
+
},
|
|
50
|
+
parameters: {
|
|
51
|
+
headingLevel: baseHeadingLevel + 1,
|
|
52
|
+
heading: 'Parameters',
|
|
53
|
+
value: method.parameters.map((param) => mapParameters(method, param)),
|
|
54
|
+
},
|
|
55
|
+
inherited: (method as MethodMirrorWithInheritance).inherited,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function adaptConstructor(
|
|
60
|
+
typeName: string,
|
|
61
|
+
constructor: ConstructorMirror,
|
|
62
|
+
linkGenerator: GetRenderableContentByTypeName,
|
|
63
|
+
baseHeadingLevel: number,
|
|
64
|
+
): RenderableConstructor {
|
|
65
|
+
function buildTitle(name: string, constructor: ConstructorMirror): string {
|
|
66
|
+
const { parameters } = constructor;
|
|
67
|
+
const parametersString = parameters.map((param) => param.name).join(', ');
|
|
68
|
+
return `${name}(${parametersString})`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function buildSignature(name: string, constructor: ConstructorMirror): string {
|
|
72
|
+
const { access_modifier } = constructor;
|
|
73
|
+
const parameters = constructor.parameters
|
|
74
|
+
.map((param) => `${param.typeReference.rawDeclaration} ${param.name}`)
|
|
75
|
+
.join(', ');
|
|
76
|
+
return `${access_modifier} ${name}(${parameters})`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
doc: adaptDocumentable(constructor, linkGenerator, baseHeadingLevel + 1),
|
|
81
|
+
headingLevel: baseHeadingLevel,
|
|
82
|
+
heading: buildTitle(typeName, constructor),
|
|
83
|
+
signature: {
|
|
84
|
+
headingLevel: baseHeadingLevel + 1,
|
|
85
|
+
heading: 'Signature',
|
|
86
|
+
value: [buildSignature(typeName, constructor)],
|
|
87
|
+
},
|
|
88
|
+
parameters: {
|
|
89
|
+
headingLevel: baseHeadingLevel + 1,
|
|
90
|
+
heading: 'Parameters',
|
|
91
|
+
value: constructor.parameters.map((param) => mapParameters(constructor, param)),
|
|
92
|
+
},
|
|
93
|
+
throws: {
|
|
94
|
+
headingLevel: baseHeadingLevel + 1,
|
|
95
|
+
heading: 'Throws',
|
|
96
|
+
value: constructor.docComment?.throwsAnnotations.map((thrown) => mapThrows(thrown)),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function mapParameters(documentable: Documentable, param: ParameterMirror) {
|
|
102
|
+
const paramAnnotation = documentable.docComment?.paramAnnotations.find(
|
|
103
|
+
(pa) => pa.paramName.toLowerCase() === param.name.toLowerCase(),
|
|
104
|
+
);
|
|
105
|
+
return {
|
|
106
|
+
...adaptDescribable(paramAnnotation?.bodyLines, linkFromTypeNameGenerator),
|
|
107
|
+
name: param.name,
|
|
108
|
+
type: linkFromTypeNameGenerator(param.typeReference.rawDeclaration),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function mapThrows(thrown: ThrowsAnnotation) {
|
|
113
|
+
return {
|
|
114
|
+
...adaptDescribable(thrown.bodyLines, linkFromTypeNameGenerator),
|
|
115
|
+
type: linkFromTypeNameGenerator(thrown.exceptionName),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import ClassFileGeneratorHelper from '../transpiler/markdown/class-file-generatorHelper';
|
|
2
|
+
import { Link, RenderableContent, StringOrLink } from '../core/renderable/types';
|
|
3
|
+
|
|
4
|
+
export type GetRenderableContentByTypeName = (typeName: string) => StringOrLink;
|
|
5
|
+
|
|
6
|
+
export const linkFromTypeNameGenerator: GetRenderableContentByTypeName =
|
|
7
|
+
ClassFileGeneratorHelper.getRenderableLinkByTypeName;
|
|
8
|
+
|
|
9
|
+
function defaultGetEmailByReference(email: string): Link {
|
|
10
|
+
return {
|
|
11
|
+
title: email,
|
|
12
|
+
url: `mailto:${email}`,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function replaceInlineReferences(
|
|
17
|
+
text: string,
|
|
18
|
+
linkReplacer: GetRenderableContentByTypeName = linkFromTypeNameGenerator,
|
|
19
|
+
emailReplacer: GetRenderableContentByTypeName = defaultGetEmailByReference,
|
|
20
|
+
): RenderableContent[] {
|
|
21
|
+
return replaceInlineEmails(replaceInlineLinks([text], linkReplacer), emailReplacer);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function replaceInlineLinks(
|
|
25
|
+
renderableContents: RenderableContent[],
|
|
26
|
+
getLinkByTypeName: GetRenderableContentByTypeName,
|
|
27
|
+
): RenderableContent[] {
|
|
28
|
+
return renderableContents.flatMap((renderableContent) => inlineLinkContent(renderableContent, getLinkByTypeName));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function inlineLinkContent(
|
|
32
|
+
renderableContent: RenderableContent,
|
|
33
|
+
getLinkByTypeName: GetRenderableContentByTypeName,
|
|
34
|
+
): RenderableContent[] {
|
|
35
|
+
if (typeof renderableContent !== 'string') {
|
|
36
|
+
return [renderableContent];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const text = renderableContent;
|
|
40
|
+
|
|
41
|
+
// Matches either `<<ClassName>>` or `{@link ClassName}`
|
|
42
|
+
const linkFormatRegEx = '{@link (.*?)}|<<([^>]+)>>';
|
|
43
|
+
const matches = match(linkFormatRegEx, text);
|
|
44
|
+
return createRenderableContents(matches, text, getLinkByTypeName);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function replaceInlineEmails(
|
|
48
|
+
renderableContents: RenderableContent[],
|
|
49
|
+
getLinkByTypeName: GetRenderableContentByTypeName,
|
|
50
|
+
): RenderableContent[] {
|
|
51
|
+
return renderableContents.flatMap((renderableContent) => inlineEmailContent(renderableContent, getLinkByTypeName));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function inlineEmailContent(
|
|
55
|
+
renderableContent: RenderableContent,
|
|
56
|
+
getLinkByTypeName: GetRenderableContentByTypeName,
|
|
57
|
+
): RenderableContent[] {
|
|
58
|
+
if (typeof renderableContent !== 'string') {
|
|
59
|
+
return [renderableContent];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const text = renderableContent;
|
|
63
|
+
|
|
64
|
+
// Parsing references using the format '{@email email}'
|
|
65
|
+
const linkFormatRegEx = '{@email (.*?)}';
|
|
66
|
+
const matches = match(linkFormatRegEx, text);
|
|
67
|
+
return createRenderableContents(matches, text, getLinkByTypeName);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function match(regex: string, text: string) {
|
|
71
|
+
const expression = new RegExp(regex, 'gi');
|
|
72
|
+
let match;
|
|
73
|
+
const matches = [];
|
|
74
|
+
|
|
75
|
+
do {
|
|
76
|
+
match = expression.exec(text);
|
|
77
|
+
if (match) {
|
|
78
|
+
matches.push(match);
|
|
79
|
+
}
|
|
80
|
+
} while (match);
|
|
81
|
+
|
|
82
|
+
return matches;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function createRenderableContents(matches: RegExpExecArray[], text: string, linker: GetRenderableContentByTypeName) {
|
|
86
|
+
if (matches.length === 0) {
|
|
87
|
+
return [text];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const result: RenderableContent[] = [];
|
|
91
|
+
let lastIndex = 0;
|
|
92
|
+
for (const match of matches) {
|
|
93
|
+
const index = match.index;
|
|
94
|
+
const length = match[0].length;
|
|
95
|
+
|
|
96
|
+
// loop through the matches (skip the first one, which is the full match)
|
|
97
|
+
// until we find the first capturing group that has a value
|
|
98
|
+
const capturedGroup = match.slice(1).find((group) => group);
|
|
99
|
+
if (!capturedGroup) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
result.push(text.slice(lastIndex, index));
|
|
103
|
+
result.push(linker(capturedGroup));
|
|
104
|
+
|
|
105
|
+
lastIndex = index + length;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (lastIndex < text.length) {
|
|
109
|
+
result.push(text.slice(lastIndex));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return result;
|
|
113
|
+
}
|