langtools/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java
author bpatel
Thu, 08 Jan 2009 16:26:59 -0800
changeset 1787 1aa079321cd2
parent 10 06bc494ca11e
child 5520 86e4b9a9da40
permissions -rw-r--r--
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
06bc494ca11e Initial load
duke
parents:
diff changeset
     2
 * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
06bc494ca11e Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
06bc494ca11e Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
06bc494ca11e Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
06bc494ca11e Initial load
duke
parents:
diff changeset
    23
 * have any questions.
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.doclets.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import java.io.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * Generate the Help File for the generated API documentation. The help file
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * contents are helpful for browsing the generated documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
public class HelpWriter extends HtmlDocletWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
     * Constructor to construct HelpWriter object.
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
     * @param filename File to be generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
    public HelpWriter(ConfigurationImpl configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
                      String filename) throws IOException {
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
        super(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
     * Construct the HelpWriter object and then use it to generate the help
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     * file. The name of the generated file is "help-doc.html". The help file
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * will get generated if and only if "-helpfile" and "-nohelp" is not used
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     * on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
     * @throws DocletAbortException
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    public static void generate(ConfigurationImpl configuration) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
        HelpWriter helpgen;
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
        String filename = "";
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
            filename = "help-doc.html";
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
            helpgen = new HelpWriter(configuration, filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
            helpgen.generateHelpFile();
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
            helpgen.close();
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
            configuration.standardmessage.error(
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
                        "doclet.exception_encountered",
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
                        exc.toString(), filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * Generate the help file contents.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    protected void generateHelpFile() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        printHtmlHeader(configuration.getText("doclet.Window_Help_title"),
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
            null, true);
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
        printTop();
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
        navLinks(true);  hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
        printHelpFileContents();
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        navLinks(false);
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        printBottom();
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
        printBodyHtmlEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * Print the help file contents from the resource file. While generating the
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * help file contents it also keeps track of user options. If "-notree"
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * is used, then the "overview-tree.html" will not get generated and hence
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * help information also will not get generated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
    protected void printHelpFileContents() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        center(); h1(); printText("doclet.Help_line_1"); h1End(); centerEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
        printText("doclet.Help_line_2");
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
        if (configuration.createoverview) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
            h3(); printText("doclet.Overview"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
            blockquote(); p();
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
            printText("doclet.Help_line_3",
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
                getHyperLink("overview-summary.html",
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
                configuration.getText("doclet.Overview")));
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
            blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
        h3(); printText("doclet.Package"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
        blockquote(); p(); printText("doclet.Help_line_4");
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        ul();
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        li(); printText("doclet.Interfaces_Italic");
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        li(); printText("doclet.Classes");
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        li(); printText("doclet.Enums");
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        li(); printText("doclet.Exceptions");
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        li(); printText("doclet.Errors");
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        li(); printText("doclet.AnnotationTypes");
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        ulEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
        blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
        h3(); printText("doclet.Help_line_5"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
        blockquote(); p(); printText("doclet.Help_line_6");
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        ul();
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        li(); printText("doclet.Help_line_7");
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
        li(); printText("doclet.Help_line_8");
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        li(); printText("doclet.Help_line_9");
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        li(); printText("doclet.Help_line_10");
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        li(); printText("doclet.Help_line_11");
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        li(); printText("doclet.Help_line_12");
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        li(); printText("doclet.Nested_Class_Summary");
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        li(); printText("doclet.Field_Summary");
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
        li(); printText("doclet.Constructor_Summary");
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        li(); printText("doclet.Method_Summary");
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
        p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        li(); printText("doclet.Field_Detail");
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        li(); printText("doclet.Constructor_Detail");
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        li(); printText("doclet.Method_Detail");
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
        ulEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        printText("doclet.Help_line_13");
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
        blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        //Annotation Types
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        h3(); printText("doclet.AnnotationType"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
        blockquote(); p(); printText("doclet.Help_annotation_type_line_1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        ul();
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
        li(); printText("doclet.Help_annotation_type_line_2");
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        li(); printText("doclet.Help_annotation_type_line_3");
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
        li(); printText("doclet.Annotation_Type_Required_Member_Summary");
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        li(); printText("doclet.Annotation_Type_Optional_Member_Summary");
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        li(); printText("doclet.Annotation_Type_Member_Detail");
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
        ulEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        //Enums
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        h3(); printText("doclet.Enum"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
        blockquote(); p(); printText("doclet.Help_enum_line_1");
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        ul();
06bc494ca11e Initial load
duke
parents:
diff changeset
   155
        li(); printText("doclet.Help_enum_line_2");
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        li(); printText("doclet.Help_enum_line_3");
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
        li(); printText("doclet.Enum_Constant_Summary");
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        li(); printText("doclet.Enum_Constant_Detail");
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
        ulEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
        if (configuration.classuse) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
            h3(); printText("doclet.Help_line_14"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
            blockquote();
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
            printText("doclet.Help_line_15");
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
            blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        if (configuration.createtree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
            h3(); printText("doclet.Help_line_16"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
            blockquote();
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
            printText("doclet.Help_line_17_with_tree_link",
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
                 getHyperLink("overview-tree.html",
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
                 configuration.getText("doclet.Class_Hierarchy")));
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
            ul();
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
            li(); printText("doclet.Help_line_18");
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
            li(); printText("doclet.Help_line_19");
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
            ulEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
            blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        if (!(configuration.nodeprecatedlist ||
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
                  configuration.nodeprecated)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
            h3(); printText("doclet.Deprecated_API"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
            blockquote();
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
            printText("doclet.Help_line_20_with_deprecated_api_link",
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
                getHyperLink("deprecated-list.html",
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
                configuration.getText("doclet.Deprecated_API")));
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
            blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
        if (configuration.createindex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
            String indexlink;
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            if (configuration.splitindex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
                indexlink = getHyperLink("index-files/index-1.html",
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
                    configuration.getText("doclet.Index"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
                indexlink = getHyperLink("index-all.html",
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
                    configuration.getText("doclet.Index"));
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
            h3(); printText("doclet.Help_line_21"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
            blockquote();
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
            printText("doclet.Help_line_22", indexlink);
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
            blockquoteEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        h3(); printText("doclet.Help_line_23"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
        printText("doclet.Help_line_24");
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
        h3(); printText("doclet.Help_line_25"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        printText("doclet.Help_line_26"); p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
        h3(); printText("doclet.Serialized_Form"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        printText("doclet.Help_line_27"); p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
06bc494ca11e Initial load
duke
parents:
diff changeset
   211
        h3(); printText("doclet.Constants_Summary"); h3End();
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        printText("doclet.Help_line_28"); p();
06bc494ca11e Initial load
duke
parents:
diff changeset
   213
06bc494ca11e Initial load
duke
parents:
diff changeset
   214
        font("-1"); em();
06bc494ca11e Initial load
duke
parents:
diff changeset
   215
        printText("doclet.Help_line_29");
06bc494ca11e Initial load
duke
parents:
diff changeset
   216
        emEnd(); fontEnd(); br();
06bc494ca11e Initial load
duke
parents:
diff changeset
   217
        hr();
06bc494ca11e Initial load
duke
parents:
diff changeset
   218
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   219
06bc494ca11e Initial load
duke
parents:
diff changeset
   220
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   221
     * Highlight the word "Help" in the navigation bar as this is the help file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
    protected void navLinkHelp() {
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
        navCellRevStart();
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        fontStyle("NavBarFont1Rev");
1787
1aa079321cd2 6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents: 10
diff changeset
   226
        strongText("doclet.Help");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
        fontEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
        navCellEnd();
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
}