author | jjg |
Tue, 14 May 2013 10:14:52 -0700 | |
changeset 17560 | 9f6771abbd1a |
parent 17559 | 87c28ee29329 |
child 17561 | 9f3505f35da9 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14542
diff
changeset
|
2 |
* Copyright (c) 1998, 2013, 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 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
28 |
import java.io.*; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
29 |
import java.util.*; |
14258 | 30 |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
31 |
import com.sun.javadoc.*; |
14258 | 32 |
import com.sun.tools.doclets.formats.html.markup.*; |
33 |
import com.sun.tools.doclets.internal.toolkit.*; |
|
10 | 34 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
35 |
||
36 |
/** |
|
37 |
* Class to generate file for each package contents in the left-hand bottom |
|
38 |
* frame. This will list all the Class Kinds in the package. A click on any |
|
39 |
* class-kind will update the right-hand frame with the clicked class-kind page. |
|
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> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
45 |
* |
10 | 46 |
* @author Atul M Dambalkar |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
47 |
* @author Bhavesh Patel (Modified) |
10 | 48 |
*/ |
49 |
public class PackageFrameWriter extends HtmlDocletWriter { |
|
50 |
||
51 |
/** |
|
52 |
* The package being documented. |
|
53 |
*/ |
|
54 |
private PackageDoc packageDoc; |
|
55 |
||
56 |
/** |
|
57 |
* The classes to be documented. Use this to filter out classes |
|
58 |
* that will not be documented. |
|
59 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1264
diff
changeset
|
60 |
private Set<ClassDoc> documentedClasses; |
10 | 61 |
|
62 |
/** |
|
63 |
* Constructor to construct PackageFrameWriter object and to generate |
|
64 |
* "package-frame.html" file in the respective package directory. |
|
65 |
* For example for package "java.lang" this will generate file |
|
66 |
* "package-frame.html" file in the "java/lang" directory. It will also |
|
67 |
* create "java/lang" directory in the current or the destination directory |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
68 |
* if it doesn't exist. |
10 | 69 |
* |
70 |
* @param configuration the configuration of the doclet. |
|
71 |
* @param packageDoc PackageDoc under consideration. |
|
72 |
*/ |
|
73 |
public PackageFrameWriter(ConfigurationImpl configuration, |
|
74 |
PackageDoc packageDoc) |
|
75 |
throws IOException { |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
76 |
super(configuration, DocPath.forPackage(packageDoc).resolve(DocPaths.PACKAGE_FRAME)); |
10 | 77 |
this.packageDoc = packageDoc; |
78 |
if (configuration.root.specifiedPackages().length == 0) { |
|
868 | 79 |
documentedClasses = new HashSet<ClassDoc>(Arrays.asList(configuration.root.classes())); |
10 | 80 |
} |
81 |
} |
|
82 |
||
83 |
/** |
|
84 |
* Generate a package summary page for the left-hand bottom frame. Construct |
|
85 |
* the PackageFrameWriter object and then uses it generate the file. |
|
86 |
* |
|
87 |
* @param configuration the current configuration of the doclet. |
|
88 |
* @param packageDoc The package for which "pacakge-frame.html" is to be generated. |
|
89 |
*/ |
|
90 |
public static void generate(ConfigurationImpl configuration, |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
91 |
PackageDoc packageDoc) { |
10 | 92 |
PackageFrameWriter packgen; |
93 |
try { |
|
94 |
packgen = new PackageFrameWriter(configuration, packageDoc); |
|
95 |
String pkgName = Util.getPackageName(packageDoc); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
96 |
Content body = packgen.getBody(false, packgen.getWindowTitle(pkgName)); |
17560 | 97 |
Content pkgNameContent = new StringContent(pkgName); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
98 |
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
99 |
packgen.getTargetPackageLink(packageDoc, "classFrame", pkgNameContent)); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
100 |
body.addContent(heading); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
101 |
HtmlTree div = new HtmlTree(HtmlTag.DIV); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
102 |
div.addStyle(HtmlStyle.indexContainer); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
103 |
packgen.addClassListing(div); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
104 |
body.addContent(div); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
105 |
packgen.printHtmlDocument( |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
106 |
configuration.metakeywords.getMetaKeywords(packageDoc), false, body); |
10 | 107 |
packgen.close(); |
108 |
} catch (IOException exc) { |
|
109 |
configuration.standardmessage.error( |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
110 |
"doclet.exception_encountered", |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
111 |
exc.toString(), DocPaths.PACKAGE_FRAME.getPath()); |
10 | 112 |
throw new DocletAbortException(); |
113 |
} |
|
114 |
} |
|
115 |
||
116 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
117 |
* Add class listing for all the classes in this package. Divide class |
10 | 118 |
* listing as per the class kind and generate separate listing for |
119 |
* Classes, Interfaces, Exceptions and Errors. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
120 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
121 |
* @param contentTree the content tree to which the listing will be added |
10 | 122 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
123 |
protected void addClassListing(Content contentTree) { |
14542 | 124 |
Configuration config = configuration; |
10 | 125 |
if (packageDoc.isIncluded()) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
126 |
addClassKindListing(packageDoc.interfaces(), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
127 |
getResource("doclet.Interfaces"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
128 |
addClassKindListing(packageDoc.ordinaryClasses(), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
129 |
getResource("doclet.Classes"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
130 |
addClassKindListing(packageDoc.enums(), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
131 |
getResource("doclet.Enums"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
132 |
addClassKindListing(packageDoc.exceptions(), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
133 |
getResource("doclet.Exceptions"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
134 |
addClassKindListing(packageDoc.errors(), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
135 |
getResource("doclet.Errors"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
136 |
addClassKindListing(packageDoc.annotationTypes(), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
137 |
getResource("doclet.AnnotationTypes"), contentTree); |
10 | 138 |
} else { |
139 |
String name = Util.getPackageName(packageDoc); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
140 |
addClassKindListing(config.classDocCatalog.interfaces(name), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
141 |
getResource("doclet.Interfaces"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
142 |
addClassKindListing(config.classDocCatalog.ordinaryClasses(name), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
143 |
getResource("doclet.Classes"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
144 |
addClassKindListing(config.classDocCatalog.enums(name), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
145 |
getResource("doclet.Enums"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
146 |
addClassKindListing(config.classDocCatalog.exceptions(name), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
147 |
getResource("doclet.Exceptions"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
148 |
addClassKindListing(config.classDocCatalog.errors(name), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
149 |
getResource("doclet.Errors"), contentTree); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
150 |
addClassKindListing(config.classDocCatalog.annotationTypes(name), |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
151 |
getResource("doclet.AnnotationTypes"), contentTree); |
10 | 152 |
} |
153 |
} |
|
154 |
||
155 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
156 |
* Add specific class kind listing. Also add label to the listing. |
10 | 157 |
* |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
158 |
* @param arr Array of specific class kinds, namely Class or Interface or Exception or Error |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
159 |
* @param labelContent content tree of the label to be added |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
160 |
* @param contentTree the content tree to which the class kind listing will be added |
10 | 161 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
162 |
protected void addClassKindListing(ClassDoc[] arr, Content labelContent, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
163 |
Content contentTree) { |
16319
e586bfeb39c5
7112427: The doclet needs to be able to generate JavaFX documentation.
jjg
parents:
14542
diff
changeset
|
164 |
arr = Util.filterOutPrivateClasses(arr, configuration.javafx); |
10 | 165 |
if(arr.length > 0) { |
166 |
Arrays.sort(arr); |
|
167 |
boolean printedHeader = false; |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
168 |
HtmlTree ul = new HtmlTree(HtmlTag.UL); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
169 |
ul.addAttr(HtmlAttr.TITLE, labelContent.toString()); |
10 | 170 |
for (int i = 0; i < arr.length; i++) { |
171 |
if (documentedClasses != null && |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
172 |
!documentedClasses.contains(arr[i])) { |
10 | 173 |
continue; |
174 |
} |
|
175 |
if (!Util.isCoreClass(arr[i]) || ! |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
176 |
configuration.isGeneratedDoc(arr[i])) { |
10 | 177 |
continue; |
178 |
} |
|
179 |
if (!printedHeader) { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
180 |
Content heading = HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
181 |
true, labelContent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
182 |
contentTree.addContent(heading); |
10 | 183 |
printedHeader = true; |
184 |
} |
|
17560 | 185 |
Content arr_i_name = new StringContent(arr[i].name()); |
186 |
if (arr[i].isInterface()) arr_i_name = HtmlTree.I(arr_i_name); |
|
17559
87c28ee29329
8011642: Remove LinkOutput in favor of direct use of Content
jjg
parents:
17558
diff
changeset
|
187 |
Content link = getLink(new LinkInfoImpl(configuration, |
17560 | 188 |
LinkInfoImpl.Kind.PACKAGE_FRAME, arr[i], arr_i_name, "classFrame")); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
189 |
Content li = HtmlTree.LI(link); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
190 |
ul.addContent(li); |
10 | 191 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
192 |
contentTree.addContent(ul); |
10 | 193 |
} |
194 |
} |
|
195 |
} |