author | jjg |
Wed, 20 Feb 2019 16:15:02 -0800 | |
changeset 53863 | d001808c57e8 |
parent 53562 | 0d9dee001667 |
child 53879 | e7cb0348fa1c |
permissions | -rw-r--r-- |
10 | 1 |
/* |
53863
d001808c57e8
8218998: Add metadata to generated API documentation files
jjg
parents:
53562
diff
changeset
|
2 |
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. |
10 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
10 | 24 |
*/ |
25 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.formats.html; |
10 | 27 |
|
28 |
import java.util.*; |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
29 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
30 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
31 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
32 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
34 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
35 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
47846
diff
changeset
|
36 |
import jdk.javadoc.internal.doclets.formats.html.markup.Navigation; |
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
47846
diff
changeset
|
37 |
import jdk.javadoc.internal.doclets.formats.html.markup.Navigation.PageMode; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
38 |
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
39 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
40587 | 40 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
41 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; |
10 | 42 |
|
43 |
/** |
|
44 |
* Abstract class to generate the overview files in |
|
45 |
* Frame and Non-Frame format. This will be sub-classed by to |
|
46 |
* generate overview-frame.html as well as overview-summary.html. |
|
47 |
* |
|
14260 | 48 |
* <p><b>This is NOT part of any supported API. |
49 |
* If you write code that depends on this, you do so at your own risk. |
|
50 |
* This code and its internal interfaces are subject to change or |
|
51 |
* deletion without notice.</b> |
|
52 |
* |
|
10 | 53 |
* @author Atul M Dambalkar |
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
1787
diff
changeset
|
54 |
* @author Bhavesh Patel (Modified) |
10 | 55 |
*/ |
56 |
public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter { |
|
57 |
||
58 |
/** |
|
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
19937
diff
changeset
|
59 |
* A Set of Packages to be documented. |
10 | 60 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
61 |
protected SortedSet<PackageElement> packages; |
10 | 62 |
|
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
47846
diff
changeset
|
63 |
protected Navigation navBar; |
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
47846
diff
changeset
|
64 |
|
10 | 65 |
/** |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
66 |
* Constructor. Also initializes the packages variable. |
10 | 67 |
* |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
68 |
* @param configuration The current configuration |
10 | 69 |
* @param filename Name of the package index file to be generated. |
70 |
*/ |
|
45417 | 71 |
public AbstractPackageIndexWriter(HtmlConfiguration configuration, |
40303 | 72 |
DocPath filename) { |
10 | 73 |
super(configuration, filename); |
74 |
packages = configuration.packages; |
|
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
47846
diff
changeset
|
75 |
this.navBar = new Navigation(null, configuration, fixedNavDiv, PageMode.OVERVIEW, path); |
10 | 76 |
} |
77 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
78 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
79 |
* Adds the navigation bar header to the documentation tree. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
80 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
81 |
* @param header the document tree to which the navigation bar header will be added |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
82 |
*/ |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
83 |
protected abstract void addNavigationBarHeader(Content header); |
10 | 84 |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
85 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
86 |
* Adds the navigation bar footer to the documentation tree. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
87 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
88 |
* @param body the document tree to which the navigation bar footer will be added |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
89 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
90 |
protected abstract void addNavigationBarFooter(Content body); |
10 | 91 |
|
92 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
93 |
* Adds the overview header to the documentation tree. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
94 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
95 |
* @param footer the document tree to which the overview header will be added |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
96 |
*/ |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
97 |
protected abstract void addOverviewHeader(Content footer); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
98 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
99 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
100 |
* Adds the packages list to the documentation tree. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
101 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
102 |
* @param main the document tree to which the packages list will be added |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
103 |
*/ |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
104 |
protected abstract void addPackagesList(Content main); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
105 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
106 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
107 |
* Generate and prints the contents in the package index file. Call appropriate |
10 | 108 |
* methods from the sub-class in order to generate Frame or Non |
109 |
* Frame format. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
110 |
* |
53863
d001808c57e8
8218998: Add metadata to generated API documentation files
jjg
parents:
53562
diff
changeset
|
111 |
* @param title the title of the window |
d001808c57e8
8218998: Add metadata to generated API documentation files
jjg
parents:
53562
diff
changeset
|
112 |
* @param description the content for the description META tag |
10 | 113 |
* @param includeScript boolean set true if windowtitle script is to be included |
40587 | 114 |
* @throws DocFileIOException if there is a problem building the package index file |
10 | 115 |
*/ |
53863
d001808c57e8
8218998: Add metadata to generated API documentation files
jjg
parents:
53562
diff
changeset
|
116 |
protected void buildPackageIndexFile(String title, String description, boolean includeScript) |
d001808c57e8
8218998: Add metadata to generated API documentation files
jjg
parents:
53562
diff
changeset
|
117 |
throws DocFileIOException { |
52644
43efb4ca6d6c
8214139: Remove wrapper methods from {Base,Html}Configuration
jjg
parents:
51797
diff
changeset
|
118 |
String windowOverview = resources.getText(title); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
119 |
Content body = getBody(includeScript, getWindowTitle(windowOverview)); |
53562 | 120 |
Content header = HtmlTree.HEADER(); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
121 |
addNavigationBarHeader(header); |
53562 | 122 |
Content main = HtmlTree.MAIN(); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
123 |
addOverviewHeader(main); |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
124 |
addIndex(header, main); |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
125 |
addOverview(main); |
53562 | 126 |
Content footer = HtmlTree.FOOTER(); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
127 |
addNavigationBarFooter(footer); |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
128 |
body.addContent(header); |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
129 |
body.addContent(main); |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
130 |
body.addContent(footer); |
53863
d001808c57e8
8218998: Add metadata to generated API documentation files
jjg
parents:
53562
diff
changeset
|
131 |
printHtmlDocument( |
d001808c57e8
8218998: Add metadata to generated API documentation files
jjg
parents:
53562
diff
changeset
|
132 |
configuration.metakeywords.getOverviewMetaKeywords(title, configuration.doctitle), |
d001808c57e8
8218998: Add metadata to generated API documentation files
jjg
parents:
53562
diff
changeset
|
133 |
description, includeScript, body); |
10 | 134 |
} |
135 |
||
136 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
137 |
* Default to no overview, override to add overview. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
138 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
139 |
* @param main the document tree to which the overview will be added |
10 | 140 |
*/ |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
141 |
protected void addOverview(Content main) { } |
10 | 142 |
|
143 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
144 |
* Adds the frame or non-frame package index to the documentation tree. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
145 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
146 |
* @param header the document tree to which the navigation links will be added |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
147 |
* @param main the document tree to which the packages list will be added |
10 | 148 |
*/ |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
149 |
protected void addIndex(Content header, Content main) { |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
150 |
addIndexContents(header, main); |
10 | 151 |
} |
152 |
||
153 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
154 |
* Adds package index contents. Call appropriate methods from |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
155 |
* the sub-classes. Adds it to the body HtmlTree |
10 | 156 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
157 |
* @param header the document tree to which navigation links will be added |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
158 |
* @param main the document tree to which the packages list will be added |
10 | 159 |
*/ |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
160 |
protected void addIndexContents(Content header, Content main) { |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
19937
diff
changeset
|
161 |
if (!packages.isEmpty()) { |
53562 | 162 |
HtmlTree htmlTree = HtmlTree.NAV(); |
47846 | 163 |
htmlTree.setStyle(HtmlStyle.indexNav); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
164 |
HtmlTree ul = new HtmlTree(HtmlTag.UL); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
165 |
addAllClassesLink(ul); |
44879
49beafe2faf3
8166306: Broken link for All Packages in java.jnlp module
bpatel
parents:
40587
diff
changeset
|
166 |
if (configuration.showModules && configuration.modules.size() > 1) { |
36526 | 167 |
addAllModulesLink(ul); |
168 |
} |
|
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
169 |
htmlTree.addContent(ul); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
170 |
header.addContent(htmlTree); |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
49551
diff
changeset
|
171 |
addPackagesList(main); |
10 | 172 |
} |
173 |
} |
|
174 |
||
175 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
176 |
* Adds the doctitle to the documentation tree, if it is specified on the command line. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
177 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
178 |
* @param body the document tree to which the title will be added |
10 | 179 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
180 |
protected void addConfigurationTitle(Content body) { |
10 | 181 |
if (configuration.doctitle.length() > 0) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
182 |
Content title = new RawHtml(configuration.doctitle); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
183 |
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
184 |
HtmlStyle.title, title); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
185 |
Content div = HtmlTree.DIV(HtmlStyle.header, heading); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
186 |
body.addContent(div); |
10 | 187 |
} |
188 |
} |
|
189 |
||
190 |
/** |
|
15723
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14357
diff
changeset
|
191 |
* Do nothing. This will be overridden. |
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14357
diff
changeset
|
192 |
* |
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14357
diff
changeset
|
193 |
* @param div the document tree to which the all classes link will be added |
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14357
diff
changeset
|
194 |
*/ |
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14357
diff
changeset
|
195 |
protected void addAllClassesLink(Content div) { |
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14357
diff
changeset
|
196 |
} |
36526 | 197 |
|
198 |
/** |
|
199 |
* Do nothing. This will be overridden. |
|
200 |
* |
|
201 |
* @param div the document tree to which the all modules link will be added |
|
202 |
*/ |
|
203 |
protected void addAllModulesLink(Content div) { |
|
204 |
} |
|
10 | 205 |
} |