From 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Fri, 10 Nov 2023 11:46:54 +0100 Subject: Restructure the project to utilize included builds (#3174) * Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich --- .../AbortGracefullyOnMissingDocumentablesTest.kt | 22 + .../plugin-base/src/test/kotlin/basic/DRITest.kt | 351 +++++ .../src/test/kotlin/basic/DokkaBasicTests.kt | 46 + .../src/test/kotlin/basic/FailOnWarningTest.kt | 128 ++ .../src/test/kotlin/basic/LoggerTest.kt | 48 + .../kotlin/content/ContentInDescriptionTest.kt | 142 ++ .../src/test/kotlin/content/HighlightingTest.kt | 83 + .../annotations/ContentForAnnotationsTest.kt | 351 +++++ .../content/annotations/FileLevelJvmNameTest.kt | 115 ++ .../content/annotations/JavaDeprecatedTest.kt | 144 ++ .../content/annotations/KotlinDeprecatedTest.kt | 401 +++++ .../kotlin/content/annotations/SinceKotlinTest.kt | 350 +++++ .../content/exceptions/ContentForExceptions.kt | 439 ++++++ .../content/functions/ContentForBriefTest.kt | 388 +++++ .../content/functions/ContentForConstructors.kt | 53 + .../content/inheritors/ContentForInheritorsTest.kt | 499 ++++++ .../kotlin/content/params/ContentForParamsTest.kt | 1529 ++++++++++++++++++ .../ContentForClassWithParamsAndPropertiesTest.kt | 272 ++++ .../content/receiver/ContentForReceiverTest.kt | 61 + .../content/samples/ContentForSamplesTest.kt | 207 +++ .../content/seealso/ContentForSeeAlsoTest.kt | 866 +++++++++++ .../signatures/ConstructorsSignaturesTest.kt | 469 ++++++ .../content/signatures/ContentForSignaturesTest.kt | 515 ++++++ .../kotlin/content/typealiases/TypealiasTest.kt | 83 + .../src/test/kotlin/enums/JavaEnumsTest.kt | 75 + .../src/test/kotlin/enums/KotlinEnumsTest.kt | 471 ++++++ .../src/test/kotlin/expect/AbstractExpectTest.kt | 109 ++ .../src/test/kotlin/expect/ExpectGenerator.kt | 17 + .../src/test/kotlin/expect/ExpectTest.kt | 28 + .../src/test/kotlin/expect/ExpectUtils.kt | 32 + .../test/kotlin/expectActuals/ExpectActualsTest.kt | 179 +++ .../test/kotlin/filter/DeprecationFilterTest.kt | 264 ++++ .../test/kotlin/filter/EmptyPackagesFilterTest.kt | 70 + .../src/test/kotlin/filter/JavaFileFilterTest.kt | 40 + .../test/kotlin/filter/JavaVisibilityFilterTest.kt | 308 ++++ .../filter/KotlinArrayDocumentableReplacerTest.kt | 211 +++ .../src/test/kotlin/filter/VisibilityFilterTest.kt | 755 +++++++++ .../src/test/kotlin/issues/IssuesTest.kt | 59 + .../kotlin/linkableContent/LinkableContentTest.kt | 418 +++++ .../test/kotlin/linking/EnumValuesLinkingTest.kt | 142 ++ .../AndroidExternalLocationProviderTest.kt | 109 ++ .../DefaultExternalLocationProviderTest.kt | 78 + .../Dokka010ExternalLocationProviderTest.kt | 123 ++ .../locationProvider/DokkaLocationProviderTest.kt | 126 ++ .../JavadocExternalLocationProviderTest.kt | 85 + .../locationProvider/MultiModuleLinkingTest.kt | 74 + .../src/test/kotlin/markdown/KDocTest.kt | 51 + .../src/test/kotlin/markdown/LinkTest.kt | 240 +++ .../src/test/kotlin/markdown/ParserTest.kt | 1633 ++++++++++++++++++++ .../src/test/kotlin/model/ClassesTest.kt | 594 +++++++ .../src/test/kotlin/model/CommentTest.kt | 338 ++++ .../src/test/kotlin/model/ExtensionsTest.kt | 159 ++ .../src/test/kotlin/model/FunctionsTest.kt | 403 +++++ .../src/test/kotlin/model/InheritorsTest.kt | 428 +++++ .../plugin-base/src/test/kotlin/model/JavaTest.kt | 491 ++++++ .../kotlin/model/MultiLanguageInheritanceTest.kt | 365 +++++ .../src/test/kotlin/model/ObjectTest.kt | 43 + .../src/test/kotlin/model/PackagesTest.kt | 123 ++ .../src/test/kotlin/model/PropertyTest.kt | 277 ++++ .../JavaAnnotationsForParametersTest.kt | 181 +++ .../model/annotations/JavaAnnotationsTest.kt | 195 +++ .../KotlinAnnotationsForParametersTest.kt | 105 ++ .../kotlin/multiplatform/BasicMultiplatformTest.kt | 58 + .../src/test/kotlin/packageList/PackageListTest.kt | 69 + .../test/kotlin/pageMerger/PageNodeMergerTest.kt | 465 ++++++ .../src/test/kotlin/parsers/JavadocParserTest.kt | 618 ++++++++ .../src/test/kotlin/renderers/html/BasicTest.kt | 24 + .../test/kotlin/renderers/html/BreadcrumbsTest.kt | 88 ++ .../test/kotlin/renderers/html/CoverPageTest.kt | 51 + .../test/kotlin/renderers/html/CustomFooterTest.kt | 48 + .../test/kotlin/renderers/html/DivergentTest.kt | 316 ++++ .../kotlin/renderers/html/FooterMessageTest.kt | 31 + .../kotlin/renderers/html/FormattingUtilsTest.kt | 86 ++ .../kotlin/renderers/html/GroupWrappingTest.kt | 82 + .../src/test/kotlin/renderers/html/HeaderTest.kt | 102 ++ .../renderers/html/HtmlRenderingOnlyTestBase.kt | 68 + .../test/kotlin/renderers/html/ListStylesTest.kt | 45 + .../kotlin/renderers/html/NavigationIconTest.kt | 292 ++++ .../test/kotlin/renderers/html/NavigationTest.kt | 414 +++++ .../renderers/html/SearchbarDataInstallerTest.kt | 50 + .../renderers/html/SourceSetDependentHintTest.kt | 139 ++ .../kotlin/renderers/html/SourceSetFilterTest.kt | 68 + .../kotlin/renderers/html/TabbedContentTest.kt | 188 +++ .../test/kotlin/renderers/html/TextStylesTest.kt | 113 ++ .../test/kotlin/resourceLinks/ResourceLinksTest.kt | 301 ++++ .../kotlin/signatures/AbstractRenderingTest.kt | 65 + .../kotlin/signatures/DivergentSignatureTest.kt | 73 + .../FunctionalTypeConstructorsSignatureTest.kt | 312 ++++ .../signatures/InheritedAccessorsSignatureTest.kt | 461 ++++++ .../kotlin/signatures/ObviousTypeSkippingTest.kt | 206 +++ .../test/kotlin/signatures/RawHtmlRenderingTest.kt | 70 + .../src/test/kotlin/signatures/SignatureTest.kt | 1035 +++++++++++++ .../kotlin/signatures/VarianceSignatureTest.kt | 108 ++ .../superFields/DescriptorSuperPropertiesTest.kt | 366 +++++ .../test/kotlin/superFields/PsiSuperFieldsTest.kt | 177 +++ .../PageTransformerBuilderTest.kt | 195 +++ ...ntextModuleAndPackageDocumentationReaderTest.kt | 27 + .../transformers/CommentsToContentConverterTest.kt | 484 ++++++ ...textModuleAndPackageDocumentationReaderTest1.kt | 187 +++ ...textModuleAndPackageDocumentationReaderTest3.kt | 61 + .../test/kotlin/transformers/DivisionSwitchTest.kt | 126 ++ ...itedEntriesDocumentableFilterTransfromerTest.kt | 162 ++ ...ntentModuleAndPackageDocumentationReaderTest.kt | 100 ++ .../MergeImplicitExpectActualDeclarationsTest.kt | 386 +++++ ...ackageDocumentationTransformerFunctionalTest.kt | 137 ++ ...leAndPackageDocumentationTransformerUnitTest.kt | 260 ++++ ...sAndInheritedFunctionsDocumentableFilterTest.kt | 229 +++ .../ReportUndocumentedTransformerTest.kt | 927 +++++++++++ .../transformers/SourceLinkTransformerTest.kt | 131 ++ .../kotlin/transformers/SuppressTagFilterTest.kt | 211 +++ ...nfigurationDocumentableFilterTransformerTest.kt | 193 +++ .../test/kotlin/transformers/isExceptionTest.kt | 147 ++ .../kotlin/translators/AccessorMethodNamingTest.kt | 123 ++ .../src/test/kotlin/translators/Bug1341.kt | 48 + ...efaultDescriptorToDocumentableTranslatorTest.kt | 1107 +++++++++++++ .../DefaultPsiToDocumentableTranslatorTest.kt | 1027 ++++++++++++ .../translators/ExternalDocumentablesTest.kt | 144 ++ .../kotlin/translators/JavadocInheritDocsTest.kt | 312 ++++ .../translators/JavadocInheritedDocTagsTest.kt | 252 +++ .../test/kotlin/translators/JavadocParserTest.kt | 208 +++ .../src/test/kotlin/translators/utils.kt | 43 + .../plugin-base/src/test/kotlin/utils/HtmlUtils.kt | 20 + .../src/test/kotlin/utils/ModelUtils.kt | 43 + .../src/test/kotlin/utils/TagsAnnotations.kt | 42 + .../plugin-base/src/test/kotlin/utils/TestUtils.kt | 94 ++ .../src/test/kotlin/utils/contentUtils.kt | 355 +++++ .../src/test/resources/content/samples/samples.kt | 9 + .../test/resources/linkable/includes/include1.md | 14 + .../test/resources/linkable/includes/include11.md | 3 + .../test/resources/linkable/includes/include2.md | 7 + .../linkable/samples/jsMain/kotlin/JsClass.kt | 13 + .../linkable/samples/jsMain/resources/Samples.kt | 14 + .../linkable/samples/jvmMain/kotlin/JvmClass.kt | 13 + .../linkable/samples/jvmMain/resources/Samples.kt | 14 + .../linkable/sources/jsMain/kotlin/JsClass.kt | 7 + .../linkable/sources/jvmMain/kotlin/JvmClass.kt | 7 + .../jvmMain/kotlin/linking/source/JavaEnum.java | 5 + .../jvmMain/kotlin/linking/source/JavaLinker.java | 8 + .../jvmMain/kotlin/linking/source/KotlinEnum.kt | 9 + .../jvmMain/kotlin/linking/source/KotlinLinker.kt | 12 + .../resources/locationProvider/jdk8-package-list | 217 +++ .../locationProvider/multi-module-package-list | 8 + .../resources/locationProvider/old-package-list | 9 + .../resources/locationProvider/stdlib-package-list | 67 + .../commonMain/kotlin/Clock.kt | 19 + .../commonMain/kotlin/House.kt | 28 + .../basicMultiplatformTest/jsMain/kotlin/Clock.kt | 32 + .../jvmAndJsSecondCommonMain/kotlin/Greeter.kt | 14 + .../jvmMain/kotlin/example/Clock.kt | 43 + .../jvmMain/kotlin/example/ClockDays.kt | 19 + .../jvmMain/kotlin/example/HtmlTest.kt | 24 + .../jvmMain/kotlin/example/ParticularClock.kt | 36 + 152 files changed, 31982 insertions(+) create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/basic/AbortGracefullyOnMissingDocumentablesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/basic/DRITest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/basic/DokkaBasicTests.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/basic/FailOnWarningTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/basic/LoggerTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/ContentInDescriptionTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/HighlightingTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/annotations/FileLevelJvmNameTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/annotations/JavaDeprecatedTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/annotations/KotlinDeprecatedTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/annotations/SinceKotlinTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/exceptions/ContentForExceptions.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/functions/ContentForBriefTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/functions/ContentForConstructors.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/inheritors/ContentForInheritorsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/params/ContentForParamsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/properties/ContentForClassWithParamsAndPropertiesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/receiver/ContentForReceiverTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/samples/ContentForSamplesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/seealso/ContentForSeeAlsoTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/signatures/ConstructorsSignaturesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/content/typealiases/TypealiasTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/enums/JavaEnumsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/enums/KotlinEnumsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/expect/AbstractExpectTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/expect/ExpectGenerator.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/expect/ExpectTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/expect/ExpectUtils.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/expectActuals/ExpectActualsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/filter/DeprecationFilterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/filter/EmptyPackagesFilterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/filter/JavaFileFilterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/filter/JavaVisibilityFilterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/filter/KotlinArrayDocumentableReplacerTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/filter/VisibilityFilterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/issues/IssuesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/linkableContent/LinkableContentTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/linking/EnumValuesLinkingTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/DefaultExternalLocationProviderTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/DokkaLocationProviderTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/JavadocExternalLocationProviderTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/MultiModuleLinkingTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/markdown/KDocTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/markdown/LinkTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/markdown/ParserTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/ClassesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/CommentTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/ExtensionsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/FunctionsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/InheritorsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/JavaTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/MultiLanguageInheritanceTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/ObjectTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/PackagesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/PropertyTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/annotations/JavaAnnotationsForParametersTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/annotations/JavaAnnotationsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/model/annotations/KotlinAnnotationsForParametersTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/multiplatform/BasicMultiplatformTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/packageList/PackageListTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/pageMerger/PageNodeMergerTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/parsers/JavadocParserTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/BasicTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/BreadcrumbsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/CoverPageTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/CustomFooterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/DivergentTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/FooterMessageTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/FormattingUtilsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/GroupWrappingTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/HeaderTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/HtmlRenderingOnlyTestBase.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/ListStylesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/NavigationIconTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/NavigationTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/SearchbarDataInstallerTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/SourceSetDependentHintTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/SourceSetFilterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/TabbedContentTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/renderers/html/TextStylesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/resourceLinks/ResourceLinksTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/signatures/AbstractRenderingTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/signatures/DivergentSignatureTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/signatures/FunctionalTypeConstructorsSignatureTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/signatures/InheritedAccessorsSignatureTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/signatures/ObviousTypeSkippingTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/signatures/RawHtmlRenderingTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/signatures/SignatureTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/signatures/VarianceSignatureTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/superFields/DescriptorSuperPropertiesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/superFields/PsiSuperFieldsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformerBuilders/PageTransformerBuilderTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/AbstractContextModuleAndPackageDocumentationReaderTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/CommentsToContentConverterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest1.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/ContextModuleAndPackageDocumentationReaderTest3.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/DivisionSwitchTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/InheritedEntriesDocumentableFilterTransfromerTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/InvalidContentModuleAndPackageDocumentationReaderTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/MergeImplicitExpectActualDeclarationsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerFunctionalTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/ModuleAndPackageDocumentationTransformerUnitTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/ObviousAndInheritedFunctionsDocumentableFilterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/ReportUndocumentedTransformerTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/SourceLinkTransformerTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/SuppressTagFilterTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/SuppressedByConfigurationDocumentableFilterTransformerTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/transformers/isExceptionTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/AccessorMethodNamingTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/Bug1341.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/DefaultDescriptorToDocumentableTranslatorTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/ExternalDocumentablesTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/JavadocInheritDocsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/JavadocInheritedDocTagsTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/JavadocParserTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/translators/utils.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/utils/HtmlUtils.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/utils/ModelUtils.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/utils/TagsAnnotations.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/utils/TestUtils.kt create mode 100644 dokka-subprojects/plugin-base/src/test/kotlin/utils/contentUtils.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/content/samples/samples.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linkable/includes/include1.md create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linkable/includes/include11.md create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linkable/includes/include2.md create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linkable/samples/jsMain/kotlin/JsClass.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linkable/samples/jsMain/resources/Samples.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linkable/samples/jvmMain/kotlin/JvmClass.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linkable/samples/jvmMain/resources/Samples.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linkable/sources/jsMain/kotlin/JsClass.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linkable/sources/jvmMain/kotlin/JvmClass.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linking/jvmMain/kotlin/linking/source/JavaEnum.java create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linking/jvmMain/kotlin/linking/source/JavaLinker.java create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linking/jvmMain/kotlin/linking/source/KotlinEnum.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/linking/jvmMain/kotlin/linking/source/KotlinLinker.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/locationProvider/jdk8-package-list create mode 100644 dokka-subprojects/plugin-base/src/test/resources/locationProvider/multi-module-package-list create mode 100644 dokka-subprojects/plugin-base/src/test/resources/locationProvider/old-package-list create mode 100644 dokka-subprojects/plugin-base/src/test/resources/locationProvider/stdlib-package-list create mode 100644 dokka-subprojects/plugin-base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/Clock.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/multiplatform/basicMultiplatformTest/commonMain/kotlin/House.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/multiplatform/basicMultiplatformTest/jsMain/kotlin/Clock.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/multiplatform/basicMultiplatformTest/jvmAndJsSecondCommonMain/kotlin/Greeter.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/Clock.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ClockDays.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/HtmlTest.kt create mode 100644 dokka-subprojects/plugin-base/src/test/resources/multiplatform/basicMultiplatformTest/jvmMain/kotlin/example/ParticularClock.kt (limited to 'dokka-subprojects/plugin-base/src/test') diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/basic/AbortGracefullyOnMissingDocumentablesTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/basic/AbortGracefullyOnMissingDocumentablesTest.kt new file mode 100644 index 00000000..693174ec --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/basic/AbortGracefullyOnMissingDocumentablesTest.kt @@ -0,0 +1,22 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package basic + +import org.jetbrains.dokka.DokkaGenerator +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import kotlin.test.Test +import kotlin.test.assertTrue + +class AbortGracefullyOnMissingDocumentablesTest: BaseAbstractTest() { + @Test + fun `Generation aborts Gracefully with no Documentables`() { + DokkaGenerator(dokkaConfiguration { }, logger).generate() + + assertTrue( + logger.progressMessages.any { message -> "Exiting Generation: Nothing to document" == message }, + "Expected graceful exit message. Found: ${logger.progressMessages}" + ) + } +} diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/basic/DRITest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/basic/DRITest.kt new file mode 100644 index 00000000..6fd9d4b0 --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/basic/DRITest.kt @@ -0,0 +1,351 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package basic + +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.links.* +import org.jetbrains.dokka.links.Callable +import org.jetbrains.dokka.links.Nullable +import org.jetbrains.dokka.links.TypeConstructor +import org.jetbrains.dokka.model.* +import org.jetbrains.dokka.pages.ClasslikePageNode +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.pages.MemberPageNode +import kotlin.test.Test +import kotlin.test.assertEquals + +class DRITest : BaseAbstractTest() { + @Test + fun issue634() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package toplevel + | + |inline fun > Array.mySortBy( + | crossinline selector: (T) -> R?): Array = TODO() + |} + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val expected = TypeConstructor( + "kotlin.Function1", listOf( + TypeParam(listOf(Nullable(TypeConstructor("kotlin.Any", emptyList())))), + Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(RecursiveType(0)))))) + ) + ) + val actual = module.packages.single() + .functions.single() + .dri.callable?.params?.single() + assertEquals(expected, actual) + } + } + } + + @Test + fun issue634WithImmediateNullableSelf() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package toplevel + | + |fun > Array.doSomething(t: T?): Array = TODO() + |} + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val expected = Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(RecursiveType(0)))))) + val actual = module.packages.single() + .functions.single() + .dri.callable?.params?.single() + assertEquals(expected, actual) + } + } + } + + @Test + fun issue634WithGenericNullableReceiver() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package toplevel + | + |fun > T?.doSomethingWithNullable() = TODO() + |} + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val expected = Nullable(TypeParam(listOf(TypeConstructor("kotlin.Comparable", listOf(RecursiveType(0)))))) + val actual = module.packages.single() + .functions.single() + .dri.callable?.receiver + assertEquals(expected, actual) + } + } + } + + @Test + fun issue642WithStarAndAny() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + analysisPlatform = "js" + sourceRoots = listOf("src/") + } + } + } + + testInline( + """ + |/src/main/kotlin/Test.kt + | + |open class Bar + |class ReBarBar : Bar() + |class Foo, R : List>> + | + |fun > Foo.qux(): String = TODO() + |fun > Foo.qux(): String = TODO() + | + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { module -> + // DRI(//qux/Foo[TypeParam(bounds=[kotlin.Comparable[kotlin.Any?]]),*]#/PointingToFunctionOrClasslike/) + val expectedDRI = DRI( + "", + null, + Callable( + "qux", TypeConstructor( + "Foo", listOf( + TypeParam( + listOf( + TypeConstructor( + "kotlin.Comparable", listOf( + Nullable(TypeConstructor("kotlin.Any", emptyList())) + ) + ) + ) + ), + StarProjection + ) + ), + emptyList() + ) + ) + + val driCount = module + .withDescendants() + .filterIsInstance() + .sumBy { it.dri.count { dri -> dri == expectedDRI } } + + assertEquals(1, driCount) + } + } + } + + @Test + fun driForGenericClass(){ + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + testInline( + """ + |/src/main/kotlin/Test.kt + |package example + | + |class Sample(first: S){ } + | + | + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { module -> + val sampleClass = module.dfs { it.name == "Sample" } as ClasslikePageNode + val classDocumentable = sampleClass.documentables.firstOrNull() as DClass + + assertEquals( "example/Sample///PointingToDeclaration/", sampleClass.dri.first().toString()) + assertEquals("example/Sample///PointingToGenericParameters(0)/", classDocumentable.generics.first().dri.toString()) + } + } + } + + @Test + fun driForGenericFunction(){ + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + classpath = listOfNotNull(jvmStdlibPath) + } + } + } + testInline( + """ + |/src/main/kotlin/Test.kt + |package example + | + |class Sample(first: S){ + | fun genericFun(param1: String): Tuple = TODO() + |} + | + | + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { module -> + val sampleClass = module.dfs { it.name == "Sample" } as ClasslikePageNode + val functionNode = sampleClass.children.first { it.name == "genericFun" } as MemberPageNode + val functionDocumentable = functionNode.documentables.firstOrNull() as DFunction + val parameter = functionDocumentable.parameters.first() + + assertEquals("example/Sample/genericFun/#kotlin.String/PointingToDeclaration/", functionNode.dri.first().toString()) + + assertEquals(1, functionDocumentable.parameters.size) + assertEquals("example/Sample/genericFun/#kotlin.String/PointingToCallableParameters(0)/", parameter.dri.toString()) + //1 since from the function's perspective there is only 1 new generic declared + //The other one is 'inherited' from class + assertEquals( 1, functionDocumentable.generics.size) + assertEquals( "T", functionDocumentable.generics.first().name) + assertEquals( "example/Sample/genericFun/#kotlin.String/PointingToGenericParameters(0)/", functionDocumentable.generics.first().dri.toString()) + } + } + } + + @Test + fun driForFunctionNestedInsideInnerClass() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + classpath = listOfNotNull(jvmStdlibPath) + } + } + } + testInline( + """ + |/src/main/kotlin/Test.kt + |package example + | + |class Sample(first: S){ + | inner class SampleInner { + | fun foo(): S = TODO() + | } + |} + | + | + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { module -> + val sampleClass = module.dfs { it.name == "Sample" } as ClasslikePageNode + val sampleInner = sampleClass.children.first { it.name == "SampleInner" } as ClasslikePageNode + val foo = sampleInner.children.first { it.name == "foo" } as MemberPageNode + val documentable = foo.documentables.firstOrNull() as DFunction + + val generics = (sampleClass.documentables.firstOrNull() as WithGenerics).generics + assertEquals(generics.first().dri.toString(), (documentable.type as TypeParameter).dri.toString()) + assertEquals(0, documentable.generics.size) + } + } + } + + @Test + fun driForGenericExtensionFunction(){ + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + testInline( + """ + |/src/main/kotlin/Test.kt + |package example + | + | fun List.extensionFunction(): String = "" + | + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { module -> + val extensionFunction = module.dfs { it.name == "extensionFunction" } as MemberPageNode + val documentable = extensionFunction.documentables.firstOrNull() as DFunction + + assertEquals( + "example//extensionFunction/kotlin.collections.List[TypeParam(bounds=[kotlin.Any?])]#/PointingToDeclaration/", + extensionFunction.dri.first().toString() + ) + assertEquals(1, documentable.generics.size) + assertEquals("T", documentable.generics.first().name) + assertEquals( + "example//extensionFunction/kotlin.collections.List[TypeParam(bounds=[kotlin.Any?])]#/PointingToGenericParameters(0)/", + documentable.generics.first().dri.toString() + ) + + } + } + } + + @Test + fun `deep recursive typebound #1342`() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + } + } + } + testInline( + """ + |/src/main/kotlin/Test.kt + |package example + | + | fun recursiveBound(t: T, s: S, r: R) where T: List, S: List, R: List = Unit + | + """.trimMargin(), + configuration + ) { + documentablesMergingStage = { module -> + val function = module.dfs { it.name == "recursiveBound" } + assertEquals( + "example//recursiveBound/#TypeParam(bounds=[kotlin.collections.List[TypeParam(bounds=[kotlin.collections.List[TypeParam(bounds=[kotlin.collections.List[^^]])]])]])#TypeParam(bounds=[kotlin.collections.List[TypeParam(bounds=[kotlin.collections.List[^]])]])#TypeParam(bounds=[kotlin.collections.List[TypeParam(bounds=[kotlin.collections.List[^]])]])/PointingToDeclaration/", + function?.dri?.toString(), + ) + } + } + } +} diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/basic/DokkaBasicTests.kt b/dokka-subprojects/plugin-base/src/test/kotlin/basic/DokkaBasicTests.kt new file mode 100644 index 00000000..2b353ad8 --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/basic/DokkaBasicTests.kt @@ -0,0 +1,46 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package basic + +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.pages.ClasslikePageNode +import org.jetbrains.dokka.pages.ModulePageNode +import kotlin.test.Test +import kotlin.test.assertEquals + +class DokkaBasicTests : BaseAbstractTest() { + + @Test + fun basic1() { + val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/main/kotlin/basic/Test.kt") + } + } + } + + testInline( + """ + |/src/main/kotlin/basic/Test.kt + |package basic + | + |class Test { + | val tI = 1 + | fun tF() = 2 + |} + """.trimMargin(), + configuration + ) { + pagesGenerationStage = { + val root = it as ModulePageNode + assertEquals(3, root.getClasslikeToMemberMap().filterKeys { it.name == "Test" }.entries.firstOrNull()?.value?.size) + } + } + } + + private fun ModulePageNode.getClasslikeToMemberMap() = + this.parentMap.filterValues { it is ClasslikePageNode }.entries.groupBy({ it.value }) { it.key } +} diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/basic/FailOnWarningTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/basic/FailOnWarningTest.kt new file mode 100644 index 00000000..ebdf7860 --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/basic/FailOnWarningTest.kt @@ -0,0 +1,128 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package basic + +import org.jetbrains.dokka.DokkaException +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.testApi.logger.TestLogger +import org.jetbrains.dokka.utilities.DokkaConsoleLogger +import org.jetbrains.dokka.utilities.DokkaLogger +import org.jetbrains.dokka.utilities.LoggingLevel +import kotlin.test.Test +import kotlin.test.assertFailsWith + +class FailOnWarningTest : BaseAbstractTest() { + + @Test + fun `throws exception if one or more warnings were emitted`() { + val configuration = dokkaConfiguration { + failOnWarning = true + sourceSets { + sourceSet { + sourceRoots = listOf("src/main/kotlin") + } + } + } + + assertFailsWith { + testInline( + """ + |/src/main/kotlin/Bar.kt + |package sample + |class Bar {} + """.trimIndent(), configuration + ) { + pluginsSetupStage = { + logger.warn("Warning!") + } + } + } + } + + @Test + fun `throws exception if one or more error were emitted`() { + val configuration = dokkaConfiguration { + failOnWarning = true + sourceSets { + sourceSet { + sourceRoots = listOf("src/main/kotlin") + } + } + } + + assertFailsWith { + testInline( + """ + |/src/main/kotlin/Bar.kt + |package sample + |class Bar {} + """.trimIndent(), configuration + ) { + pluginsSetupStage = { + logger.error("Error!") + } + } + } + } + + @Test + fun `does not throw if now warning or error was emitted`() { + + val configuration = dokkaConfiguration { + failOnWarning = true + sourceSets { + sourceSet { + sourceRoots = listOf("src/main/kotlin") + } + } + } + + + testInline( + """ + |/src/main/kotlin/Bar.kt + |package sample + |class Bar {} + """.trimIndent(), + configuration, + loggerForTest = TestLogger(ZeroErrorOrWarningCountDokkaLogger()) + ) { + /* We expect no Exception */ + } + } + + @Test + fun `does not throw if disabled`() { + val configuration = dokkaConfiguration { + failOnWarning = false + sourceSets { + sourceSet { + sourceRoots = listOf("src/main/kotlin") + } + } + } + + + testInline( + """ + |/src/main/kotlin/Bar.kt + |package sample + |class Bar {} + """.trimIndent(), configuration + ) { + pluginsSetupStage = { + logger.warn("Error!") + logger.error("Error!") + } + } + } +} + +private class ZeroErrorOrWarningCountDokkaLogger( + logger: DokkaLogger = DokkaConsoleLogger(LoggingLevel.DEBUG) +) : DokkaLogger by logger { + override var warningsCount: Int = 0 + override var errorsCount: Int = 0 +} diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/basic/LoggerTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/basic/LoggerTest.kt new file mode 100644 index 00000000..12c39690 --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/basic/LoggerTest.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package basic + +import org.jetbrains.dokka.utilities.DokkaConsoleLogger +import org.jetbrains.dokka.utilities.LoggingLevel +import org.jetbrains.dokka.utilities.MessageEmitter +import kotlin.test.Test +import kotlin.test.assertFalse +import kotlin.test.assertTrue + +class LoggerTest { + class AccumulatingEmitter : MessageEmitter { + val messages: MutableList = mutableListOf() + override fun invoke(message: String) { + messages.add(message) + } + } + + @Test + fun `should display info messages if logging is info`(){ + val emitter = AccumulatingEmitter() + val logger = DokkaConsoleLogger(LoggingLevel.INFO, emitter) + + logger.debug("Debug!") + logger.info("Info!") + + assertTrue(emitter.messages.size > 0) + assertTrue(emitter.messages.any { it == "Info!" }) + assertFalse(emitter.messages.any { it == "Debug!" }) + } + + @Test + fun `should not display info messages if logging is warn`(){ + val emitter = AccumulatingEmitter() + val logger = DokkaConsoleLogger(LoggingLevel.WARN, emitter) + + logger.warn("Warning!") + logger.info("Info!") + + + assertTrue(emitter.messages.size > 0) + assertFalse(emitter.messages.any { it.contains("Info!") }) + assertTrue(emitter.messages.any { it.contains("Warning!") }) + } +} diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/content/ContentInDescriptionTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/content/ContentInDescriptionTest.kt new file mode 100644 index 00000000..a278795d --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/content/ContentInDescriptionTest.kt @@ -0,0 +1,142 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package content + +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.model.doc.* +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue + +class ContentInDescriptionTest : BaseAbstractTest() { + private val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + analysisPlatform = "jvm" + classpath += jvmStdlibPath!! + } + } + } + + val expectedDescription = Description( + CustomDocTag( + listOf( + P( + listOf( + Text("Hello World! Docs with period issue, e.g."), + Text(String(Character.toChars(160)), params = mapOf("content-type" to "html")), + Text("this.") + ) + ) + ), + params = emptyMap(), + name = "MARKDOWN_FILE" + ) + ) + + @Test + fun `nbsp is handled as code in kotlin`() { + testInline( + """ + |/src/main/kotlin/sample/ParentKt.kt + |package sample; + |/** + | * Hello World! Docs with period issue, e.g. this. + | */ + |public class ParentKt { + |} + """.trimIndent(), configuration + ) { + documentablesMergingStage = { + val classlike = it.packages.flatMap { it.classlikes }.find { it.name == "ParentKt" } + + assertTrue(classlike != null) + assertEquals(expectedDescription, classlike.documentation.values.first().children.first()) + } + } + } + + @Test + fun `nbsp is handled as code in java`() { + testInline( + """ + |/src/main/kotlin/sample/Parent.java + |package sample; + |/** + | * Hello World! Docs with period issue, e.g. this. + | */ + |public class Parent { + |} + """.trimIndent(), configuration + ) { + documentablesMergingStage = { + val classlike = it.packages.flatMap { it.classlikes }.find { it.name == "Parent" } + + assertTrue(classlike != null) + assertEquals(expectedDescription, classlike.documentation.values.first().children.first()) + } + } + } + + @Test + fun `same documentation in java and kotlin when nbsp is present`() { + testInline( + """ + |/src/main/kotlin/sample/Parent.java + |package sample; + |/** + | * Hello World! Docs with period issue, e.g. this. + | */ + |public class Parent { + |} + | + |/src/main/kotlin/sample/ParentKt.kt + |package sample; + |/** + | * Hello World! Docs with period issue, e.g. this. + | */ + |public class ParentKt { + |} + """.trimIndent(), + configuration + ) { + documentablesMergingStage = { module -> + val java = module.packages.flatMap { it.classlikes }.first { it.name == "Parent" } + val kotlin = module.packages.flatMap { it.classlikes }.first { it.name == "ParentKt" } + + assertEquals(java.documentation.values.first(), kotlin.documentation.values.first()) + } + } + } + + @Test + fun `text surrounded by angle brackets is not removed`() { + testInline( + """ + |/src/main/kotlin/sample/Foo.kt + |package sample + |/** + | * My example `CodeInline` + | * ``` + | * CodeBlock + | * ``` + | */ + |class Foo { + |} + """.trimIndent(), + configuration + ) { + documentablesMergingStage = { module -> + val cls = module.packages.flatMap { it.classlikes }.first { it.name == "Foo" } + val documentation = cls.documentation.values.first() + val docTags = documentation.children.single().root.children + + assertEquals("CodeInline", ((docTags[0].children[1] as CodeInline).children.first() as Text).body) + assertEquals("CodeBlock", ((docTags[1] as CodeBlock).children.first() as Text).body) + } + } + } +} diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/content/HighlightingTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/content/HighlightingTest.kt new file mode 100644 index 00000000..a7fb2bde --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/content/HighlightingTest.kt @@ -0,0 +1,83 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package content + +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.model.dfs +import org.jetbrains.dokka.pages.* +import kotlin.test.Test +import kotlin.test.assertTrue + +class HighlightingTest : BaseAbstractTest() { + private val configuration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + classpath = listOf(commonStdlibPath!!, jvmStdlibPath!!) + externalDocumentationLinks = listOf(stdlibExternalDocumentationLink) + } + } + } + + @Test + fun `open suspend fun`() { + testInline( + """ + |/src/main/kotlin/test/Test.kt + |package example + | + | open suspend fun simpleFun(): String = "Celebrimbor" + """, + configuration + ) { + pagesTransformationStage = { module -> + val symbol = (module.dfs { it.name == "simpleFun" } as MemberPageNode).content + .dfs { it is ContentGroup && it.dci.kind == ContentKind.Symbol } + val children = symbol?.children + + for (it in listOf( + Pair(0, TokenStyle.Keyword), Pair(1, TokenStyle.Keyword), Pair(2, TokenStyle.Keyword), + Pair(4, TokenStyle.Punctuation), Pair(5, TokenStyle.Punctuation), Pair(6, TokenStyle.Operator) + )) + assertTrue(children?.get(it.first)?.style?.contains(it.second) == true) + assertTrue(children?.get(3)?.children?.first()?.style?.contains(TokenStyle.Function) == true) + } + } + } + + @Test + fun `plain typealias of plain class with annotation`() { + testInline( + """ + |/src/main/kotlin/common/Test.kt + |package example + | + |@MustBeDocumented + |@Target(AnnotationTarget.TYPEALIAS) + |annotation class SomeAnnotation + | + |@SomeAnnotation + |typealias PlainTypealias = Int + | + """.trimMargin(), + configuration + ) { + pagesTransformationStage = { module -> + val symbol = (module.dfs { it.name == "example" } as PackagePageNode).content + .dfs { it is ContentGroup && it.dci.kind == ContentKind.Symbol } + val children = symbol?.children + + for (it in listOf( + Pair(1, TokenStyle.Keyword), Pair(3, TokenStyle.Operator) + )) + assertTrue(children?.get(it.first)?.style?.contains(it.second) == true) + val annotation = children?.first()?.children?.first() + + assertTrue(annotation?.children?.get(0)?.style?.contains(TokenStyle.Annotation) == true) + assertTrue(annotation?.children?.get(1)?.children?.first()?.style?.contains(TokenStyle.Annotation) == true) + } + } + } +} diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt new file mode 100644 index 00000000..7293b53c --- /dev/null +++ b/dokka-subprojects/plugin-base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt @@ -0,0 +1,351 @@ +/* + * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. + */ + +package content.annotations + +import matchers.content.* +import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest +import org.jetbrains.dokka.base.utils.firstNotNullOfOrNull +import org.jetbrains.dokka.links.DRI +import org.jetbrains.dokka.model.* +import org.jetbrains.dokka.pages.ContentPage +import org.jetbrains.dokka.pages.ContentText +import org.jetbrains.dokka.pages.MemberPageNode +import org.jetbrains.dokka.pages.PackagePageNode +import utils.ParamAttributes +import utils.assertNotNull +import utils.bareSignature +import utils.propertySignature +import kotlin.test.Test +import kotlin.test.assertEquals +import kotlin.test.assertTrue + + +class ContentForAnnotationsTest : BaseAbstractTest() { + + + private val testConfiguration = dokkaConfiguration { + sourceSets { + sourceSet { + sourceRoots = listOf("src/") + analysisPlatform = "jvm" + classpath += jvmStdlibPath!! + } + } + } + + @Test + fun `function with documented annotation`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, + | AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD + |) + |@Retention(AnnotationRetention.SOURCE) + |@MustBeDocumented + |annotation class Fancy + | + | + |@Fancy + |fun function(@Fancy abc: String): String { + | return "Hello, " + abc + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + } + divergentGroup { + divergentInstance { + divergent { + bareSignature( + mapOf("Fancy" to emptySet()), + "", + "", + emptySet(), + "function", + "String", + "abc" to ParamAttributes(mapOf("Fancy" to emptySet()), emptySet(), "String") + ) + } + } + } + + } + } + } + } + + @Test + fun `function with undocumented annotation`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, + | AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FIELD + |) + |@Retention(AnnotationRetention.SOURCE) + |annotation class Fancy + | + |@Fancy + |fun function(@Fancy abc: String): String { + | return "Hello, " + abc + |} + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } + .children.single { it.name == "function" } as ContentPage + page.content.assertNode { + group { + header(1) { +"function" } + } + divergentGroup { + divergentInstance { + divergent { + bareSignature( + emptyMap(), + "", + "", + emptySet(), + "function", + "String", + "abc" to ParamAttributes(emptyMap(), emptySet(), "String") + ) + } + } + } + + } + } + } + } + + @Test + fun `property with undocumented annotation`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |@Suppress + |val property: Int = 6 + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } as PackagePageNode + page.content.assertNode { + propertySignature(emptyMap(), "", "", emptySet(), "val", "property", "Int", "6") + } + } + } + } + + @Test + fun `property with documented annotation`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |@MustBeDocumented + |annotation class Fancy + | + |@Fancy + |val property: Int = 6 + """.trimIndent(), testConfiguration + ) { + pagesTransformationStage = { module -> + val page = module.children.single { it.name == "test" } as PackagePageNode + page.content.assertNode { + propertySignature(mapOf("Fancy" to emptySet()), "", "", emptySet(), "val", "property", "Int", "6") + } + } + } + } + + + @Test + fun `rich documented annotation`() { + testInline( + """ + |/src/main/kotlin/test/source.kt + |package test + | + |@MustBeDocumented + |@Retention(AnnotationRetention.SOURCE) + |@Target(AnnotationTarget.PROPERTY) + |annotation class BugReport( + | val assignedTo: String = "[none]", + | val testCase: KClass = ABC::class, + | val status: Status = Status.UNCONFIRMED, + | val ref: Reference = Reference(value = 1), + | val reportedBy: Array, + | val showStopper: Boolean = false + | val previousReport: BugReport? + |) { + | enum class Status { + | UNCONFIRMED, CONFIRMED, FIXED, NOTABUG + | } + | class ABC + |} + |annotation class Reference(val value: Long) + |annotation class ReferenceReal(val value: Double) + | + | + |@BugReport( + | assignedTo = "me", + | testCase = BugReport.ABC::class, + | status = BugReport.Status.FIXED, + | ref = Reference(value = 2u), + | reportedBy = [Reference(value = 2UL), Reference(value = 4L), + | ReferenceReal(value = 4.9), ReferenceReal(value = 2f)], + | showStopper = true, + | previousReport = null + |) + |val ltint: Int = 5 + """.trimIndent(), testConfiguration + ) { + documentablesCreationStage = { modules -> + + fun expectedAnnotationValue(name: String, value: AnnotationParameterValue) = AnnotationValue(Annotations.Annotation( +