8227416: Add a "Table Of Contents" to HTML version of man pages
authorjjg
Wed, 10 Jul 2019 16:23:59 -0700
changeset 55651 45fc36beb0aa
parent 55650 56e8c0a3fe9a
child 55652 2d1acda7555a
8227416: Add a "Table Of Contents" to HTML version of man pages Reviewed-by: mchung
make/Docs.gmk
make/data/docs-resources/resources/jdk-default.css
make/jdk/src/classes/build/tools/fixuppandoc/Main.java
--- a/make/Docs.gmk	Thu Jul 11 08:19:56 2019 +0900
+++ b/make/Docs.gmk	Wed Jul 10 16:23:59 2019 -0700
@@ -626,7 +626,7 @@
             FILTER := $(PANDOC_HTML_MANPAGE_FILTER), \
             CSS := $(GLOBAL_SPECS_DEFAULT_CSS_FILE), \
             REPLACEMENTS := @@VERSION_SHORT@@ => $(VERSION_SHORT), \
-            OPTIONS := -V include-before='$(SPECS_TOP)' -V include-after='$(SPECS_BOTTOM_1)', \
+            OPTIONS := --toc -V include-before='$(SPECS_TOP)' -V include-after='$(SPECS_BOTTOM_1)', \
             POST_PROCESS := $(TOOL_FIXUPPANDOC), \
             EXTRA_DEPS := $(PANDOC_HTML_MANPAGE_FILTER) \
                 $(PANDOC_HTML_MANPAGE_FILTER_JAVASCRIPT), \
--- a/make/data/docs-resources/resources/jdk-default.css	Thu Jul 11 08:19:56 2019 +0900
+++ b/make/data/docs-resources/resources/jdk-default.css	Wed Jul 10 16:23:59 2019 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, 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
@@ -162,3 +162,22 @@
     font-style: italic;
     font-size: 80%;
 }
+
+nav#TOC {
+  border: 1px solid gray;
+  border-radius: 10px;
+  padding: 5px 10px;
+  margin-bottom: 15px;
+}
+
+nav#TOC ul ul {
+    font-size:smaller;
+}
+
+nav#TOC ul ul li {
+    display: inline-block
+}
+
+nav#TOC ul ul li::before {
+    content: " \2022  "
+}
--- a/make/jdk/src/classes/build/tools/fixuppandoc/Main.java	Thu Jul 11 08:19:56 2019 +0900
+++ b/make/jdk/src/classes/build/tools/fixuppandoc/Main.java	Wed Jul 10 16:23:59 2019 -0700
@@ -81,6 +81,10 @@
  *
  * Update the content string, to indicate it has been processed by this program.
  *
+ * <h2>{@code <nav id="TOC">}</h2>
+ *
+ * Set attribute {@code title="Table Of Contents"}
+ *
  */
 public class Main {
     /**
@@ -273,6 +277,11 @@
                     }
                     // <main> is not permitted within these elements
                     allowMain = false;
+                    if (name.equals("nav") && Objects.equals(attrs.get("id"), "TOC")) {
+                        out.write(buffer.toString()
+                                .replaceAll(">$", " title=\"Table Of Contents\">"));
+                        buffer.setLength(0);
+                    }
                     break;
 
                 case "body":