Fri, 27 Feb 2009 18:57:17 -0800
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
Reviewed-by: jjg
1 /*
2 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Sun designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
26 package com.sun.tools.doclets.formats.html;
28 import com.sun.tools.doclets.internal.toolkit.*;
29 import com.sun.tools.doclets.internal.toolkit.util.*;
31 import com.sun.javadoc.*;
32 import java.io.*;
33 import java.util.*;
35 /**
36 * Class to generate file for each package contents in the right-hand
37 * frame. This will list all the Class Kinds in the package. A click on any
38 * class-kind will update the frame with the clicked class-kind page.
39 *
40 * @author Atul M Dambalkar
41 */
42 public class PackageWriterImpl extends HtmlDocletWriter
43 implements PackageSummaryWriter {
45 /**
46 * The prev package name in the alpha-order list.
47 */
48 protected PackageDoc prev;
50 /**
51 * The next package name in the alpha-order list.
52 */
53 protected PackageDoc next;
55 /**
56 * The package being documented.
57 */
58 protected PackageDoc packageDoc;
60 /**
61 * The name of the output file.
62 */
63 private static final String OUTPUT_FILE_NAME = "package-summary.html";
65 /**
66 * Constructor to construct PackageWriter object and to generate
67 * "package-summary.html" file in the respective package directory.
68 * For example for package "java.lang" this will generate file
69 * "package-summary.html" file in the "java/lang" directory. It will also
70 * create "java/lang" directory in the current or the destination directory
71 * if it doesen't exist.
72 *
73 * @param configuration the configuration of the doclet.
74 * @param packageDoc PackageDoc under consideration.
75 * @param prev Previous package in the sorted array.
76 * @param next Next package in the sorted array.
77 */
78 public PackageWriterImpl(ConfigurationImpl configuration,
79 PackageDoc packageDoc, PackageDoc prev, PackageDoc next)
80 throws IOException {
81 super(configuration, DirectoryManager.getDirectoryPath(packageDoc), OUTPUT_FILE_NAME,
82 DirectoryManager.getRelativePath(packageDoc.name()));
83 this.prev = prev;
84 this.next = next;
85 this.packageDoc = packageDoc;
86 }
88 /**
89 * Return the name of the output file.
90 *
91 * @return the name of the output file.
92 */
93 public String getOutputFileName() {
94 return OUTPUT_FILE_NAME;
95 }
97 /**
98 * {@inheritDoc}
99 */
100 public void writeSummaryHeader() {}
102 /**
103 * {@inheritDoc}
104 */
105 public void writeSummaryFooter() {}
107 /**
108 * {@inheritDoc}
109 */
110 public void writeClassesSummary(ClassDoc[] classes, String label) {
111 if(classes.length > 0) {
112 Arrays.sort(classes);
113 tableIndexSummary();
114 boolean printedHeading = false;
115 for (int i = 0; i < classes.length; i++) {
116 if (!printedHeading) {
117 printFirstRow(label);
118 printedHeading = true;
119 }
120 if (!Util.isCoreClass(classes[i]) ||
121 !configuration.isGeneratedDoc(classes[i])) {
122 continue;
123 }
124 trBgcolorStyle("white", "TableRowColor");
125 summaryRow(15);
126 strong();
127 printLink(new LinkInfoImpl(LinkInfoImpl.CONTEXT_PACKAGE,
128 classes[i], false));
129 strongEnd();
130 summaryRowEnd();
131 summaryRow(0);
132 if (Util.isDeprecated(classes[i])) {
133 strongText("doclet.Deprecated");
134 if (classes[i].tags("deprecated").length > 0) {
135 space();
136 printSummaryDeprecatedComment(classes[i],
137 classes[i].tags("deprecated")[0]);
138 }
139 } else {
140 printSummaryComment(classes[i]);
141 }
142 summaryRowEnd();
143 trEnd();
144 }
145 tableEnd();
146 println(" ");
147 p();
148 }
149 }
151 /**
152 * Print the table heading for the class-listing.
153 *
154 * @param label Label for the Class kind listing.
155 */
156 protected void printFirstRow(String label) {
157 tableHeaderStart("#CCCCFF");
158 strong(label);
159 tableHeaderEnd();
160 }
162 /**
163 * {@inheritDoc}
164 */
165 public void writePackageDescription() {
166 if (packageDoc.inlineTags().length > 0) {
167 anchor("package_description");
168 h2(configuration.getText("doclet.Package_Description", packageDoc.name()));
169 p();
170 printInlineComment(packageDoc);
171 p();
172 }
173 }
175 /**
176 * {@inheritDoc}
177 */
178 public void writePackageTags() {
179 printTags(packageDoc);
180 }
182 /**
183 * {@inheritDoc}
184 */
185 public void writePackageHeader(String heading) {
186 String pkgName = packageDoc.name();
187 printHtmlHeader(pkgName,
188 configuration.metakeywords.getMetaKeywords(packageDoc), true);
189 printTop();
190 navLinks(true);
191 hr();
192 writeAnnotationInfo(packageDoc);
193 h2(configuration.getText("doclet.Package") + " " + heading);
194 if (packageDoc.inlineTags().length > 0 && ! configuration.nocomment) {
195 printSummaryComment(packageDoc);
196 p();
197 strong(configuration.getText("doclet.See"));
198 br();
199 printNbsps();
200 printHyperLink("", "package_description",
201 configuration.getText("doclet.Description"), true);
202 p();
203 }
204 }
206 /**
207 * {@inheritDoc}
208 */
209 public void writePackageFooter() {
210 hr();
211 navLinks(false);
212 printBottom();
213 printBodyHtmlEnd();
214 }
216 /**
217 * Print "Use" link for this pacakge in the navigation bar.
218 */
219 protected void navLinkClassUse() {
220 navCellStart();
221 printHyperLink("package-use.html", "", configuration.getText("doclet.navClassUse"),
222 true, "NavBarFont1");
223 navCellEnd();
224 }
226 /**
227 * Print "PREV PACKAGE" link in the navigation bar.
228 */
229 protected void navLinkPrevious() {
230 if (prev == null) {
231 printText("doclet.Prev_Package");
232 } else {
233 String path = DirectoryManager.getRelativePath(packageDoc.name(),
234 prev.name());
235 printHyperLink(path + "package-summary.html", "",
236 configuration.getText("doclet.Prev_Package"), true);
237 }
238 }
240 /**
241 * Print "NEXT PACKAGE" link in the navigation bar.
242 */
243 protected void navLinkNext() {
244 if (next == null) {
245 printText("doclet.Next_Package");
246 } else {
247 String path = DirectoryManager.getRelativePath(packageDoc.name(),
248 next.name());
249 printHyperLink(path + "package-summary.html", "",
250 configuration.getText("doclet.Next_Package"), true);
251 }
252 }
254 /**
255 * Print "Tree" link in the navigation bar. This will be link to the package
256 * tree file.
257 */
258 protected void navLinkTree() {
259 navCellStart();
260 printHyperLink("package-tree.html", "", configuration.getText("doclet.Tree"),
261 true, "NavBarFont1");
262 navCellEnd();
263 }
265 /**
266 * Highlight "Package" in the navigation bar, as this is the package page.
267 */
268 protected void navLinkPackage() {
269 navCellRevStart();
270 fontStyle("NavBarFont1Rev");
271 strongText("doclet.Package");
272 fontEnd();
273 navCellEnd();
274 }
275 }