# HG changeset patch # User mchung # Date 1497375858 25200 # Node ID e82401275b00abbfbbcb209b582e175af04e7927 # Parent 9e0c80381e32f84f8c8047e98798e77b80dc3204 8182029: Make the top-level docs index.html to a HTML-level redirect to the API overview page Reviewed-by: alanb, erikj, ihse diff -r 9e0c80381e32 -r e82401275b00 jdk/make/ModuleTools.gmk --- a/jdk/make/ModuleTools.gmk Tue Jun 13 09:13:28 2017 -0700 +++ b/jdk/make/ModuleTools.gmk Tue Jun 13 10:44:18 2017 -0700 @@ -49,7 +49,4 @@ --add-exports java.base/jdk.internal.module=ALL-UNNAMED \ build.tools.jigsaw.AddPackagesAttribute -TOOL_GEN_DOCS_BUNDLE_PAGE := $(BUILD_JAVA) -esa -ea -cp $(TOOLS_CLASSES_DIR) \ - build.tools.docs.GenDocsBundlePage - endif # _MODULE_TOOLS_GMK diff -r 9e0c80381e32 -r e82401275b00 jdk/make/src/classes/build/tools/docs/GenDocsBundlePage.java --- a/jdk/make/src/classes/build/tools/docs/GenDocsBundlePage.java Tue Jun 13 09:13:28 2017 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package build.tools.docs; - -import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintWriter; -import java.lang.module.ModuleDescriptor; -import java.lang.module.ModuleFinder; -import java.lang.module.ModuleReference; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Locale; -import java.util.Map; -import java.util.Properties; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Stream; -import static java.util.stream.Collectors.*; - -/** - * Build tool to generate the docs bundle index page. - */ -public class GenDocsBundlePage { - private static String DOCS_BUNDLE_PAGE = "docs-bundle-page.html"; - private static String MODULE_GROUPS_PROPS = "docs-module-groups.properties"; - - private static String USAGE = - "GenDocsBundlePage --output --title " + - " [--template <template>]"; - - public static void main(String... args) throws IOException { - String title = null; - Path outputfile = null; - Path template = null; - for (int i=0; i < args.length; i++) { - String option = args[i]; - if (option.equals("--output")) { - outputfile = Paths.get(getArgument(args, option, ++i)); - } else if (option.equals("--title")) { - title = getArgument(args, option, ++i); - } else if (option.equals("--template")) { - template = Paths.get(getArgument(args, option, ++i)); - } else if (option.startsWith("-")) { - throw new IllegalArgumentException("Invalid option: " + option); - } - } - - if (outputfile == null) { - System.err.println("ERROR: must specify --output option"); - System.exit(1); - } - if (title == null) { - System.err.println("ERROR: must specify --title option"); - System.exit(1); - } - - try (InputStream is = readTemplate(template); - BufferedReader reader = new BufferedReader(new InputStreamReader(is))) - { - new GenDocsBundlePage(title, outputfile).run(reader); - } - } - - private static String getArgument(String[] args, String option, int index) { - if (index < args.length) { - return args[index]; - } - throw new IllegalArgumentException("Argument must be specified for " + option); - } - - private static InputStream readTemplate(Path template) throws IOException { - if (template != null) { - return Files.newInputStream(template); - } else { - return GenDocsBundlePage.class.getResourceAsStream(DOCS_BUNDLE_PAGE); - } - } - - private static final String HEADER_TITLE = "@HEADER_TITLE@"; - - - final Path outputfile; - final String title; - final Map<String, Set<ModuleDescriptor>> moduleGroups = new HashMap<>(); - GenDocsBundlePage(String title, Path outputfile) throws IOException - { - this.outputfile = outputfile; - this.title = title; - - // read module groups - ModuleFinder finder = ModuleFinder.ofSystem(); - try (InputStream in = GenDocsBundlePage.class.getResourceAsStream(MODULE_GROUPS_PROPS)) { - Properties props = new Properties(); - props.load(in); - for (String key: props.stringPropertyNames()) { - Set<ModuleDescriptor> mods = - Stream.of(props.getProperty(key).split("\\s+")) - .map(String::trim) - .flatMap(mn -> finder.find(mn).stream()) - .map(ModuleReference::descriptor) - .collect(toSet()); - - String name = "@" + key.toUpperCase(Locale.ENGLISH) + "@"; - moduleGroups.put(name, mods); - }; - } - } - - void run(BufferedReader reader) throws IOException { - if (Files.notExists(outputfile.getParent())) { - Files.createDirectories(outputfile.getParent()); - } - try (BufferedWriter bw = Files.newBufferedWriter(outputfile, StandardCharsets.UTF_8); - PrintWriter writer = new PrintWriter(bw)) { - reader.lines().map(this::genOutputLine) - .forEach(writer::println); - } - } - - String genOutputLine(String line) { - if (line.contains(HEADER_TITLE)) { - line = line.replace(HEADER_TITLE, title); - } - int i = line.indexOf('@'); - int j = line.indexOf('@', i+1); - if (i >= 0 && i < j) { - String name = line.substring(i, j+1); - if (moduleGroups.containsKey(name)) { - line = line.replace(name, formatModuleGroup(name)); - } - } - return line; - } - - String toHRef(ModuleDescriptor md) { - String mn = md.name(); - String formattedName; - if (hasExportedAPIs(md)) { - // has exported APIs - formattedName = mn; - } else if (!md.provides().isEmpty()) { - // a provider - formattedName = "<i>" + mn + "</i>"; - } else { - // a tool - formattedName = "<i>" + mn + "</i>"; - } - return String.format("<a href=\"api/%s-summary.html\">%s</a>", - mn, formattedName); - } - - String formatModuleGroup(String groupName) { - StringBuilder sb = new StringBuilder(); - // organize in Java SE, JDK, JavaFX, JCP groups - Set<ModuleDescriptor> modules = moduleGroups.get(groupName); - Arrays.stream(ModuleGroup.values()) - .forEach(g -> { - Set<ModuleDescriptor> mods = modules.stream() - .filter(md -> g.predicate.test(md.name())) - .collect(toSet()); - if (!mods.isEmpty()) { - sb.append("<div class=" + g.cssClass + ">\n"); - // modules with exported API - mods.stream() - .filter(this::hasExportedAPIs) - .sorted(Comparator.comparing(ModuleDescriptor::name)) - .map(this::toHRef) - .forEach(m -> sb.append(m).append("\n")); - - // tools and providers - mods.stream() - .filter(md -> !hasExportedAPIs(md)) - .sorted(Comparator.comparing(ModuleDescriptor::name)) - .map(this::toHRef) - .forEach(m -> sb.append(m).append("\n")); - sb.append("</div>"); - } - }); - return sb.toString(); - } - - private boolean hasExportedAPIs(ModuleDescriptor md) { - if (md.exports().stream().anyMatch(e -> !e.isQualified())) { - return true; - } - // this should check if any indirect exports - // checking requires transitive would be sufficient for JDK modules - if (md.requires().stream() - .map(ModuleDescriptor.Requires::modifiers) - .anyMatch(mods -> mods.contains(ModuleDescriptor.Requires.Modifier.TRANSITIVE))) { - return true; - } - return false; - } - - private static final Set<String> NON_JAVA_SE_MODULES = - Set.of("java.jnlp", "java.smartcardio"); - - /** - * CSS class names are defined in docs-bundle-page.html - */ - enum ModuleGroup { - JAVA_SE("javase", mn -> mn.startsWith("java.") && !NON_JAVA_SE_MODULES.contains(mn)), - JDK("jdk", mn -> mn.startsWith("jdk.")), - JAVAFX("javafx", mn -> mn.startsWith("javafx.")), - NON_JAVA_SE("jcp", NON_JAVA_SE_MODULES::contains); - - final String cssClass; - final Predicate<String> predicate; - ModuleGroup(String cssClass, Predicate<String> predicate) { - this.cssClass = cssClass; - this.predicate = predicate; - } - } -} diff -r 9e0c80381e32 -r e82401275b00 jdk/make/src/classes/build/tools/docs/docs-bundle-page.html --- a/jdk/make/src/classes/build/tools/docs/docs-bundle-page.html Tue Jun 13 09:13:28 2017 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,171 +0,0 @@ -<!-- -Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - -This code is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License version 2 only, as -published by the Free Software Foundation. Oracle designates this -particular file as subject to the "Classpath" exception as provided -by Oracle in the LICENSE file that accompanied this code. - -This code is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -version 2 for more details (a copy is included in the LICENSE file that -accompanied this code). - -You should have received a copy of the GNU General Public License version -2 along with this work; if not, write to the Free Software Foundation, -Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - -Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -or visit www.oracle.com if you need additional information or have any -questions. ---> - -<!DOCTYPE html> -<html lang="en"> -<head> -<title>@HEADER_TITLE@ - - - - - - -

