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

changeset 1
9a66ca7c79fa
child 182
47a62d8d98b4
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HelpWriter.java	Sat Dec 01 00:00:00 2007 +0000
     1.3 @@ -0,0 +1,230 @@
     1.4 +/*
     1.5 + * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Sun designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Sun in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or
    1.26 + * have any questions.
    1.27 + */
    1.28 +
    1.29 +package com.sun.tools.doclets.formats.html;
    1.30 +
    1.31 +import com.sun.tools.doclets.internal.toolkit.util.*;
    1.32 +import java.io.*;
    1.33 +
    1.34 +/**
    1.35 + * Generate the Help File for the generated API documentation. The help file
    1.36 + * contents are helpful for browsing the generated documentation.
    1.37 + *
    1.38 + * @author Atul M Dambalkar
    1.39 + */
    1.40 +public class HelpWriter extends HtmlDocletWriter {
    1.41 +
    1.42 +    /**
    1.43 +     * Constructor to construct HelpWriter object.
    1.44 +     * @param filename File to be generated.
    1.45 +     */
    1.46 +    public HelpWriter(ConfigurationImpl configuration,
    1.47 +                      String filename) throws IOException {
    1.48 +        super(configuration, filename);
    1.49 +    }
    1.50 +
    1.51 +    /**
    1.52 +     * Construct the HelpWriter object and then use it to generate the help
    1.53 +     * file. The name of the generated file is "help-doc.html". The help file
    1.54 +     * will get generated if and only if "-helpfile" and "-nohelp" is not used
    1.55 +     * on the command line.
    1.56 +     * @throws DocletAbortException
    1.57 +     */
    1.58 +    public static void generate(ConfigurationImpl configuration) {
    1.59 +        HelpWriter helpgen;
    1.60 +        String filename = "";
    1.61 +        try {
    1.62 +            filename = "help-doc.html";
    1.63 +            helpgen = new HelpWriter(configuration, filename);
    1.64 +            helpgen.generateHelpFile();
    1.65 +            helpgen.close();
    1.66 +        } catch (IOException exc) {
    1.67 +            configuration.standardmessage.error(
    1.68 +                        "doclet.exception_encountered",
    1.69 +                        exc.toString(), filename);
    1.70 +            throw new DocletAbortException();
    1.71 +        }
    1.72 +    }
    1.73 +
    1.74 +    /**
    1.75 +     * Generate the help file contents.
    1.76 +     */
    1.77 +    protected void generateHelpFile() {
    1.78 +        printHtmlHeader(configuration.getText("doclet.Window_Help_title"),
    1.79 +            null, true);
    1.80 +        printTop();
    1.81 +        navLinks(true);  hr();
    1.82 +
    1.83 +        printHelpFileContents();
    1.84 +
    1.85 +        navLinks(false);
    1.86 +        printBottom();
    1.87 +        printBodyHtmlEnd();
    1.88 +    }
    1.89 +
    1.90 +    /**
    1.91 +     * Print the help file contents from the resource file. While generating the
    1.92 +     * help file contents it also keeps track of user options. If "-notree"
    1.93 +     * is used, then the "overview-tree.html" will not get generated and hence
    1.94 +     * help information also will not get generated.
    1.95 +     */
    1.96 +    protected void printHelpFileContents() {
    1.97 +        center(); h1(); printText("doclet.Help_line_1"); h1End(); centerEnd();
    1.98 +        printText("doclet.Help_line_2");
    1.99 +        if (configuration.createoverview) {
   1.100 +            h3(); printText("doclet.Overview"); h3End();
   1.101 +            blockquote(); p();
   1.102 +            printText("doclet.Help_line_3",
   1.103 +                getHyperLink("overview-summary.html",
   1.104 +                configuration.getText("doclet.Overview")));
   1.105 +            blockquoteEnd();
   1.106 +        }
   1.107 +        h3(); printText("doclet.Package"); h3End();
   1.108 +        blockquote(); p(); printText("doclet.Help_line_4");
   1.109 +        ul();
   1.110 +        li(); printText("doclet.Interfaces_Italic");
   1.111 +        li(); printText("doclet.Classes");
   1.112 +        li(); printText("doclet.Enums");
   1.113 +        li(); printText("doclet.Exceptions");
   1.114 +        li(); printText("doclet.Errors");
   1.115 +        li(); printText("doclet.AnnotationTypes");
   1.116 +        ulEnd();
   1.117 +        blockquoteEnd();
   1.118 +        h3(); printText("doclet.Help_line_5"); h3End();
   1.119 +        blockquote(); p(); printText("doclet.Help_line_6");
   1.120 +        ul();
   1.121 +        li(); printText("doclet.Help_line_7");
   1.122 +        li(); printText("doclet.Help_line_8");
   1.123 +        li(); printText("doclet.Help_line_9");
   1.124 +        li(); printText("doclet.Help_line_10");
   1.125 +        li(); printText("doclet.Help_line_11");
   1.126 +        li(); printText("doclet.Help_line_12");
   1.127 +        p();
   1.128 +        li(); printText("doclet.Nested_Class_Summary");
   1.129 +        li(); printText("doclet.Field_Summary");
   1.130 +        li(); printText("doclet.Constructor_Summary");
   1.131 +        li(); printText("doclet.Method_Summary");
   1.132 +        p();
   1.133 +        li(); printText("doclet.Field_Detail");
   1.134 +        li(); printText("doclet.Constructor_Detail");
   1.135 +        li(); printText("doclet.Method_Detail");
   1.136 +        ulEnd();
   1.137 +        printText("doclet.Help_line_13");
   1.138 +        blockquoteEnd();
   1.139 +
   1.140 +        //Annotation Types
   1.141 +        blockquoteEnd();
   1.142 +        h3(); printText("doclet.AnnotationType"); h3End();
   1.143 +        blockquote(); p(); printText("doclet.Help_annotation_type_line_1");
   1.144 +        ul();
   1.145 +        li(); printText("doclet.Help_annotation_type_line_2");
   1.146 +        li(); printText("doclet.Help_annotation_type_line_3");
   1.147 +        li(); printText("doclet.Annotation_Type_Required_Member_Summary");
   1.148 +        li(); printText("doclet.Annotation_Type_Optional_Member_Summary");
   1.149 +        li(); printText("doclet.Annotation_Type_Member_Detail");
   1.150 +        ulEnd();
   1.151 +        blockquoteEnd();
   1.152 +
   1.153 +        //Enums
   1.154 +        blockquoteEnd();
   1.155 +        h3(); printText("doclet.Enum"); h3End();
   1.156 +        blockquote(); p(); printText("doclet.Help_enum_line_1");
   1.157 +        ul();
   1.158 +        li(); printText("doclet.Help_enum_line_2");
   1.159 +        li(); printText("doclet.Help_enum_line_3");
   1.160 +        li(); printText("doclet.Enum_Constant_Summary");
   1.161 +        li(); printText("doclet.Enum_Constant_Detail");
   1.162 +        ulEnd();
   1.163 +        blockquoteEnd();
   1.164 +
   1.165 +        if (configuration.classuse) {
   1.166 +            h3(); printText("doclet.Help_line_14"); h3End();
   1.167 +            blockquote();
   1.168 +            printText("doclet.Help_line_15");
   1.169 +            blockquoteEnd();
   1.170 +        }
   1.171 +        if (configuration.createtree) {
   1.172 +            h3(); printText("doclet.Help_line_16"); h3End();
   1.173 +            blockquote();
   1.174 +            printText("doclet.Help_line_17_with_tree_link",
   1.175 +                 getHyperLink("overview-tree.html",
   1.176 +                 configuration.getText("doclet.Class_Hierarchy")));
   1.177 +            ul();
   1.178 +            li(); printText("doclet.Help_line_18");
   1.179 +            li(); printText("doclet.Help_line_19");
   1.180 +            ulEnd();
   1.181 +            blockquoteEnd();
   1.182 +        }
   1.183 +        if (!(configuration.nodeprecatedlist ||
   1.184 +                  configuration.nodeprecated)) {
   1.185 +            h3(); printText("doclet.Deprecated_API"); h3End();
   1.186 +            blockquote();
   1.187 +            printText("doclet.Help_line_20_with_deprecated_api_link",
   1.188 +                getHyperLink("deprecated-list.html",
   1.189 +                configuration.getText("doclet.Deprecated_API")));
   1.190 +            blockquoteEnd();
   1.191 +        }
   1.192 +        if (configuration.createindex) {
   1.193 +            String indexlink;
   1.194 +            if (configuration.splitindex) {
   1.195 +                indexlink = getHyperLink("index-files/index-1.html",
   1.196 +                    configuration.getText("doclet.Index"));
   1.197 +            } else {
   1.198 +                indexlink = getHyperLink("index-all.html",
   1.199 +                    configuration.getText("doclet.Index"));
   1.200 +            }
   1.201 +            h3(); printText("doclet.Help_line_21"); h3End();
   1.202 +            blockquote();
   1.203 +            printText("doclet.Help_line_22", indexlink);
   1.204 +            blockquoteEnd();
   1.205 +        }
   1.206 +        h3(); printText("doclet.Help_line_23"); h3End();
   1.207 +        printText("doclet.Help_line_24");
   1.208 +        h3(); printText("doclet.Help_line_25"); h3End();
   1.209 +        printText("doclet.Help_line_26"); p();
   1.210 +
   1.211 +        h3(); printText("doclet.Serialized_Form"); h3End();
   1.212 +        printText("doclet.Help_line_27"); p();
   1.213 +
   1.214 +        h3(); printText("doclet.Constants_Summary"); h3End();
   1.215 +        printText("doclet.Help_line_28"); p();
   1.216 +
   1.217 +        font("-1"); em();
   1.218 +        printText("doclet.Help_line_29");
   1.219 +        emEnd(); fontEnd(); br();
   1.220 +        hr();
   1.221 +    }
   1.222 +
   1.223 +    /**
   1.224 +     * Highlight the word "Help" in the navigation bar as this is the help file.
   1.225 +     */
   1.226 +    protected void navLinkHelp() {
   1.227 +        navCellRevStart();
   1.228 +        fontStyle("NavBarFont1Rev");
   1.229 +        boldText("doclet.Help");
   1.230 +        fontEnd();
   1.231 +        navCellEnd();
   1.232 +    }
   1.233 +}

mercurial