author | bpatel |
Thu, 28 Apr 2016 05:10:11 +0000 | |
changeset 37747 | 878801512393 |
parent 36526 | 3b41f1c69604 |
child 37943 | 2efb75c09230 |
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.io.*; |
|
29 |
import java.util.List; |
|
30 |
import java.util.Set; |
|
31 |
||
32 |
import javax.lang.model.element.ModuleElement; |
|
33 |
import javax.lang.model.element.PackageElement; |
|
34 |
||
35 |
import com.sun.source.doctree.DocTree; |
|
36 |
||
37 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; |
|
38 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
|
39 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
|
40 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
|
41 |
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; |
|
42 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
|
43 |
import jdk.javadoc.internal.doclets.toolkit.ModuleSummaryWriter; |
|
44 |
import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; |
|
45 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; |
|
46 |
||
47 |
/** |
|
48 |
* Class to generate file for each module contents in the right-hand |
|
49 |
* frame. This will list all the packages and Class Kinds in the module. A click on any |
|
50 |
* class-kind will update the frame with the clicked class-kind page. A click on any |
|
51 |
* package will update the frame with the clicked module package page. |
|
52 |
* |
|
53 |
* <p><b>This is NOT part of any supported API. |
|
54 |
* If you write code that depends on this, you do so at your own risk. |
|
55 |
* This code and its internal interfaces are subject to change or |
|
56 |
* deletion without notice.</b> |
|
57 |
* |
|
58 |
* @author Bhavesh Patel |
|
59 |
*/ |
|
60 |
public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryWriter { |
|
61 |
||
62 |
/** |
|
63 |
* The prev module name in the alpha-order list. |
|
64 |
*/ |
|
65 |
protected ModuleElement prevModule; |
|
66 |
||
67 |
/** |
|
68 |
* The next module name in the alpha-order list. |
|
69 |
*/ |
|
70 |
protected ModuleElement nextModule; |
|
71 |
||
72 |
/** |
|
73 |
* The module being documented. |
|
74 |
*/ |
|
75 |
protected ModuleElement mdle; |
|
76 |
||
77 |
/** |
|
78 |
* The HTML tree for main tag. |
|
79 |
*/ |
|
80 |
protected HtmlTree mainTree = HtmlTree.MAIN(); |
|
81 |
||
82 |
/** |
|
83 |
* Constructor to construct ModuleWriter object and to generate |
|
84 |
* "moduleName-summary.html" file. |
|
85 |
* |
|
86 |
* @param configuration the configuration of the doclet. |
|
87 |
* @param module Module under consideration. |
|
88 |
* @param prevModule Previous module in the sorted array. |
|
89 |
* @param nextModule Next module in the sorted array. |
|
90 |
*/ |
|
91 |
public ModuleWriterImpl(ConfigurationImpl configuration, |
|
92 |
ModuleElement mdle, ModuleElement prevModule, ModuleElement nextModule) |
|
93 |
throws IOException { |
|
94 |
super(configuration, DocPaths.moduleSummary(mdle)); |
|
95 |
this.prevModule = prevModule; |
|
96 |
this.nextModule = nextModule; |
|
97 |
this.mdle = mdle; |
|
98 |
} |
|
99 |
||
100 |
/** |
|
101 |
* {@inheritDoc} |
|
102 |
*/ |
|
103 |
public Content getModuleHeader(String heading) { |
|
104 |
HtmlTree bodyTree = getBody(true, getWindowTitle(mdle.getQualifiedName().toString())); |
|
105 |
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER)) |
|
106 |
? HtmlTree.HEADER() |
|
107 |
: bodyTree; |
|
108 |
addTop(htmlTree); |
|
109 |
addNavLinks(true, htmlTree); |
|
110 |
if (configuration.allowTag(HtmlTag.HEADER)) { |
|
111 |
bodyTree.addContent(htmlTree); |
|
112 |
} |
|
113 |
HtmlTree div = new HtmlTree(HtmlTag.DIV); |
|
114 |
div.addStyle(HtmlStyle.header); |
|
115 |
Content tHeading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, |
|
116 |
HtmlStyle.title, moduleLabel); |
|
117 |
tHeading.addContent(getSpace()); |
|
118 |
Content moduleHead = new RawHtml(heading); |
|
119 |
tHeading.addContent(moduleHead); |
|
120 |
div.addContent(tHeading); |
|
121 |
if (configuration.allowTag(HtmlTag.MAIN)) { |
|
122 |
mainTree.addContent(div); |
|
123 |
} else { |
|
124 |
bodyTree.addContent(div); |
|
125 |
} |
|
126 |
return bodyTree; |
|
127 |
} |
|
128 |
||
129 |
/** |
|
130 |
* {@inheritDoc} |
|
131 |
*/ |
|
132 |
public Content getContentHeader() { |
|
133 |
HtmlTree div = new HtmlTree(HtmlTag.DIV); |
|
134 |
div.addStyle(HtmlStyle.contentContainer); |
|
135 |
return div; |
|
136 |
} |
|
137 |
||
138 |
/** |
|
139 |
* {@inheritDoc} |
|
140 |
*/ |
|
141 |
public Content getSummaryHeader() { |
|
142 |
HtmlTree li = new HtmlTree(HtmlTag.LI); |
|
143 |
li.addStyle(HtmlStyle.blockList); |
|
144 |
return li; |
|
145 |
} |
|
146 |
||
147 |
/** |
|
148 |
* {@inheritDoc} |
|
149 |
*/ |
|
150 |
public Content getSummaryTree(Content summaryContentTree) { |
|
151 |
HtmlTree ul = HtmlTree.UL(HtmlStyle.blockList, summaryContentTree); |
|
152 |
return ul; |
|
153 |
} |
|
154 |
||
155 |
/** |
|
156 |
* {@inheritDoc} |
|
157 |
*/ |
|
158 |
public void addPackagesSummary(Set<PackageElement> packages, String text, |
|
159 |
String tableSummary, Content summaryContentTree) { |
|
160 |
Content table = (configuration.isOutputHtml5()) |
|
161 |
? HtmlTree.TABLE(HtmlStyle.overviewSummary, getTableCaption(new RawHtml(text))) |
|
162 |
: HtmlTree.TABLE(HtmlStyle.overviewSummary, tableSummary, getTableCaption(new RawHtml(text))); |
|
163 |
table.addContent(getSummaryTableHeader(packageTableHeader, "col")); |
|
164 |
Content tbody = new HtmlTree(HtmlTag.TBODY); |
|
165 |
addPackagesList(packages, tbody); |
|
166 |
table.addContent(tbody); |
|
167 |
summaryContentTree.addContent(table); |
|
168 |
} |
|
169 |
||
170 |
/** |
|
37747
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
171 |
* {@inheritDoc} |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
172 |
*/ |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
173 |
public void addModuleDescription(Content moduleContentTree) { |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
174 |
if (!utils.getBody(mdle).isEmpty()) { |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
175 |
Content tree = configuration.allowTag(HtmlTag.SECTION) ? HtmlTree.SECTION() : moduleContentTree; |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
176 |
tree.addContent(HtmlConstants.START_OF_MODULE_DESCRIPTION); |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
177 |
tree.addContent(getMarkerAnchor(SectionName.MODULE_DESCRIPTION)); |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
178 |
addInlineComment(mdle, tree); |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
179 |
if (configuration.allowTag(HtmlTag.SECTION)) { |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
180 |
moduleContentTree.addContent(tree); |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
181 |
} |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
182 |
} |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
183 |
} |
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
184 |
|
878801512393
8154119: Module summary page should display module description
bpatel
parents:
36526
diff
changeset
|
185 |
/** |
36526 | 186 |
* Adds list of packages in the package summary table. Generate link to each package. |
187 |
* |
|
188 |
* @param packages Packages to which link is to be generated |
|
189 |
* @param tbody the documentation tree to which the list will be added |
|
190 |
*/ |
|
191 |
protected void addPackagesList(Set<PackageElement> packages, Content tbody) { |
|
192 |
boolean altColor = true; |
|
193 |
for (PackageElement pkg : packages) { |
|
194 |
if (pkg != null && !pkg.isUnnamed()) { |
|
195 |
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { |
|
196 |
Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg)); |
|
197 |
Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent); |
|
198 |
HtmlTree tdSummary = new HtmlTree(HtmlTag.TD); |
|
199 |
tdSummary.addStyle(HtmlStyle.colLast); |
|
200 |
addSummaryComment(pkg, tdSummary); |
|
201 |
HtmlTree tr = HtmlTree.TR(tdPackage); |
|
202 |
tr.addContent(tdSummary); |
|
203 |
tr.addStyle(altColor ? HtmlStyle.altColor : HtmlStyle.rowColor); |
|
204 |
tbody.addContent(tr); |
|
205 |
} |
|
206 |
} |
|
207 |
altColor = !altColor; |
|
208 |
} |
|
209 |
} |
|
210 |
||
211 |
/** |
|
212 |
* {@inheritDoc} |
|
213 |
*/ |
|
214 |
public void addModuleContent(Content contentTree, Content moduleContentTree) { |
|
215 |
if (configuration.allowTag(HtmlTag.MAIN)) { |
|
216 |
mainTree.addContent(moduleContentTree); |
|
217 |
contentTree.addContent(mainTree); |
|
218 |
} else { |
|
219 |
contentTree.addContent(moduleContentTree); |
|
220 |
} |
|
221 |
} |
|
222 |
||
223 |
/** |
|
224 |
* {@inheritDoc} |
|
225 |
*/ |
|
226 |
public void addModuleFooter(Content contentTree) { |
|
227 |
Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER)) |
|
228 |
? HtmlTree.FOOTER() |
|
229 |
: contentTree; |
|
230 |
addNavLinks(false, htmlTree); |
|
231 |
addBottom(htmlTree); |
|
232 |
if (configuration.allowTag(HtmlTag.FOOTER)) { |
|
233 |
contentTree.addContent(htmlTree); |
|
234 |
} |
|
235 |
} |
|
236 |
||
237 |
/** |
|
238 |
* {@inheritDoc} |
|
239 |
*/ |
|
240 |
public void printDocument(Content contentTree) throws IOException { |
|
241 |
printHtmlDocument(configuration.metakeywords.getMetaKeywordsForModule(mdle), |
|
242 |
true, contentTree); |
|
243 |
} |
|
244 |
||
245 |
/** |
|
246 |
* Add the module package deprecation information to the documentation tree. |
|
247 |
* |
|
248 |
* @param li the content tree to which the deprecation information will be added |
|
249 |
* @param pkg the PackageDoc that is added |
|
250 |
*/ |
|
251 |
public void addPackageDeprecationInfo(Content li, PackageElement pkg) { |
|
252 |
List<? extends DocTree> deprs; |
|
253 |
if (utils.isDeprecated(pkg)) { |
|
254 |
deprs = utils.getDeprecatedTrees(pkg); |
|
255 |
HtmlTree deprDiv = new HtmlTree(HtmlTag.DIV); |
|
256 |
deprDiv.addStyle(HtmlStyle.deprecatedContent); |
|
257 |
Content deprPhrase = HtmlTree.SPAN(HtmlStyle.deprecatedLabel, deprecatedPhrase); |
|
258 |
deprDiv.addContent(deprPhrase); |
|
259 |
if (!deprs.isEmpty()) { |
|
260 |
CommentHelper ch = utils.getCommentHelper(pkg); |
|
261 |
List<? extends DocTree> commentTags = ch.getDescription(configuration, deprs.get(0)); |
|
262 |
if (!commentTags.isEmpty()) { |
|
263 |
addInlineDeprecatedComment(pkg, deprs.get(0), deprDiv); |
|
264 |
} |
|
265 |
} |
|
266 |
li.addContent(deprDiv); |
|
267 |
} |
|
268 |
} |
|
269 |
||
270 |
/** |
|
271 |
* Get "PREV MODULE" link in the navigation bar. |
|
272 |
* |
|
273 |
* @return a content tree for the previous link |
|
274 |
*/ |
|
275 |
public Content getNavLinkPrevious() { |
|
276 |
Content li; |
|
277 |
if (prevModule == null) { |
|
278 |
li = HtmlTree.LI(prevmoduleLabel); |
|
279 |
} else { |
|
280 |
li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.moduleSummary( |
|
281 |
prevModule)), prevmoduleLabel, "", "")); |
|
282 |
} |
|
283 |
return li; |
|
284 |
} |
|
285 |
||
286 |
/** |
|
287 |
* Get "NEXT MODULE" link in the navigation bar. |
|
288 |
* |
|
289 |
* @return a content tree for the next link |
|
290 |
*/ |
|
291 |
public Content getNavLinkNext() { |
|
292 |
Content li; |
|
293 |
if (nextModule == null) { |
|
294 |
li = HtmlTree.LI(nextmoduleLabel); |
|
295 |
} else { |
|
296 |
li = HtmlTree.LI(getHyperLink(pathToRoot.resolve(DocPaths.moduleSummary( |
|
297 |
nextModule)), nextmoduleLabel, "", "")); |
|
298 |
} |
|
299 |
return li; |
|
300 |
} |
|
301 |
} |