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