author | bpatel |
Fri, 20 Nov 2015 20:55:07 +0000 | |
changeset 33920 | bd731341c405 |
parent 25874 | 83c19f00452c |
child 38617 | d93a7f64e231 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
2 |
* Copyright (c) 2003, 2014, 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 |
||
26 |
package com.sun.tools.doclets.formats.html; |
|
27 |
||
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
28 |
import com.sun.javadoc.*; |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
29 |
import com.sun.tools.doclets.formats.html.markup.ContentBuilder; |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
30 |
import com.sun.tools.doclets.formats.html.markup.HtmlStyle; |
17565
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
31 |
import com.sun.tools.doclets.formats.html.markup.HtmlTree; |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
32 |
import com.sun.tools.doclets.formats.html.markup.RawHtml; |
17565
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
33 |
import com.sun.tools.doclets.formats.html.markup.StringContent; |
10 | 34 |
import com.sun.tools.doclets.internal.toolkit.*; |
35 |
import com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder; |
|
36 |
import com.sun.tools.doclets.internal.toolkit.taglets.*; |
|
37 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
38 |
||
39 |
/** |
|
40 |
* The taglet writer that writes HTML. |
|
41 |
* |
|
14260 | 42 |
* <p><b>This is NOT part of any supported API. |
43 |
* If you write code that depends on this, you do so at your own risk. |
|
44 |
* This code and its internal interfaces are subject to change or |
|
45 |
* deletion without notice.</b> |
|
46 |
* |
|
10 | 47 |
* @since 1.5 |
48 |
* @author Jamie Ho |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
49 |
* @author Bhavesh Patel (Modified) |
10 | 50 |
*/ |
51 |
||
52 |
public class TagletWriterImpl extends TagletWriter { |
|
53 |
||
14542 | 54 |
private final HtmlDocletWriter htmlWriter; |
55 |
private final ConfigurationImpl configuration; |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
56 |
private final Utils utils; |
10 | 57 |
|
58 |
public TagletWriterImpl(HtmlDocletWriter htmlWriter, boolean isFirstSentence) { |
|
14542 | 59 |
super(isFirstSentence); |
10 | 60 |
this.htmlWriter = htmlWriter; |
14542 | 61 |
configuration = htmlWriter.configuration; |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
62 |
this.utils = configuration.utils; |
10 | 63 |
} |
64 |
||
65 |
/** |
|
66 |
* {@inheritDoc} |
|
67 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
68 |
public Content getOutputInstance() { |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
69 |
return new ContentBuilder(); |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
70 |
} |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
71 |
|
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
72 |
/** |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
73 |
* {@inheritDoc} |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
74 |
*/ |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
75 |
protected Content codeTagOutput(Tag tag) { |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
76 |
Content result = HtmlTree.CODE(new StringContent(utils.normalizeNewlines(tag.text()))); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
77 |
return result; |
10 | 78 |
} |
79 |
||
33920 | 80 |
protected Content indexTagOutput(Tag tag) { |
81 |
String text = tag.text(); |
|
82 |
String tagText = ""; |
|
83 |
String desc = ""; |
|
84 |
if (text.isEmpty() || text.trim().isEmpty()) { |
|
85 |
configuration.message.warning(tag.position(), "doclet.invalid_usage_of_tag", tag.name()); |
|
86 |
} else { |
|
87 |
int len = text.length(); |
|
88 |
int tagTextEnd = 0; |
|
89 |
int descstart = 0; |
|
90 |
int start = 0; |
|
91 |
Character term = ' '; |
|
92 |
int cp = text.codePointAt(0); |
|
93 |
if (cp == '"') { |
|
94 |
term = '"'; |
|
95 |
start++; |
|
96 |
} |
|
97 |
for (int i = start; i < len; i += Character.charCount(cp)) { |
|
98 |
cp = text.codePointAt(i); |
|
99 |
if (cp == term) { |
|
100 |
tagTextEnd = i; |
|
101 |
break; |
|
102 |
} |
|
103 |
} |
|
104 |
if (tagTextEnd < len - 1 && tagTextEnd != 0) { |
|
105 |
descstart = tagTextEnd + 1; |
|
106 |
} |
|
107 |
String desctext = ""; |
|
108 |
if (descstart > 0) { |
|
109 |
tagText = text.substring(start, tagTextEnd).trim(); |
|
110 |
desctext = text.substring(descstart, len).trim(); |
|
111 |
// strip off the white space which can be between tag description and the |
|
112 |
// actual label. |
|
113 |
for (int i = 0; i < desctext.length(); i++) { |
|
114 |
char ch2 = desctext.charAt(i); |
|
115 |
if (!(ch2 == ' ' || ch2 == '\t' || ch2 == '\n')) { |
|
116 |
desc = desctext.substring(i); |
|
117 |
break; |
|
118 |
} |
|
119 |
} |
|
120 |
} else { |
|
121 |
if (term == '"') { |
|
122 |
if (tagTextEnd == 0) { |
|
123 |
// If unclosed quote, print out a warning and ignore the invalid tag text. |
|
124 |
configuration.message.warning(tag.position(), "doclet.invalid_usage_of_tag", tag.name()); |
|
125 |
tagText = ""; |
|
126 |
} else { |
|
127 |
tagText = text.substring(start, tagTextEnd).trim(); |
|
128 |
} |
|
129 |
} else { |
|
130 |
tagText = text.trim(); |
|
131 |
} |
|
132 |
desc = ""; |
|
133 |
} |
|
134 |
} |
|
135 |
String anchorName = htmlWriter.getName(tagText); |
|
136 |
Content result = HtmlTree.A_ID(anchorName, new StringContent(tagText)); |
|
137 |
if (configuration.createindex && !tagText.isEmpty()) { |
|
138 |
SearchIndexItem si = new SearchIndexItem(); |
|
139 |
si.setLabel(tagText); |
|
140 |
si.setDescription(desc); |
|
141 |
if (tag.holder() instanceof ProgramElementDoc) { |
|
142 |
if (tag.holder() instanceof MemberDoc) { |
|
143 |
si.setUrl(DocPath.forClass(((MemberDoc) tag.holder()).containingClass()).getPath() |
|
144 |
+ "#" + anchorName); |
|
145 |
si.setHolder(((MemberDoc) tag.holder()).qualifiedName()); |
|
146 |
} else { |
|
147 |
si.setUrl(DocPath.forClass((ClassDoc) tag.holder()).getPath() + "#" + anchorName); |
|
148 |
si.setHolder(((ClassDoc) tag.holder()).qualifiedName()); |
|
149 |
} |
|
150 |
} else if (tag.holder() instanceof PackageDoc) { |
|
151 |
si.setUrl(DocPath.forPackage((PackageDoc) tag.holder()).getPath() |
|
152 |
+ "/" + DocPaths.PACKAGE_SUMMARY.getPath() + "#" + anchorName); |
|
153 |
si.setHolder(((PackageDoc) tag.holder()).name()); |
|
154 |
} |
|
155 |
si.setCategory(configuration.getResource("doclet.SearchTags").toString()); |
|
156 |
configuration.tagSearchIndex.add(si); |
|
157 |
} |
|
158 |
return result; |
|
159 |
} |
|
160 |
||
10 | 161 |
/** |
162 |
* {@inheritDoc} |
|
163 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
164 |
public Content getDocRootOutput() { |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
165 |
String path; |
22005
4270ada5dcd1
8025416: doclet not substituting {@docRoot} in some cases
bpatel
parents:
21478
diff
changeset
|
166 |
if (htmlWriter.pathToRoot.isEmpty()) |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
167 |
path = "."; |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
168 |
else |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
169 |
path = htmlWriter.pathToRoot.getPath(); |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
170 |
return new StringContent(path); |
17565
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
171 |
} |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
172 |
|
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
173 |
/** |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
174 |
* {@inheritDoc} |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
175 |
*/ |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
176 |
public Content deprecatedTagOutput(Doc doc) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
177 |
ContentBuilder result = new ContentBuilder(); |
10 | 178 |
Tag[] deprs = doc.tags("deprecated"); |
179 |
if (doc instanceof ClassDoc) { |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
180 |
if (utils.isDeprecated((ProgramElementDoc) doc)) { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
181 |
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
182 |
new StringContent(configuration.getText("doclet.Deprecated")))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
183 |
result.addContent(RawHtml.nbsp); |
10 | 184 |
if (deprs.length > 0) { |
185 |
Tag[] commentTags = deprs[0].inlineTags(); |
|
186 |
if (commentTags.length > 0) { |
|
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
187 |
result.addContent(commentTagsToOutput(null, doc, |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
188 |
deprs[0].inlineTags(), false) |
10 | 189 |
); |
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
} else { |
|
194 |
MemberDoc member = (MemberDoc) doc; |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
195 |
if (utils.isDeprecated((ProgramElementDoc) doc)) { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
196 |
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
197 |
new StringContent(configuration.getText("doclet.Deprecated")))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
198 |
result.addContent(RawHtml.nbsp); |
10 | 199 |
if (deprs.length > 0) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
200 |
Content body = commentTagsToOutput(null, doc, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
201 |
deprs[0].inlineTags(), false); |
21023
1192bdc59d82
8026370: javadoc creates empty <span class="italic"></span>
bpatel
parents:
19253
diff
changeset
|
202 |
if (!body.isEmpty()) |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
203 |
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecationComment, body)); |
10 | 204 |
} |
205 |
} else { |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
206 |
if (utils.isDeprecated(member.containingClass())) { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
207 |
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
208 |
new StringContent(configuration.getText("doclet.Deprecated")))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
209 |
result.addContent(RawHtml.nbsp); |
10 | 210 |
} |
211 |
} |
|
212 |
} |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
213 |
return result; |
10 | 214 |
} |
215 |
||
216 |
/** |
|
217 |
* {@inheritDoc} |
|
218 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
219 |
protected Content literalTagOutput(Tag tag) { |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
220 |
Content result = new StringContent(utils.normalizeNewlines(tag.text())); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
221 |
return result; |
17565
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
222 |
} |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
223 |
|
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
224 |
/** |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
225 |
* {@inheritDoc} |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
226 |
*/ |
10 | 227 |
public MessageRetriever getMsgRetriever() { |
14542 | 228 |
return configuration.message; |
10 | 229 |
} |
230 |
||
231 |
/** |
|
232 |
* {@inheritDoc} |
|
233 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
234 |
public Content getParamHeader(String header) { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
235 |
HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.paramLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
236 |
new StringContent(header))); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
237 |
return result; |
10 | 238 |
} |
239 |
||
240 |
/** |
|
241 |
* {@inheritDoc} |
|
242 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
243 |
public Content paramTagOutput(ParamTag paramTag, String paramName) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
244 |
ContentBuilder body = new ContentBuilder(); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
245 |
body.addContent(HtmlTree.CODE(new RawHtml(paramName))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
246 |
body.addContent(" - "); |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
247 |
body.addContent(htmlWriter.commentTagsToContent(paramTag, null, paramTag.inlineTags(), false)); |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
248 |
HtmlTree result = HtmlTree.DD(body); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
249 |
return result; |
10 | 250 |
} |
251 |
||
252 |
/** |
|
253 |
* {@inheritDoc} |
|
254 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
255 |
public Content propertyTagOutput(Tag tag, String prefix) { |
17572 | 256 |
Content body = new ContentBuilder(); |
257 |
body.addContent(new RawHtml(prefix)); |
|
258 |
body.addContent(" "); |
|
259 |
body.addContent(HtmlTree.CODE(new RawHtml(tag.text()))); |
|
260 |
body.addContent("."); |
|
261 |
Content result = HtmlTree.P(body); |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
262 |
return result; |
17572 | 263 |
} |
264 |
||
265 |
/** |
|
266 |
* {@inheritDoc} |
|
267 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
268 |
public Content returnTagOutput(Tag returnTag) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
269 |
ContentBuilder result = new ContentBuilder(); |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
270 |
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.returnLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
271 |
new StringContent(configuration.getText("doclet.Returns"))))); |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
272 |
result.addContent(HtmlTree.DD(htmlWriter.commentTagsToContent( |
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
273 |
returnTag, null, returnTag.inlineTags(), false))); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
274 |
return result; |
10 | 275 |
} |
276 |
||
277 |
/** |
|
278 |
* {@inheritDoc} |
|
279 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
280 |
public Content seeTagOutput(Doc holder, SeeTag[] seeTags) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
281 |
ContentBuilder body = new ContentBuilder(); |
10 | 282 |
if (seeTags.length > 0) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22005
diff
changeset
|
283 |
for (SeeTag seeTag : seeTags) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
284 |
appendSeparatorIfNotEmpty(body); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22005
diff
changeset
|
285 |
body.addContent(htmlWriter.seeTagToContent(seeTag)); |
10 | 286 |
} |
287 |
} |
|
288 |
if (holder.isField() && ((FieldDoc)holder).constantValue() != null && |
|
289 |
htmlWriter instanceof ClassWriterImpl) { |
|
290 |
//Automatically add link to constant values page for constant fields. |
|
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
291 |
appendSeparatorIfNotEmpty(body); |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
292 |
DocPath constantsPath = |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
293 |
htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES); |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
294 |
String whichConstant = |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
295 |
((ClassWriterImpl) htmlWriter).getClassDoc().qualifiedName() + "." + ((FieldDoc) holder).name(); |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
296 |
DocLink link = constantsPath.fragment(whichConstant); |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
297 |
body.addContent(htmlWriter.getHyperLink(link, |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
298 |
new StringContent(configuration.getText("doclet.Constants_Summary")))); |
10 | 299 |
} |
300 |
if (holder.isClass() && ((ClassDoc)holder).isSerializable()) { |
|
301 |
//Automatically add link to serialized form page for serializable classes. |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1787
diff
changeset
|
302 |
if ((SerializedFormBuilder.serialInclude(holder) && |
10 | 303 |
SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
304 |
appendSeparatorIfNotEmpty(body); |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
305 |
DocPath serialPath = htmlWriter.pathToRoot.resolve(DocPaths.SERIALIZED_FORM); |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
306 |
DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName()); |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
307 |
body.addContent(htmlWriter.getHyperLink(link, |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
308 |
new StringContent(configuration.getText("doclet.Serialized_Form")))); |
10 | 309 |
} |
310 |
} |
|
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
311 |
if (body.isEmpty()) |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
312 |
return body; |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
313 |
|
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
314 |
ContentBuilder result = new ContentBuilder(); |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
315 |
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
316 |
new StringContent(configuration.getText("doclet.See_Also"))))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
317 |
result.addContent(HtmlTree.DD(body)); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
318 |
return result; |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
319 |
|
10 | 320 |
} |
321 |
||
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
322 |
private void appendSeparatorIfNotEmpty(ContentBuilder body) { |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
323 |
if (!body.isEmpty()) { |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
324 |
body.addContent(", "); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
325 |
body.addContent(DocletConstants.NL); |
10 | 326 |
} |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
327 |
} |
10 | 328 |
|
329 |
/** |
|
330 |
* {@inheritDoc} |
|
331 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
332 |
public Content simpleTagOutput(Tag[] simpleTags, String header) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
333 |
ContentBuilder result = new ContentBuilder(); |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
334 |
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header)))); |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
335 |
ContentBuilder body = new ContentBuilder(); |
10 | 336 |
for (int i = 0; i < simpleTags.length; i++) { |
337 |
if (i > 0) { |
|
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
338 |
body.addContent(", "); |
10 | 339 |
} |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
340 |
body.addContent(htmlWriter.commentTagsToContent( |
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
341 |
simpleTags[i], null, simpleTags[i].inlineTags(), false)); |
10 | 342 |
} |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
343 |
result.addContent(HtmlTree.DD(body)); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
344 |
return result; |
10 | 345 |
} |
346 |
||
347 |
/** |
|
348 |
* {@inheritDoc} |
|
349 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
350 |
public Content simpleTagOutput(Tag simpleTag, String header) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
351 |
ContentBuilder result = new ContentBuilder(); |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
352 |
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.simpleTagLabel, new RawHtml(header)))); |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
353 |
Content body = htmlWriter.commentTagsToContent( |
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
354 |
simpleTag, null, simpleTag.inlineTags(), false); |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
355 |
result.addContent(HtmlTree.DD(body)); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
356 |
return result; |
10 | 357 |
} |
358 |
||
359 |
/** |
|
360 |
* {@inheritDoc} |
|
361 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
362 |
public Content getThrowsHeader() { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
363 |
HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.throwsLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
364 |
new StringContent(configuration.getText("doclet.Throws")))); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
365 |
return result; |
10 | 366 |
} |
367 |
||
368 |
/** |
|
369 |
* {@inheritDoc} |
|
370 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
371 |
public Content throwsTagOutput(ThrowsTag throwsTag) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
372 |
ContentBuilder body = new ContentBuilder(); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
373 |
Content excName = (throwsTag.exceptionType() == null) ? |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
374 |
new RawHtml(throwsTag.exceptionName()) : |
17558
eee4ccf66cfd
8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents:
14542
diff
changeset
|
375 |
htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
376 |
throwsTag.exceptionType())); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
377 |
body.addContent(HtmlTree.CODE(excName)); |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
378 |
Content desc = htmlWriter.commentTagsToContent(throwsTag, null, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
379 |
throwsTag.inlineTags(), false); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
380 |
if (desc != null && !desc.isEmpty()) { |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
381 |
body.addContent(" - "); |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
382 |
body.addContent(desc); |
10 | 383 |
} |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
384 |
HtmlTree result = HtmlTree.DD(body); |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
385 |
return result; |
10 | 386 |
} |
387 |
||
388 |
/** |
|
389 |
* {@inheritDoc} |
|
390 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
391 |
public Content throwsTagOutput(Type throwsType) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
392 |
HtmlTree result = HtmlTree.DD(HtmlTree.CODE(htmlWriter.getLink( |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
393 |
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, throwsType)))); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
394 |
return result; |
10 | 395 |
} |
396 |
||
397 |
/** |
|
398 |
* {@inheritDoc} |
|
399 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
400 |
public Content valueTagOutput(FieldDoc field, String constantVal, |
10 | 401 |
boolean includeLink) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
402 |
return includeLink ? |
17558
eee4ccf66cfd
8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents:
14542
diff
changeset
|
403 |
htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field, |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
404 |
constantVal, false) : new RawHtml(constantVal); |
10 | 405 |
} |
406 |
||
407 |
/** |
|
408 |
* {@inheritDoc} |
|
409 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
410 |
public Content commentTagsToOutput(Tag holderTag, Tag[] tags) { |
10 | 411 |
return commentTagsToOutput(holderTag, null, tags, false); |
412 |
} |
|
413 |
||
414 |
/** |
|
415 |
* {@inheritDoc} |
|
416 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
417 |
public Content commentTagsToOutput(Doc holderDoc, Tag[] tags) { |
10 | 418 |
return commentTagsToOutput(null, holderDoc, tags, false); |
419 |
} |
|
420 |
||
421 |
/** |
|
422 |
* {@inheritDoc} |
|
423 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
424 |
public Content commentTagsToOutput(Tag holderTag, |
10 | 425 |
Doc holderDoc, Tag[] tags, boolean isFirstSentence) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
426 |
return htmlWriter.commentTagsToContent( |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
427 |
holderTag, holderDoc, tags, isFirstSentence); |
10 | 428 |
} |
429 |
||
430 |
/** |
|
431 |
* {@inheritDoc} |
|
432 |
*/ |
|
433 |
public Configuration configuration() { |
|
14542 | 434 |
return configuration; |
10 | 435 |
} |
436 |
} |