36526
|
1 |
/*
|
|
2 |
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
|
|
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
|
|
7 |
* published by the Free Software Foundation. Oracle designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Oracle in the LICENSE file that accompanied this code.
|
|
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 |
*
|
|
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.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package jdk.javadoc.internal.doclets.formats.html;
|
|
27 |
|
|
28 |
import java.io.*;
|
|
29 |
import java.util.Map;
|
|
30 |
import java.util.Set;
|
|
31 |
|
|
32 |
import javax.lang.model.element.ModuleElement;
|
|
33 |
import javax.lang.model.element.PackageElement;
|
|
34 |
|
|
35 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants;
|
|
36 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle;
|
|
37 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag;
|
|
38 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree;
|
|
39 |
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml;
|
|
40 |
import jdk.javadoc.internal.doclets.toolkit.Content;
|
|
41 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Abstract class to generate the module overview files in
|
|
45 |
* Frame and Non-Frame format. This will be sub-classed to
|
|
46 |
* generate module-overview-frame.html as well as module-overview-summary.html.
|
|
47 |
*
|
|
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 |
*
|
|
53 |
* @author Bhavesh Patel
|
|
54 |
*/
|
|
55 |
public abstract class AbstractModuleIndexWriter extends HtmlDocletWriter {
|
|
56 |
|
|
57 |
/**
|
|
58 |
* Modules to be documented.
|
|
59 |
*/
|
|
60 |
protected Map<ModuleElement, Set<PackageElement>> modules;
|
|
61 |
|
|
62 |
/**
|
|
63 |
* Constructor. Also initializes the modules variable.
|
|
64 |
*
|
|
65 |
* @param configuration The current configuration
|
|
66 |
* @param filename Name of the module index file to be generated.
|
|
67 |
*/
|
|
68 |
public AbstractModuleIndexWriter(ConfigurationImpl configuration,
|
40303
|
69 |
DocPath filename) {
|
36526
|
70 |
super(configuration, filename);
|
|
71 |
modules = configuration.modulePackages;
|
|
72 |
}
|
|
73 |
|
|
74 |
/**
|
|
75 |
* Adds the navigation bar header to the documentation tree.
|
|
76 |
*
|
|
77 |
* @param body the document tree to which the navigation bar header will be added
|
|
78 |
*/
|
|
79 |
protected abstract void addNavigationBarHeader(Content body);
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Adds the navigation bar footer to the documentation tree.
|
|
83 |
*
|
|
84 |
* @param body the document tree to which the navigation bar footer will be added
|
|
85 |
*/
|
|
86 |
protected abstract void addNavigationBarFooter(Content body);
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Adds the overview header to the documentation tree.
|
|
90 |
*
|
|
91 |
* @param body the document tree to which the overview header will be added
|
|
92 |
*/
|
|
93 |
protected abstract void addOverviewHeader(Content body);
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Adds the modules list to the documentation tree.
|
|
97 |
*
|
|
98 |
* @param modules the set of modules
|
|
99 |
* @param text caption for the table
|
|
100 |
* @param tableSummary summary for the table
|
|
101 |
* @param body the document tree to which the modules list will be added
|
|
102 |
*/
|
|
103 |
protected abstract void addModulesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
|
|
104 |
String tableSummary, Content body);
|
|
105 |
|
|
106 |
/**
|
|
107 |
* Adds the module packages list to the documentation tree.
|
|
108 |
*
|
|
109 |
* @param modules the set of modules
|
|
110 |
* @param text caption for the table
|
|
111 |
* @param tableSummary summary for the table
|
|
112 |
* @param body the document tree to which the modules list will be added
|
|
113 |
* @param mdle the module being documented
|
|
114 |
*/
|
|
115 |
protected abstract void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text,
|
|
116 |
String tableSummary, Content body, ModuleElement mdle);
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Generate and prints the contents in the module index file. Call appropriate
|
|
120 |
* methods from the sub-class in order to generate Frame or Non
|
|
121 |
* Frame format.
|
|
122 |
*
|
|
123 |
* @param title the title of the window.
|
|
124 |
* @param includeScript boolean set true if windowtitle script is to be included
|
|
125 |
*/
|
|
126 |
protected void buildModuleIndexFile(String title, boolean includeScript) throws IOException {
|
|
127 |
String windowOverview = configuration.getText(title);
|
|
128 |
Content body = getBody(includeScript, getWindowTitle(windowOverview));
|
|
129 |
addNavigationBarHeader(body);
|
|
130 |
addOverviewHeader(body);
|
|
131 |
addIndex(body);
|
|
132 |
addOverview(body);
|
|
133 |
addNavigationBarFooter(body);
|
|
134 |
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
|
|
135 |
configuration.doctitle), includeScript, body);
|
|
136 |
}
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Generate and prints the contents in the module packages index file. Call appropriate
|
|
140 |
* methods from the sub-class in order to generate Frame or Non
|
|
141 |
* Frame format.
|
|
142 |
*
|
|
143 |
* @param title the title of the window.
|
|
144 |
* @param includeScript boolean set true if windowtitle script is to be included
|
|
145 |
* @param moduleName the name of the module being documented
|
|
146 |
*/
|
|
147 |
protected void buildModulePackagesIndexFile(String title,
|
|
148 |
boolean includeScript, ModuleElement mdle) throws IOException {
|
|
149 |
String windowOverview = configuration.getText(title);
|
|
150 |
Content body = getBody(includeScript, getWindowTitle(windowOverview));
|
|
151 |
addNavigationBarHeader(body);
|
|
152 |
addOverviewHeader(body);
|
|
153 |
addModulePackagesIndex(body, mdle);
|
|
154 |
addOverview(body);
|
|
155 |
addNavigationBarFooter(body);
|
|
156 |
printHtmlDocument(configuration.metakeywords.getOverviewMetaKeywords(title,
|
|
157 |
configuration.doctitle), includeScript, body);
|
|
158 |
}
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Default to no overview, override to add overview.
|
|
162 |
*
|
|
163 |
* @param body the document tree to which the overview will be added
|
|
164 |
*/
|
|
165 |
protected void addOverview(Content body) throws IOException {
|
|
166 |
}
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Adds the frame or non-frame module index to the documentation tree.
|
|
170 |
*
|
|
171 |
* @param body the document tree to which the index will be added
|
|
172 |
*/
|
|
173 |
protected void addIndex(Content body) {
|
|
174 |
addIndexContents(modules, "doclet.Module_Summary",
|
|
175 |
configuration.getText("doclet.Member_Table_Summary",
|
|
176 |
configuration.getText("doclet.Module_Summary"),
|
|
177 |
configuration.getText("doclet.modules")), body);
|
|
178 |
}
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Adds the frame or non-frame module packages index to the documentation tree.
|
|
182 |
*
|
|
183 |
* @param body the document tree to which the index will be added
|
|
184 |
* @param mdle the module being documented
|
|
185 |
*/
|
|
186 |
protected void addModulePackagesIndex(Content body, ModuleElement mdle) {
|
|
187 |
addModulePackagesIndexContents("doclet.Module_Summary",
|
|
188 |
configuration.getText("doclet.Member_Table_Summary",
|
|
189 |
configuration.getText("doclet.Module_Summary"),
|
|
190 |
configuration.getText("doclet.modules")), body, mdle);
|
|
191 |
}
|
|
192 |
|
|
193 |
/**
|
|
194 |
* Adds module index contents. Call appropriate methods from
|
|
195 |
* the sub-classes. Adds it to the body HtmlTree
|
|
196 |
*
|
|
197 |
* @param modules the modules to be documented
|
|
198 |
* @param text string which will be used as the heading
|
|
199 |
* @param tableSummary summary for the table
|
|
200 |
* @param body the document tree to which the index contents will be added
|
|
201 |
*/
|
|
202 |
protected void addIndexContents(Map<ModuleElement, Set<PackageElement>> modules, String text,
|
|
203 |
String tableSummary, Content body) {
|
|
204 |
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
|
|
205 |
? HtmlTree.NAV()
|
|
206 |
: new HtmlTree(HtmlTag.DIV);
|
|
207 |
htmlTree.addStyle(HtmlStyle.indexNav);
|
|
208 |
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
|
209 |
addAllClassesLink(ul);
|
|
210 |
addAllPackagesLink(ul);
|
|
211 |
htmlTree.addContent(ul);
|
|
212 |
body.addContent(htmlTree);
|
|
213 |
addModulesList(modules, text, tableSummary, body);
|
|
214 |
}
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Adds module packages index contents. Call appropriate methods from
|
|
218 |
* the sub-classes. Adds it to the body HtmlTree
|
|
219 |
*
|
|
220 |
* @param text string which will be used as the heading
|
|
221 |
* @param tableSummary summary for the table
|
|
222 |
* @param body the document tree to which the index contents will be added
|
|
223 |
* @param mdle the module being documented
|
|
224 |
*/
|
|
225 |
protected void addModulePackagesIndexContents(String text,
|
|
226 |
String tableSummary, Content body, ModuleElement mdle) {
|
|
227 |
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.NAV))
|
|
228 |
? HtmlTree.NAV()
|
|
229 |
: new HtmlTree(HtmlTag.DIV);
|
|
230 |
htmlTree.addStyle(HtmlStyle.indexNav);
|
|
231 |
HtmlTree ul = new HtmlTree(HtmlTag.UL);
|
|
232 |
addAllClassesLink(ul);
|
|
233 |
addAllPackagesLink(ul);
|
|
234 |
addAllModulesLink(ul);
|
|
235 |
htmlTree.addContent(ul);
|
|
236 |
body.addContent(htmlTree);
|
|
237 |
addModulePackagesList(modules, text, tableSummary, body, mdle);
|
|
238 |
}
|
|
239 |
|
|
240 |
/**
|
|
241 |
* Adds the doctitle to the documentation tree, if it is specified on the command line.
|
|
242 |
*
|
|
243 |
* @param body the document tree to which the title will be added
|
|
244 |
*/
|
|
245 |
protected void addConfigurationTitle(Content body) {
|
|
246 |
if (configuration.doctitle.length() > 0) {
|
|
247 |
Content title = new RawHtml(configuration.doctitle);
|
|
248 |
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
|
|
249 |
HtmlStyle.title, title);
|
|
250 |
Content div = HtmlTree.DIV(HtmlStyle.header, heading);
|
|
251 |
body.addContent(div);
|
|
252 |
}
|
|
253 |
}
|
|
254 |
|
|
255 |
/**
|
|
256 |
* Returns highlighted "Overview", in the navigation bar as this is the
|
|
257 |
* overview page.
|
|
258 |
*
|
|
259 |
* @return a Content object to be added to the documentation tree
|
|
260 |
*/
|
|
261 |
protected Content getNavLinkContents() {
|
40303
|
262 |
Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.overviewLabel);
|
36526
|
263 |
return li;
|
|
264 |
}
|
|
265 |
|
|
266 |
/**
|
|
267 |
* Do nothing. This will be overridden in ModuleIndexFrameWriter.
|
|
268 |
*
|
|
269 |
* @param div the document tree to which the all classes link will be added
|
|
270 |
*/
|
|
271 |
protected void addAllClassesLink(Content div) {
|
|
272 |
}
|
|
273 |
|
|
274 |
/**
|
|
275 |
* Do nothing. This will be overridden in ModuleIndexFrameWriter.
|
|
276 |
*
|
|
277 |
* @param div the document tree to which the all packages link will be added
|
|
278 |
*/
|
|
279 |
protected void addAllPackagesLink(Content div) {
|
|
280 |
}
|
|
281 |
|
|
282 |
/**
|
|
283 |
* Do nothing. This will be overridden in ModulePackageIndexFrameWriter.
|
|
284 |
*
|
|
285 |
* @param div the document tree to which the all modules link will be added
|
|
286 |
*/
|
|
287 |
protected void addAllModulesLink(Content div) {
|
|
288 |
}
|
|
289 |
}
|