@HEADER_TITLE@

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
JDK Modules
GroupModules
Foundation@JAVA_BASE@
Integration@INTEGRATION_MODULES@
User Interface@UI_MODULES@
Compilation@COMPILER_MODULES@
Scripting@SCRIPTING_MODULES@
Security@SECURITY_MODULES@
Management@MANAGEMENT_MODULES@
Instrumentation@INSTRUMENT_MODULES@
Serviceability@SVC_MODULES@
Packaging@PACKAGING_MODULES@
Incubator@INCUBATOR_MODULES@
Non-Java SE@OTHER_MODULES@
Java EE@JAVA_EE_MODULES@
Aggregator@AGGREGATOR_MODULES@
- -

Key: -

- -

-


-Copyright © 1993, 2017, Oracle and/or its affiliates. All rights reserved.

- - - - - diff -r 9e0c80381e32 -r e82401275b00 jdk/make/src/classes/build/tools/docs/docs-module-groups.properties --- a/jdk/make/src/classes/build/tools/docs/docs-module-groups.properties Tue Jun 13 09:13:28 2017 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -# Module Grouping for the docs bundle page -# - -java_base=\ -java.base - -java_ee_modules=\ -java.activation \ -java.corba \ -java.transaction \ -java.xml.bind \ -java.xml.ws \ -java.xml.ws.annotation \ -jdk.xml.bind \ -jdk.xml.ws - -aggregator_modules=\ -java.se \ -java.se.ee - -security_modules=\ -java.security.jgss \ -java.security.sasl \ -java.xml.crypto \ -jdk.security.auth \ -jdk.security.jgss \ -jdk.crypto.cryptoki \ -jdk.crypto.ec \ -jdk.crypto.mscapi \ -jdk.crypto.ucrypto \ -jdk.policytool - -instrument_modules=\ -java.instrument - -management_modules=\ -java.management \ -java.management.rmi \ -jdk.management \ -jdk.management.agent \ -jdk.management.cmm \ -jdk.management.jfr \ -jdk.management.resource \ -jdk.snmp \ -jdk.jconsole - -integration_modules=\ -java.logging \ -java.naming \ -java.prefs \ -java.rmi \ -java.sql \ -java.sql.rowset \ -java.xml \ -jdk.charsets \ -jdk.localedata \ -jdk.net \ -jdk.sctp \ -jdk.jsobject \ -jdk.httpserver \ -jdk.naming.dns \ -jdk.naming.rmi \ -jdk.xml.dom \ -jdk.zipfs - -ui_modules=\ -java.datatransfer \ -java.desktop \ -javafx.base \ -javafx.controls \ -javafx.fxml \ -javafx.graphics \ -javafx.media \ -javafx.swing \ -javafx.web \ -jdk.accessibility - -svc_modules=\ -jdk.jfr \ -jdk.attach \ -jdk.jcmd \ -jdk.jdi \ -jdk.jdwp.agent \ -jdk.jstatd \ -jdk.hotspot.agent - -packaging_modules=\ -jdk.jartool \ -jdk.jlink \ -jdk.pack \ -jdk.packager.services - -compiler_modules=\ -java.compiler \ -jdk.compiler \ -jdk.javadoc \ -jdk.jdeps \ -jdk.editpad \ -jdk.jshell \ -jdk.rmic - -scripting_modules=\ -java.scripting \ -jdk.dynalink \ -jdk.scripting.nashorn \ -jdk.scripting.nashorn.shell - -other_modules=\ -java.jnlp \ -java.smartcardio - -incubator_modules=\ -jdk.incubator.httpclient -