author | hannesw |
Wed, 27 Nov 2019 13:08:16 +0100 | |
changeset 59294 | 48b88b9c11eb |
parent 54596 | 86c1da00dd6a |
permissions | -rw-r--r-- |
10 | 1 |
/* |
54060
53a95878619f
8220202: Simplify/standardize method naming for HtmlTree
jjg
parents:
52644
diff
changeset
|
2 |
* Copyright (c) 2003, 2019, 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 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.builders; |
10 | 27 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
28 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
29 |
import javax.lang.model.element.TypeElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
30 |
|
54596
86c1da00dd6a
8219998: Eliminate inherently singleton lists
pmuthuswamy
parents:
54060
diff
changeset
|
31 |
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
32 |
import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
48029
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47272
diff
changeset
|
34 |
import jdk.javadoc.internal.doclets.toolkit.DocFilesHandler; |
40587 | 35 |
import jdk.javadoc.internal.doclets.toolkit.DocletException; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
36 |
|
10 | 37 |
|
38 |
/** |
|
39 |
* Builds the summary for a given annotation type. |
|
40 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
41 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
42 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
43 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
44 |
* deletion without notice.</b> |
10 | 45 |
* |
46 |
* @author Jamie Ho |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
47 |
* @author Bhavesh Patel (Modified) |
10 | 48 |
*/ |
49 |
public class AnnotationTypeBuilder extends AbstractBuilder { |
|
50 |
||
51 |
/** |
|
52 |
* The annotation type being documented. |
|
53 |
*/ |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
54 |
private final TypeElement annotationType; |
10 | 55 |
|
56 |
/** |
|
57 |
* The doclet specific writer. |
|
58 |
*/ |
|
14542 | 59 |
private final AnnotationTypeWriter writer; |
10 | 60 |
|
61 |
/** |
|
62 |
* Construct a new ClassBuilder. |
|
63 |
* |
|
14542 | 64 |
* @param context the build context. |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
65 |
* @param annotationTypeElement the class being documented. |
14542 | 66 |
* @param writer the doclet specific writer. |
10 | 67 |
*/ |
14542 | 68 |
private AnnotationTypeBuilder(Context context, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
69 |
TypeElement annotationTypeElement, |
14542 | 70 |
AnnotationTypeWriter writer) { |
71 |
super(context); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
72 |
this.annotationType = annotationTypeElement; |
14542 | 73 |
this.writer = writer; |
10 | 74 |
} |
75 |
||
76 |
/** |
|
40587 | 77 |
* Construct a new AnnotationTypeBuilder. |
10 | 78 |
* |
14542 | 79 |
* @param context the build context. |
10 | 80 |
* @param annotationTypeDoc the class being documented. |
81 |
* @param writer the doclet specific writer. |
|
40587 | 82 |
* @return an AnnotationTypeBuilder |
10 | 83 |
*/ |
14542 | 84 |
public static AnnotationTypeBuilder getInstance(Context context, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
85 |
TypeElement annotationTypeDoc, |
40587 | 86 |
AnnotationTypeWriter writer) { |
14542 | 87 |
return new AnnotationTypeBuilder(context, annotationTypeDoc, writer); |
10 | 88 |
} |
89 |
||
90 |
/** |
|
91 |
* {@inheritDoc} |
|
92 |
*/ |
|
40587 | 93 |
@Override |
94 |
public void build() throws DocletException { |
|
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
54596
diff
changeset
|
95 |
buildAnnotationTypeDoc(); |
10 | 96 |
} |
97 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
98 |
/** |
40587 | 99 |
* Build the annotation type documentation. |
100 |
* |
|
101 |
* @throws DocletException if there is a problem building the documentation |
|
102 |
*/ |
|
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
54596
diff
changeset
|
103 |
protected void buildAnnotationTypeDoc() throws DocletException { |
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
54596
diff
changeset
|
104 |
Content contentTree = writer.getHeader(resources.getText("doclet.AnnotationType") + |
40587 | 105 |
" " + utils.getSimpleName(annotationType)); |
106 |
Content annotationContentTree = writer.getAnnotationContentHeader(); |
|
45599 | 107 |
|
108 |
buildAnnotationTypeInfo(annotationContentTree); |
|
109 |
buildMemberSummary(annotationContentTree); |
|
110 |
buildAnnotationTypeMemberDetails(annotationContentTree); |
|
111 |
||
59294
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
54596
diff
changeset
|
112 |
writer.addAnnotationContentTree(annotationContentTree); |
48b88b9c11eb
8223378: CSS solution for navbar problem with <a> elements is not ideal
hannesw
parents:
54596
diff
changeset
|
113 |
writer.addFooter(); |
40587 | 114 |
writer.printDocument(contentTree); |
115 |
copyDocFiles(); |
|
116 |
} |
|
10 | 117 |
|
40587 | 118 |
/** |
119 |
* Copy the doc files for the current TypeElement if necessary. |
|
120 |
* |
|
121 |
* @throws DocletException if there is a problem building the documentation |
|
122 |
*/ |
|
123 |
private void copyDocFiles() throws DocletException { |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
124 |
PackageElement containingPackage = utils.containingPackage(annotationType); |
45599 | 125 |
if ((configuration.packages == null || |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
20237
diff
changeset
|
126 |
!configuration.packages.contains(containingPackage) && |
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
20237
diff
changeset
|
127 |
!containingPackagesSeen.contains(containingPackage))){ |
10 | 128 |
//Only copy doc files dir if the containing package is not |
129 |
//documented AND if we have not documented a class from the same |
|
130 |
//package already. Otherwise, we are making duplicate copies. |
|
48029
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47272
diff
changeset
|
131 |
DocFilesHandler docFilesHandler = configuration |
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47272
diff
changeset
|
132 |
.getWriterFactory() |
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47272
diff
changeset
|
133 |
.getDocFilesHandler(containingPackage); |
e9dab2492924
8185985: Html files in doc-files directories should be wrapped with standard header and footer
ksrini
parents:
47272
diff
changeset
|
134 |
docFilesHandler.copyDocFiles(); |
24221
2376793dd33b
8038583: [javadoc] Refactor uses of arrays to Collections
ksrini
parents:
20237
diff
changeset
|
135 |
containingPackagesSeen.add(containingPackage); |
10 | 136 |
} |
40587 | 137 |
} |
10 | 138 |
|
139 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
140 |
* Build the annotation information tree documentation. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
141 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
142 |
* @param annotationContentTree the content tree to which the documentation will be added |
40587 | 143 |
* @throws DocletException if there is a problem building the documentation |
10 | 144 |
*/ |
45599 | 145 |
protected void buildAnnotationTypeInfo(Content annotationContentTree) |
40587 | 146 |
throws DocletException { |
54596
86c1da00dd6a
8219998: Eliminate inherently singleton lists
pmuthuswamy
parents:
54060
diff
changeset
|
147 |
Content annotationInfoTree = new ContentBuilder(); |
47272 | 148 |
buildAnnotationTypeSignature(annotationInfoTree); |
45599 | 149 |
buildDeprecationInfo(annotationInfoTree); |
150 |
buildAnnotationTypeDescription(annotationInfoTree); |
|
151 |
buildAnnotationTypeTagInfo(annotationInfoTree); |
|
152 |
||
54060
53a95878619f
8220202: Simplify/standardize method naming for HtmlTree
jjg
parents:
52644
diff
changeset
|
153 |
annotationContentTree.add(writer.getAnnotationInfo(annotationInfoTree)); |
10 | 154 |
} |
155 |
||
156 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
157 |
* If this annotation is deprecated, build the appropriate information. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
158 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
159 |
* @param annotationInfoTree the content tree to which the documentation will be added |
10 | 160 |
*/ |
45599 | 161 |
protected void buildDeprecationInfo(Content annotationInfoTree) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
162 |
writer.addAnnotationTypeDeprecationInfo(annotationInfoTree); |
10 | 163 |
} |
164 |
||
165 |
/** |
|
166 |
* Build the signature of the current annotation type. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
167 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
168 |
* @param annotationInfoTree the content tree to which the documentation will be added |
10 | 169 |
*/ |
45599 | 170 |
protected void buildAnnotationTypeSignature(Content annotationInfoTree) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
171 |
writer.addAnnotationTypeSignature(utils.modifiersToString(annotationType, true), |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
172 |
annotationInfoTree); |
10 | 173 |
} |
174 |
||
175 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
176 |
* Build the annotation type description. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
177 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
178 |
* @param annotationInfoTree the content tree to which the documentation will be added |
10 | 179 |
*/ |
45599 | 180 |
protected void buildAnnotationTypeDescription(Content annotationInfoTree) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
181 |
writer.addAnnotationTypeDescription(annotationInfoTree); |
10 | 182 |
} |
183 |
||
184 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
185 |
* Build the tag information for the current annotation type. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
186 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
187 |
* @param annotationInfoTree the content tree to which the documentation will be added |
10 | 188 |
*/ |
45599 | 189 |
protected void buildAnnotationTypeTagInfo(Content annotationInfoTree) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
190 |
writer.addAnnotationTypeTagInfo(annotationInfoTree); |
10 | 191 |
} |
192 |
||
193 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
194 |
* Build the member summary contents of the page. |
10 | 195 |
* |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
196 |
* @param annotationContentTree the content tree to which the documentation will be added |
40587 | 197 |
* @throws DocletException if there is a problem building the documentation |
10 | 198 |
*/ |
45599 | 199 |
protected void buildMemberSummary(Content annotationContentTree) throws DocletException { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
200 |
Content memberSummaryTree = writer.getMemberTreeHeader(); |
45599 | 201 |
builderFactory.getMemberSummaryBuilder(writer).build(memberSummaryTree); |
54060
53a95878619f
8220202: Simplify/standardize method naming for HtmlTree
jjg
parents:
52644
diff
changeset
|
202 |
annotationContentTree.add(writer.getMemberSummaryTree(memberSummaryTree)); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
203 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
204 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
205 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
206 |
* Build the member details contents of the page. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
207 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
208 |
* @param annotationContentTree the content tree to which the documentation will be added |
40587 | 209 |
* @throws DocletException if there is a problem building the documentation |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
210 |
*/ |
45599 | 211 |
protected void buildAnnotationTypeMemberDetails(Content annotationContentTree) |
40587 | 212 |
throws DocletException { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
213 |
Content memberDetailsTree = writer.getMemberTreeHeader(); |
45599 | 214 |
|
215 |
buildAnnotationTypeFieldDetails(memberDetailsTree); |
|
216 |
buildAnnotationTypeRequiredMemberDetails(memberDetailsTree); |
|
217 |
buildAnnotationTypeOptionalMemberDetails(memberDetailsTree); |
|
218 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
219 |
if (memberDetailsTree.isValid()) { |
54060
53a95878619f
8220202: Simplify/standardize method naming for HtmlTree
jjg
parents:
52644
diff
changeset
|
220 |
annotationContentTree.add(writer.getMemberDetailsTree(memberDetailsTree)); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
221 |
} |
10 | 222 |
} |
223 |
||
224 |
/** |
|
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16560
diff
changeset
|
225 |
* Build the annotation type field documentation. |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16560
diff
changeset
|
226 |
* |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16560
diff
changeset
|
227 |
* @param memberDetailsTree the content tree to which the documentation will be added |
40587 | 228 |
* @throws DocletException if there is a problem building the documentation |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16560
diff
changeset
|
229 |
*/ |
45599 | 230 |
protected void buildAnnotationTypeFieldDetails(Content memberDetailsTree) |
40587 | 231 |
throws DocletException { |
45599 | 232 |
builderFactory.getAnnotationTypeFieldsBuilder(writer).build(memberDetailsTree); |
20237
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16560
diff
changeset
|
233 |
} |
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16560
diff
changeset
|
234 |
|
b6d89903c867
8015249: javadoc fails to document static final fields in annotation types
bpatel
parents:
16560
diff
changeset
|
235 |
/** |
10 | 236 |
* Build the annotation type optional member documentation. |
237 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
238 |
* @param memberDetailsTree the content tree to which the documentation will be added |
40587 | 239 |
* @throws DocletException if there is a problem building the documentation |
10 | 240 |
*/ |
45599 | 241 |
protected void buildAnnotationTypeOptionalMemberDetails(Content memberDetailsTree) |
40587 | 242 |
throws DocletException { |
45599 | 243 |
builderFactory.getAnnotationTypeOptionalMemberBuilder(writer).build(memberDetailsTree); |
10 | 244 |
} |
245 |
||
246 |
/** |
|
247 |
* Build the annotation type required member documentation. |
|
248 |
* |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5855
diff
changeset
|
249 |
* @param memberDetailsTree the content tree to which the documentation will be added |
40587 | 250 |
* @throws DocletException if there is a problem building the documentation |
10 | 251 |
*/ |
45599 | 252 |
protected void buildAnnotationTypeRequiredMemberDetails(Content memberDetailsTree) |
40587 | 253 |
throws DocletException { |
45599 | 254 |
builderFactory.getAnnotationTypeRequiredMemberBuilder(writer).build(memberDetailsTree); |
10 | 255 |
} |
256 |
} |