# HG changeset patch # User bobv # Date 1515091279 18000 # Node ID b39894f95ab88f59f6067c7a020c2d31e6fce0ae # Parent efb9f4c91bdeca56543891bfb90c427c21708b7f# Parent dd3b97564ed705317355ed4d869436af4644ae12 Merge diff -r efb9f4c91bde -r b39894f95ab8 src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Wed Dec 27 11:31:09 2017 +0100 +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java Thu Jan 04 13:41:19 2018 -0500 @@ -820,11 +820,14 @@ Content summary = new ContentBuilder(); if (display(usesTrees)) { description = usesTrees.get(t); - if (description != null) { - summary.addContent(description); + if (description != null && !description.isEmpty()) { + summary.addContent(HtmlTree.DIV(HtmlStyle.block, description)); + } else { + addSummaryComment(t, summary); } + } else { + summary.addContent(Contents.SPACE); } - addSummaryComment(t, summary); table.addRow(typeLinkContent, summary); } } @@ -847,11 +850,12 @@ Content desc = new ContentBuilder(); if (display(providesTrees)) { description = providesTrees.get(srv); - if (description != null) { - desc.addContent(description); + desc.addContent((description != null && !description.isEmpty()) + ? HtmlTree.DIV(HtmlStyle.block, description) + : Contents.SPACE); + } else { + desc.addContent(Contents.SPACE); } - } - addSummaryComment(srv, desc); // Only display the implementation details in the "all" mode. if (moduleMode == ModuleMode.ALL && !implSet.isEmpty()) { desc.addContent(new HtmlTree(HtmlTag.BR)); diff -r efb9f4c91bde -r b39894f95ab8 test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java --- a/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java Wed Dec 27 11:31:09 2017 +0100 +++ b/test/langtools/jdk/javadoc/doclet/testModules/TestModuleServices.java Thu Jan 04 13:41:19 2018 -0500 @@ -23,7 +23,7 @@ /* * @test - * @bug 8178067 + * @bug 8178067 8192007 * @summary tests the module's services, such as provides and uses * @modules jdk.javadoc/jdk.javadoc.internal.api * jdk.javadoc/jdk.javadoc.internal.tool @@ -34,6 +34,7 @@ * @run main TestModuleServices */ +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -52,6 +53,106 @@ } @Test + public void checkModuleServicesDescription(Path base) throws Exception { + Path src = Files.createDirectories(base.resolve("src")); + ModuleBuilder mb = new ModuleBuilder(tb, "moduleService") + .comment("This module exports a package containing the declaration of a service type.") + .exports("pkgService") + .classes("/**A Package that has a service.*/ package pkgService;") + .classes("package pkgService; /**A service Interface for service providers.*/ " + + "public interface Service {\n" + + " /**\n" + + " * A test method for the service.\n" + + " */\n" + + " void testMethod1();\n" + + " /**\n" + + " * Another test method for the service.\n" + + " */\n" + + " void testMethod2();\n" + + "}"); + mb.write(src); + mb = new ModuleBuilder(tb, "moduleServiceProvider") + .comment("This module provides an implementation of a service.\n" + + "@provides pkgService.Service Provides a service whose name is ServiceProvider.") + .requires("moduleService") + .provides("pkgService.Service", "pkgServiceProvider.ServiceProvider") + .classes("/**A Package that has a service provider.*/ package pkgServiceProvider;") + .classes("package pkgServiceProvider;\n" + + "public class ServiceProvider implements pkgService.Service {\n" + + " /**\n" + + " * {@inheritDoc}\n" + + " */\n" + + " public void testMethod1() {}\n" + + " /**\n" + + " * This is an internal implementation so the documentation will not be seen.\n" + + " */\n" + + " public void testMethod2() {}\n" + + "}"); + mb.write(src); + mb = new ModuleBuilder(tb, "moduleServiceUser") + .comment("This module uses a service defined in another module.\n" + + "@uses pkgService.Service If no other provider is found, a default internal implementation will be used.") + .requires("moduleService") + .uses("pkgService.Service") + .classes("/**A Package that has a service user.*/ package pkgServiceUser;") + .classes("package pkgServiceUser;\n" + + "/**\n" + + " * A service user class.\n" + + " */\n" + + "public class ServiceUser {\n" + + "}"); + mb.write(src); + mb = new ModuleBuilder(tb, "moduleServiceUserNoDescription") + .comment("This is another module that uses a service defined in another module.\n" + + "@uses pkgService.Service") + .requires("moduleService") + .uses("pkgService.Service") + .classes("/**A Package that has a service user with no description.*/ package pkgServiceUserNoDescription;") + .classes("package pkgServiceUserNoDescription;\n" + + "/**\n" + + " * A service user class.\n" + + " */\n" + + "public class ServiceUserNoDescription {\n" + + "}"); + mb.write(src); + + javadoc("-d", base.resolve("out").toString(), + "-quiet", "-noindex", + "--module-source-path", src.toString(), + "--module", "moduleService,moduleServiceProvider,moduleServiceUser,moduleServiceUserNoDescription", + "pkgService", "moduleServiceProvider/pkgServiceProvider", "moduleServiceUser/pkgServiceUser", + "moduleServiceUserNoDescription/pkgServiceUserNoDescription"); + checkExit(Exit.OK); + + checkOutput("moduleServiceProvider-summary.html", true, + "