8215580: Remove support for `--no-module-directories`
authorpmuthuswamy
Tue, 23 Apr 2019 14:13:18 +0530
changeset 54589 3babb3ed24c6
parent 54588 f203906d0dde
child 54594 e0516ee47c36
8215580: Remove support for `--no-module-directories` Reviewed-by: jjg
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java
src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java
test/langtools/jdk/javadoc/doclet/testModuleDirs/TestModuleDirs.java
test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	Tue Apr 23 10:08:52 2019 +0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java	Tue Apr 23 14:13:18 2019 +0530
@@ -347,7 +347,7 @@
                 }
             }
         }
-        docPaths = new DocPaths(utils, useModuleDirectories);
+        docPaths = new DocPaths(utils);
         setCreateOverview();
         setTopFile(docEnv);
         workArounds.initDocLint(doclintOpts.values(), tagletManager.getAllTagletNames());
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Tue Apr 23 10:08:52 2019 +0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java	Tue Apr 23 14:13:18 2019 +0530
@@ -417,7 +417,6 @@
                 .setCharset(configuration.charset)
                 .addKeywords(metakeywords)
                 .setStylesheets(configuration.getMainStylesheet(), configuration.getAdditionalStylesheets())
-                .setUseModuleDirectories(configuration.useModuleDirectories)
                 .setIndex(configuration.createindex, mainBodyScript)
                 .addContent(extraHeadContent);
 
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java	Tue Apr 23 10:08:52 2019 +0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Head.java	Tue Apr 23 14:13:18 2019 +0530
@@ -59,7 +59,6 @@
     private String description;
     private String generator;
     private boolean showTimestamp;
-    private boolean useModuleDirectories;
     private DocFile mainStylesheetFile;
     private List<DocFile> additionalStylesheetFiles = Collections.emptyList();
     private boolean index;
@@ -170,17 +169,6 @@
     }
 
     /**
-     * Sets whether the module directories should be used. This is used to set the JavaScript variable.
-     *
-     * @param useModuleDirectories true if the module directories should be used
-     * @return  this object
-     */
-    public Head setUseModuleDirectories(boolean useModuleDirectories) {
-        this.useModuleDirectories = useModuleDirectories;
-        return this;
-    }
-
-    /**
      * Sets whether or not to include the supporting scripts and stylesheets for the
      * "search" feature.
      * If the feature is enabled, a {@code Script} must be provided into which some
@@ -330,7 +318,6 @@
                 mainBodyScript.append("var pathtoroot = ")
                         .appendStringLiteral(ptrPath + "/")
                         .append(";\n")
-                        .append("var useModuleDirectories = " + useModuleDirectories + ";\n")
                         .append("loadScripts(document, \'script\');");
             }
             addJQueryFile(tree, DocPaths.JSZIP_MIN);
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Tue Apr 23 10:08:52 2019 +0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js	Tue Apr 23 14:13:18 2019 +0530
@@ -47,22 +47,20 @@
 }
 function getURLPrefix(ui) {
     var urlPrefix="";
-    if (useModuleDirectories) {
-        var slash = "/";
-        if (ui.item.category === catModules) {
-            return ui.item.l + slash;
-        } else if (ui.item.category === catPackages && ui.item.m) {
-            return ui.item.m + slash;
-        } else if ((ui.item.category === catTypes && ui.item.p) || ui.item.category === catMembers) {
-            $.each(packageSearchIndex, function(index, item) {
-                if (item.m && ui.item.p == item.l) {
-                    urlPrefix = item.m + slash;
-                }
-            });
-            return urlPrefix;
-        } else {
-            return urlPrefix;
-        }
+    var slash = "/";
+    if (ui.item.category === catModules) {
+        return ui.item.l + slash;
+    } else if (ui.item.category === catPackages && ui.item.m) {
+        return ui.item.m + slash;
+    } else if ((ui.item.category === catTypes && ui.item.p) || ui.item.category === catMembers) {
+        $.each(packageSearchIndex, function(index, item) {
+            if (item.m && ui.item.p == item.l) {
+                urlPrefix = item.m + slash;
+            }
+        });
+        return urlPrefix;
+    } else {
+        return urlPrefix;
     }
     return urlPrefix;
 }
@@ -286,11 +284,7 @@
             if (ui.item.l !== noResult.l) {
                 var url = getURLPrefix(ui);
                 if (ui.item.category === catModules) {
-                    if (useModuleDirectories) {
-                        url += "module-summary.html";
-                    } else {
-                        url = ui.item.l + "-summary.html";
-                    }
+                    url += "module-summary.html";
                 } else if (ui.item.category === catPackages) {
                     if (ui.item.url) {
                         url = ui.item.url;
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java	Tue Apr 23 10:08:52 2019 +0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/BaseConfiguration.java	Tue Apr 23 14:13:18 2019 +0530
@@ -295,12 +295,6 @@
      // A list of pairs containing urls and package list
     private final List<Pair<String, String>> linkOfflineList = new ArrayList<>();
 
-    /**
-     * Flag to enable/disable use of module directories when generating docs for modules
-     * Default: on (module directories are enabled).
-     */
-    public boolean useModuleDirectories = true;
-
     public boolean dumpOnError = false;
 
     private List<Pair<String, String>> groupPairs;
