src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java

Thu, 08 Jan 2009 16:26:59 -0800

author
bpatel
date
Thu, 08 Jan 2009 16:26:59 -0800
changeset 182
47a62d8d98b4
parent 1
9a66ca7c79fa
child 554
9d9f26857129
permissions
-rw-r--r--

6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
Reviewed-by: jjg

     1 /*
     2  * Copyright 1998-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.util.*;
    29 import java.io.*;
    31 /**
    32  * Generate the Help File for the generated API documentation. The help file
    33  * contents are helpful for browsing the generated documentation.
    34  *
    35  * @author Atul M Dambalkar
    36  */
    37 public class HelpWriter extends HtmlDocletWriter {
    39     /**
    40      * Constructor to construct HelpWriter object.
    41      * @param filename File to be generated.
    42      */
    43     public HelpWriter(ConfigurationImpl configuration,
    44                       String filename) throws IOException {
    45         super(configuration, filename);
    46     }
    48     /**
    49      * Construct the HelpWriter object and then use it to generate the help
    50      * file. The name of the generated file is "help-doc.html". The help file
    51      * will get generated if and only if "-helpfile" and "-nohelp" is not used
    52      * on the command line.
    53      * @throws DocletAbortException
    54      */
    55     public static void generate(ConfigurationImpl configuration) {
    56         HelpWriter helpgen;
    57         String filename = "";
    58         try {
    59             filename = "help-doc.html";
    60             helpgen = new HelpWriter(configuration, filename);
    61             helpgen.generateHelpFile();
    62             helpgen.close();
    63         } catch (IOException exc) {
    64             configuration.standardmessage.error(
    65                         "doclet.exception_encountered",
    66                         exc.toString(), filename);
    67             throw new DocletAbortException();
    68         }
    69     }
    71     /**
    72      * Generate the help file contents.
    73      */
    74     protected void generateHelpFile() {
    75         printHtmlHeader(configuration.getText("doclet.Window_Help_title"),
    76             null, true);
    77         printTop();
    78         navLinks(true);  hr();
    80         printHelpFileContents();
    82         navLinks(false);
    83         printBottom();
    84         printBodyHtmlEnd();
    85     }
    87     /**
    88      * Print the help file contents from the resource file. While generating the
    89      * help file contents it also keeps track of user options. If "-notree"
    90      * is used, then the "overview-tree.html" will not get generated and hence
    91      * help information also will not get generated.
    92      */
    93     protected void printHelpFileContents() {
    94         center(); h1(); printText("doclet.Help_line_1"); h1End(); centerEnd();
    95         printText("doclet.Help_line_2");
    96         if (configuration.createoverview) {
    97             h3(); printText("doclet.Overview"); h3End();
    98             blockquote(); p();
    99             printText("doclet.Help_line_3",
   100                 getHyperLink("overview-summary.html",
   101                 configuration.getText("doclet.Overview")));
   102             blockquoteEnd();
   103         }
   104         h3(); printText("doclet.Package"); h3End();
   105         blockquote(); p(); printText("doclet.Help_line_4");
   106         ul();
   107         li(); printText("doclet.Interfaces_Italic");
   108         li(); printText("doclet.Classes");
   109         li(); printText("doclet.Enums");
   110         li(); printText("doclet.Exceptions");
   111         li(); printText("doclet.Errors");
   112         li(); printText("doclet.AnnotationTypes");
   113         ulEnd();
   114         blockquoteEnd();
   115         h3(); printText("doclet.Help_line_5"); h3End();
   116         blockquote(); p(); printText("doclet.Help_line_6");
   117         ul();
   118         li(); printText("doclet.Help_line_7");
   119         li(); printText("doclet.Help_line_8");
   120         li(); printText("doclet.Help_line_9");
   121         li(); printText("doclet.Help_line_10");
   122         li(); printText("doclet.Help_line_11");
   123         li(); printText("doclet.Help_line_12");
   124         p();
   125         li(); printText("doclet.Nested_Class_Summary");
   126         li(); printText("doclet.Field_Summary");
   127         li(); printText("doclet.Constructor_Summary");
   128         li(); printText("doclet.Method_Summary");
   129         p();
   130         li(); printText("doclet.Field_Detail");
   131         li(); printText("doclet.Constructor_Detail");
   132         li(); printText("doclet.Method_Detail");
   133         ulEnd();
   134         printText("doclet.Help_line_13");
   135         blockquoteEnd();
   137         //Annotation Types
   138         blockquoteEnd();
   139         h3(); printText("doclet.AnnotationType"); h3End();
   140         blockquote(); p(); printText("doclet.Help_annotation_type_line_1");
   141         ul();
   142         li(); printText("doclet.Help_annotation_type_line_2");
   143         li(); printText("doclet.Help_annotation_type_line_3");
   144         li(); printText("doclet.Annotation_Type_Required_Member_Summary");
   145         li(); printText("doclet.Annotation_Type_Optional_Member_Summary");
   146         li(); printText("doclet.Annotation_Type_Member_Detail");
   147         ulEnd();
   148         blockquoteEnd();
   150         //Enums
   151         blockquoteEnd();
   152         h3(); printText("doclet.Enum"); h3End();
   153         blockquote(); p(); printText("doclet.Help_enum_line_1");
   154         ul();
   155         li(); printText("doclet.Help_enum_line_2");
   156         li(); printText("doclet.Help_enum_line_3");
   157         li(); printText("doclet.Enum_Constant_Summary");
   158         li(); printText("doclet.Enum_Constant_Detail");
   159         ulEnd();
   160         blockquoteEnd();
   162         if (configuration.classuse) {
   163             h3(); printText("doclet.Help_line_14"); h3End();
   164             blockquote();
   165             printText("doclet.Help_line_15");
   166             blockquoteEnd();
   167         }
   168         if (configuration.createtree) {
   169             h3(); printText("doclet.Help_line_16"); h3End();
   170             blockquote();
   171             printText("doclet.Help_line_17_with_tree_link",
   172                  getHyperLink("overview-tree.html",
   173                  configuration.getText("doclet.Class_Hierarchy")));
   174             ul();
   175             li(); printText("doclet.Help_line_18");
   176             li(); printText("doclet.Help_line_19");
   177             ulEnd();
   178             blockquoteEnd();
   179         }
   180         if (!(configuration.nodeprecatedlist ||
   181                   configuration.nodeprecated)) {
   182             h3(); printText("doclet.Deprecated_API"); h3End();
   183             blockquote();
   184             printText("doclet.Help_line_20_with_deprecated_api_link",
   185                 getHyperLink("deprecated-list.html",
   186                 configuration.getText("doclet.Deprecated_API")));
   187             blockquoteEnd();
   188         }
   189         if (configuration.createindex) {
   190             String indexlink;
   191             if (configuration.splitindex) {
   192                 indexlink = getHyperLink("index-files/index-1.html",
   193                     configuration.getText("doclet.Index"));
   194             } else {
   195                 indexlink = getHyperLink("index-all.html",
   196                     configuration.getText("doclet.Index"));
   197             }
   198             h3(); printText("doclet.Help_line_21"); h3End();
   199             blockquote();
   200             printText("doclet.Help_line_22", indexlink);
   201             blockquoteEnd();
   202         }
   203         h3(); printText("doclet.Help_line_23"); h3End();
   204         printText("doclet.Help_line_24");
   205         h3(); printText("doclet.Help_line_25"); h3End();
   206         printText("doclet.Help_line_26"); p();
   208         h3(); printText("doclet.Serialized_Form"); h3End();
   209         printText("doclet.Help_line_27"); p();
   211         h3(); printText("doclet.Constants_Summary"); h3End();
   212         printText("doclet.Help_line_28"); p();
   214         font("-1"); em();
   215         printText("doclet.Help_line_29");
   216         emEnd(); fontEnd(); br();
   217         hr();
   218     }
   220     /**
   221      * Highlight the word "Help" in the navigation bar as this is the help file.
   222      */
   223     protected void navLinkHelp() {
   224         navCellRevStart();
   225         fontStyle("NavBarFont1Rev");
   226         strongText("doclet.Help");
   227         fontEnd();
   228         navCellEnd();
   229     }
   230 }

mercurial