author | ksrini |
Sun, 15 Jun 2014 08:41:57 -0700 | |
changeset 25454 | 376a52c9540c |
parent 22159 | 682da512ec17 |
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 |
||
80 |
/** |
|
81 |
* {@inheritDoc} |
|
82 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
83 |
public Content getDocRootOutput() { |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
84 |
String path; |
22005
4270ada5dcd1
8025416: doclet not substituting {@docRoot} in some cases
bpatel
parents:
21478
diff
changeset
|
85 |
if (htmlWriter.pathToRoot.isEmpty()) |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
86 |
path = "."; |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
87 |
else |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
88 |
path = htmlWriter.pathToRoot.getPath(); |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
89 |
return new StringContent(path); |
17565
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
90 |
} |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
91 |
|
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
92 |
/** |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
93 |
* {@inheritDoc} |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
94 |
*/ |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
95 |
public Content deprecatedTagOutput(Doc doc) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
96 |
ContentBuilder result = new ContentBuilder(); |
10 | 97 |
Tag[] deprs = doc.tags("deprecated"); |
98 |
if (doc instanceof ClassDoc) { |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
99 |
if (utils.isDeprecated((ProgramElementDoc) doc)) { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
100 |
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
101 |
new StringContent(configuration.getText("doclet.Deprecated")))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
102 |
result.addContent(RawHtml.nbsp); |
10 | 103 |
if (deprs.length > 0) { |
104 |
Tag[] commentTags = deprs[0].inlineTags(); |
|
105 |
if (commentTags.length > 0) { |
|
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
106 |
result.addContent(commentTagsToOutput(null, doc, |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
107 |
deprs[0].inlineTags(), false) |
10 | 108 |
); |
109 |
} |
|
110 |
} |
|
111 |
} |
|
112 |
} else { |
|
113 |
MemberDoc member = (MemberDoc) doc; |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
114 |
if (utils.isDeprecated((ProgramElementDoc) doc)) { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
115 |
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
116 |
new StringContent(configuration.getText("doclet.Deprecated")))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
117 |
result.addContent(RawHtml.nbsp); |
10 | 118 |
if (deprs.length > 0) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
119 |
Content body = commentTagsToOutput(null, doc, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
120 |
deprs[0].inlineTags(), false); |
21023
1192bdc59d82
8026370: javadoc creates empty <span class="italic"></span>
bpatel
parents:
19253
diff
changeset
|
121 |
if (!body.isEmpty()) |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
122 |
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecationComment, body)); |
10 | 123 |
} |
124 |
} else { |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
125 |
if (utils.isDeprecated(member.containingClass())) { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
126 |
result.addContent(HtmlTree.SPAN(HtmlStyle.deprecatedLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
127 |
new StringContent(configuration.getText("doclet.Deprecated")))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
128 |
result.addContent(RawHtml.nbsp); |
10 | 129 |
} |
130 |
} |
|
131 |
} |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
132 |
return result; |
10 | 133 |
} |
134 |
||
135 |
/** |
|
136 |
* {@inheritDoc} |
|
137 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
138 |
protected Content literalTagOutput(Tag tag) { |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22159
diff
changeset
|
139 |
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
|
140 |
return result; |
17565
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
141 |
} |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
142 |
|
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
143 |
/** |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
144 |
* {@inheritDoc} |
a705fe5e539f
8012174: {@literal} and {@code} should use \"new\" Taglet, not old.
jjg
parents:
17560
diff
changeset
|
145 |
*/ |
10 | 146 |
public MessageRetriever getMsgRetriever() { |
14542 | 147 |
return configuration.message; |
10 | 148 |
} |
149 |
||
150 |
/** |
|
151 |
* {@inheritDoc} |
|
152 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
153 |
public Content getParamHeader(String header) { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
154 |
HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.paramLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
155 |
new StringContent(header))); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
156 |
return result; |
10 | 157 |
} |
158 |
||
159 |
/** |
|
160 |
* {@inheritDoc} |
|
161 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
162 |
public Content paramTagOutput(ParamTag paramTag, String paramName) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
163 |
ContentBuilder body = new ContentBuilder(); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
164 |
body.addContent(HtmlTree.CODE(new RawHtml(paramName))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
165 |
body.addContent(" - "); |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
166 |
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
|
167 |
HtmlTree result = HtmlTree.DD(body); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
168 |
return result; |
10 | 169 |
} |
170 |
||
171 |
/** |
|
172 |
* {@inheritDoc} |
|
173 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
174 |
public Content propertyTagOutput(Tag tag, String prefix) { |
17572 | 175 |
Content body = new ContentBuilder(); |
176 |
body.addContent(new RawHtml(prefix)); |
|
177 |
body.addContent(" "); |
|
178 |
body.addContent(HtmlTree.CODE(new RawHtml(tag.text()))); |
|
179 |
body.addContent("."); |
|
180 |
Content result = HtmlTree.P(body); |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
181 |
return result; |
17572 | 182 |
} |
183 |
||
184 |
/** |
|
185 |
* {@inheritDoc} |
|
186 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
187 |
public Content returnTagOutput(Tag returnTag) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
188 |
ContentBuilder result = new ContentBuilder(); |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
189 |
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.returnLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
190 |
new StringContent(configuration.getText("doclet.Returns"))))); |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
191 |
result.addContent(HtmlTree.DD(htmlWriter.commentTagsToContent( |
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
192 |
returnTag, null, returnTag.inlineTags(), false))); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
193 |
return result; |
10 | 194 |
} |
195 |
||
196 |
/** |
|
197 |
* {@inheritDoc} |
|
198 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
199 |
public Content seeTagOutput(Doc holder, SeeTag[] seeTags) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
200 |
ContentBuilder body = new ContentBuilder(); |
10 | 201 |
if (seeTags.length > 0) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22005
diff
changeset
|
202 |
for (SeeTag seeTag : seeTags) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
203 |
appendSeparatorIfNotEmpty(body); |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
22005
diff
changeset
|
204 |
body.addContent(htmlWriter.seeTagToContent(seeTag)); |
10 | 205 |
} |
206 |
} |
|
207 |
if (holder.isField() && ((FieldDoc)holder).constantValue() != null && |
|
208 |
htmlWriter instanceof ClassWriterImpl) { |
|
209 |
//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
|
210 |
appendSeparatorIfNotEmpty(body); |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
211 |
DocPath constantsPath = |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
212 |
htmlWriter.pathToRoot.resolve(DocPaths.CONSTANT_VALUES); |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
213 |
String whichConstant = |
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
214 |
((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
|
215 |
DocLink link = constantsPath.fragment(whichConstant); |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
216 |
body.addContent(htmlWriter.getHyperLink(link, |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
217 |
new StringContent(configuration.getText("doclet.Constants_Summary")))); |
10 | 218 |
} |
219 |
if (holder.isClass() && ((ClassDoc)holder).isSerializable()) { |
|
220 |
//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
|
221 |
if ((SerializedFormBuilder.serialInclude(holder) && |
10 | 222 |
SerializedFormBuilder.serialInclude(((ClassDoc)holder).containingPackage()))) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
223 |
appendSeparatorIfNotEmpty(body); |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
224 |
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
|
225 |
DocLink link = serialPath.fragment(((ClassDoc)holder).qualifiedName()); |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
226 |
body.addContent(htmlWriter.getHyperLink(link, |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
227 |
new StringContent(configuration.getText("doclet.Serialized_Form")))); |
10 | 228 |
} |
229 |
} |
|
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
230 |
if (body.isEmpty()) |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
231 |
return body; |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
232 |
|
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
233 |
ContentBuilder result = new ContentBuilder(); |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
234 |
result.addContent(HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.seeLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
235 |
new StringContent(configuration.getText("doclet.See_Also"))))); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
236 |
result.addContent(HtmlTree.DD(body)); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
237 |
return result; |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
238 |
|
10 | 239 |
} |
240 |
||
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
241 |
private void appendSeparatorIfNotEmpty(ContentBuilder body) { |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
242 |
if (!body.isEmpty()) { |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
243 |
body.addContent(", "); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
244 |
body.addContent(DocletConstants.NL); |
10 | 245 |
} |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
246 |
} |
10 | 247 |
|
248 |
/** |
|
249 |
* {@inheritDoc} |
|
250 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
251 |
public Content simpleTagOutput(Tag[] simpleTags, String header) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
252 |
ContentBuilder result = new ContentBuilder(); |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
253 |
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
|
254 |
ContentBuilder body = new ContentBuilder(); |
10 | 255 |
for (int i = 0; i < simpleTags.length; i++) { |
256 |
if (i > 0) { |
|
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
257 |
body.addContent(", "); |
10 | 258 |
} |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
259 |
body.addContent(htmlWriter.commentTagsToContent( |
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
260 |
simpleTags[i], null, simpleTags[i].inlineTags(), false)); |
10 | 261 |
} |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
262 |
result.addContent(HtmlTree.DD(body)); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
263 |
return result; |
10 | 264 |
} |
265 |
||
266 |
/** |
|
267 |
* {@inheritDoc} |
|
268 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
269 |
public Content simpleTagOutput(Tag simpleTag, String header) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
270 |
ContentBuilder result = new ContentBuilder(); |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
271 |
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
|
272 |
Content body = htmlWriter.commentTagsToContent( |
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
273 |
simpleTag, null, simpleTag.inlineTags(), false); |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
274 |
result.addContent(HtmlTree.DD(body)); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
275 |
return result; |
10 | 276 |
} |
277 |
||
278 |
/** |
|
279 |
* {@inheritDoc} |
|
280 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
281 |
public Content getThrowsHeader() { |
21478
fa4c7cda1b41
8026567: Use meaningful style names for strong and italic styles.
bpatel
parents:
21023
diff
changeset
|
282 |
HtmlTree result = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.throwsLabel, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
283 |
new StringContent(configuration.getText("doclet.Throws")))); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
284 |
return result; |
10 | 285 |
} |
286 |
||
287 |
/** |
|
288 |
* {@inheritDoc} |
|
289 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
290 |
public Content throwsTagOutput(ThrowsTag throwsTag) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
291 |
ContentBuilder body = new ContentBuilder(); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
292 |
Content excName = (throwsTag.exceptionType() == null) ? |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
293 |
new RawHtml(throwsTag.exceptionName()) : |
17558
eee4ccf66cfd
8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents:
14542
diff
changeset
|
294 |
htmlWriter.getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
295 |
throwsTag.exceptionType())); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
296 |
body.addContent(HtmlTree.CODE(excName)); |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
297 |
Content desc = htmlWriter.commentTagsToContent(throwsTag, null, |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
298 |
throwsTag.inlineTags(), false); |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
299 |
if (desc != null && !desc.isEmpty()) { |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
300 |
body.addContent(" - "); |
17568
d9691936f5f9
8012177: HTMLDocletWriter methods should generate Content, not Strings
jjg
parents:
17567
diff
changeset
|
301 |
body.addContent(desc); |
10 | 302 |
} |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
303 |
HtmlTree result = HtmlTree.DD(body); |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
304 |
return result; |
10 | 305 |
} |
306 |
||
307 |
/** |
|
308 |
* {@inheritDoc} |
|
309 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
310 |
public Content throwsTagOutput(Type throwsType) { |
17566
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
311 |
HtmlTree result = HtmlTree.DD(HtmlTree.CODE(htmlWriter.getLink( |
7e1a338e1085
8012175: Convert TagletOutputImpl to use ContentBuilder instead of StringBuilder
jjg
parents:
17565
diff
changeset
|
312 |
new LinkInfoImpl(configuration, LinkInfoImpl.Kind.MEMBER, throwsType)))); |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
313 |
return result; |
10 | 314 |
} |
315 |
||
316 |
/** |
|
317 |
* {@inheritDoc} |
|
318 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
319 |
public Content valueTagOutput(FieldDoc field, String constantVal, |
10 | 320 |
boolean includeLink) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
321 |
return includeLink ? |
17558
eee4ccf66cfd
8010440: Replace int constants in LinkInfoImpl with enum
jjg
parents:
14542
diff
changeset
|
322 |
htmlWriter.getDocLink(LinkInfoImpl.Kind.VALUE_TAG, field, |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
323 |
constantVal, false) : new RawHtml(constantVal); |
10 | 324 |
} |
325 |
||
326 |
/** |
|
327 |
* {@inheritDoc} |
|
328 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
329 |
public Content commentTagsToOutput(Tag holderTag, Tag[] tags) { |
10 | 330 |
return commentTagsToOutput(holderTag, null, tags, false); |
331 |
} |
|
332 |
||
333 |
/** |
|
334 |
* {@inheritDoc} |
|
335 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
336 |
public Content commentTagsToOutput(Doc holderDoc, Tag[] tags) { |
10 | 337 |
return commentTagsToOutput(null, holderDoc, tags, false); |
338 |
} |
|
339 |
||
340 |
/** |
|
341 |
* {@inheritDoc} |
|
342 |
*/ |
|
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
343 |
public Content commentTagsToOutput(Tag holderTag, |
10 | 344 |
Doc holderDoc, Tag[] tags, boolean isFirstSentence) { |
17574
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
345 |
return htmlWriter.commentTagsToContent( |
044c7e1e4d53
8012308: Remove TagletOutput in favor of direct use of Content
jjg
parents:
17572
diff
changeset
|
346 |
holderTag, holderDoc, tags, isFirstSentence); |
10 | 347 |
} |
348 |
||
349 |
/** |
|
350 |
* {@inheritDoc} |
|
351 |
*/ |
|
352 |
public Configuration configuration() { |
|
14542 | 353 |
return configuration; |
10 | 354 |
} |
355 |
} |