@@ -748,13 +742,6 @@
                         showTaglets = true;
                         return true;
                     }
-                },
-                new XOption(resources, "--no-module-directories") {
-                    @Override
-                    public boolean process(String option, List<String> args) {
-                        useModuleDirectories = false;
-                        return true;
-                    }
                 }
         };
         Set<Doclet.Option> set = new TreeSet<>();
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Tue Apr 23 10:08:52 2019 +0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocPaths.java	Tue Apr 23 14:13:18 2019 +0530
@@ -39,14 +39,12 @@
  *
  */
 public class DocPaths {
-    private final boolean useModuleDirectories;
     private final String moduleSeparator;
     private final Utils utils;
 
-    public DocPaths(Utils utils, boolean useModuleDirectories) {
+    public DocPaths(Utils utils) {
         this.utils = utils;
-        this.useModuleDirectories = useModuleDirectories;
-        moduleSeparator = useModuleDirectories ? "/module-" : "-";
+        moduleSeparator = "/module-";
     }
 
     public static final DocPath DOT_DOT = DocPath.create("..");
@@ -239,12 +237,8 @@
         }
 
         DocPath pkgPath = DocPath.create(pkgElement.getQualifiedName().toString().replace('.', '/'));
-        if (useModuleDirectories) {
-            ModuleElement mdle = (ModuleElement) pkgElement.getEnclosingElement();
-            return forModule(mdle).resolve(pkgPath);
-        } else {
-            return pkgPath;
-        }
+        ModuleElement mdle = (ModuleElement) pkgElement.getEnclosingElement();
+        return forModule(mdle).resolve(pkgPath);
     }
 
     /**
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java	Tue Apr 23 10:08:52 2019 +0800
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java	Tue Apr 23 14:13:18 2019 +0530
@@ -402,7 +402,7 @@
                         moduleItems.put(moduleName, item);
                     } else {
                         DocPath pkgPath = DocPath.create(elemname.replace('.', '/'));
-                        if (configuration.useModuleDirectories && moduleName != null) {
+                        if (moduleName != null) {
                             elempath = elempath.resolve(DocPath.create(moduleName).resolve(pkgPath));
                         } else {
                             elempath = elempath.resolve(pkgPath);
--- a/test/langtools/jdk/javadoc/doclet/testModuleDirs/TestModuleDirs.java	Tue Apr 23 10:08:52 2019 +0800
+++ b/test/langtools/jdk/javadoc/doclet/testModuleDirs/TestModuleDirs.java	Tue Apr 23 14:13:18 2019 +0530
@@ -23,7 +23,7 @@
 
 /*
  * @test
- * @bug 8195795 8201396 8196202
+ * @bug 8195795 8201396 8196202 8215582
  * @summary test the use of module directories in output,
  *          and the --no-module-directories option
  * @modules jdk.javadoc/jdk.javadoc.internal.api
@@ -76,32 +76,12 @@
                 .classes("package pa; public class A {}")
                 .exports("pa")
                 .write(src);
-        new ModuleBuilder(tb, "mb")
-                .classes("package pb; public class B {}")
-                .exports("pb")
-                .write(src);
 
         javadoc("-d", base.resolve("api").toString(),
-                "-quiet",
                 "--module-source-path", src.toString(),
                 "--no-module-directories",
                 "--module", "ma,mb");
-
-        checkExit(Exit.OK);
-        checkFiles(true,
-                "ma-summary.html",
-                "pa/package-summary.html");
-        checkFiles(false,
-                "ma/module-summary.html",
-                "ma/pa/package-summary.html");
-        checkOutput("ma-summary.html", false,
-                "<ul class=\"navList\" id=\"allclasses_navbar_top\">\n"
-                + "<li><a href=\"allclasses-noframe.html\">All&nbsp;Classes</a></li>\n"
-                + "</ul>\n");
-        checkOutput("pa/package-summary.html", true,
-                "<li><a href=\"../deprecated-list.html\">Deprecated</a></li>\n"
-                + "<li><a href=\"../index-all.html\">Index</a></li>");
-
+        checkExit(Exit.ERROR);
     }
 
     @Test
--- a/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java	Tue Apr 23 10:08:52 2019 +0800
+++ b/test/langtools/jdk/javadoc/doclet/testSearch/TestSearch.java	Tue Apr 23 14:13:18 2019 +0530
@@ -291,22 +291,8 @@
     }
 
     @Test
-    public void testNoModuleDirectories() {
-        javadoc("-d", "out-noMdlDir",
-                "--no-module-directories",
-                "-Xdoclint:none",
-                "-sourcepath", testSrc,
-                "-use",
-                "pkg", "pkg1", "pkg2", "pkg3");
-        checkExit(Exit.OK);
-        checkSearchOutput(true, false);
-        checkSearchJS();
-    }
-
-    @Test
     public void testURLEncoding() {
         javadoc("-d", "out-encode-html5",
-                "--no-module-directories",
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
@@ -320,7 +306,6 @@
     public void testJapaneseLocale() {
         javadoc("-locale", "ja_JP",
                 "-d", "out-jp",
-                "--no-module-directories",
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
@@ -339,7 +324,6 @@
     public void testChineseLocale() {
         javadoc("-locale", "zh_CN",
                 "-d", "out-cn",
-                "--no-module-directories",
                 "-Xdoclint:none",
                 "-sourcepath", testSrc,
                 "-use",
@@ -396,7 +380,6 @@
                 "<script type=\"text/javascript\" src=\"script-dir/jquery-migrate-3.0.1.js\"></script>\n",
                 "<script type=\"text/javascript\" src=\"script-dir/jquery-ui.js\"></script>",
                 "var pathtoroot = \"./\";\n"
-                + "var useModuleDirectories = " + moduleDirectoriesVar + ";\n"
                 + "loadScripts(document, 'script');",
                 "<ul class=\"navListSearch\">\n",
                 "<li><label for=\"search\">SEARCH:</label>\n"
@@ -632,22 +615,20 @@
                 + "    });",
                 "function getURLPrefix(ui) {\n"
                 + "    var urlPrefix=\"\";\n"
-                + "    if (useModuleDirectories) {\n"
-                + "        var slash = \"/\";\n"
-                + "        if (ui.item.category === catModules) {\n"
-                + "            return ui.item.l + slash;\n"
-                + "        } else if (ui.item.category === catPackages && ui.item.m) {\n"
-                + "            return ui.item.m + slash;\n"
-                + "        } else if ((ui.item.category === catTypes && ui.item.p) || ui.item.category === catMembers) {\n"
-                + "            $.each(packageSearchIndex, function(index, item) {\n"
-                + "                if (item.m && ui.item.p == item.l) {\n"
-                + "                    urlPrefix = item.m + slash;\n"
-                + "                }\n"
-                + "            });\n"
-                + "            return urlPrefix;\n"
-                + "        } else {\n"
-                + "            return urlPrefix;\n"
-                + "        }\n"
+                + "    var slash = \"/\";\n"
+                + "    if (ui.item.category === catModules) {\n"
+                + "        return ui.item.l + slash;\n"
+                + "    } else if (ui.item.category === catPackages && ui.item.m) {\n"
+                + "        return ui.item.m + slash;\n"
+                + "    } else if ((ui.item.category === catTypes && ui.item.p) || ui.item.category === catMembers) {\n"
+                + "        $.each(packageSearchIndex, function(index, item) {\n"
+                + "            if (item.m && ui.item.p == item.l) {\n"
+                + "                urlPrefix = item.m + slash;\n"
+                + "            }\n"
+                + "        });\n"
+                + "        return urlPrefix;\n"
+                + "    } else {\n"
+                + "        return urlPrefix;\n"
                 + "    }\n"
                 + "    return urlPrefix;\n"
                 + "}",