001    /*
002     * Copyright 1998-2005 Sun Microsystems, Inc.  All Rights Reserved.
003     * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004     *
005     * This code is free software; you can redistribute it and/or modify it
006     * under the terms of the GNU General Public License version 2 only, as
007     * published by the Free Software Foundation.  Sun designates this
008     * particular file as subject to the "Classpath" exception as provided
009     * by Sun in the LICENSE file that accompanied this code.
010     *
011     * This code is distributed in the hope that it will be useful, but WITHOUT
012     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013     * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014     * version 2 for more details (a copy is included in the LICENSE file that
015     * accompanied this code).
016     *
017     * You should have received a copy of the GNU General Public License version
018     * 2 along with this work; if not, write to the Free Software Foundation,
019     * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020     *
021     * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022     * CA 95054 USA or visit www.sun.com if you need additional information or
023     * have any questions.
024     */
025    
026    package com.sun.tools.doclets.formats.html;
027    
028    import com.sun.tools.doclets.internal.toolkit.util.*;
029    import java.io.*;
030    
031    /**
032     * Generate the Help File for the generated API documentation. The help file
033     * contents are helpful for browsing the generated documentation.
034     *
035     * @author Atul M Dambalkar
036     */
037    public class HelpWriter extends HtmlDocletWriter {
038    
039        /**
040         * Constructor to construct HelpWriter object.
041         * @param filename File to be generated.
042         */
043        public HelpWriter(ConfigurationImpl configuration,
044                          String filename) throws IOException {
045            super(configuration, filename);
046        }
047    
048        /**
049         * Construct the HelpWriter object and then use it to generate the help
050         * file. The name of the generated file is "help-doc.html". The help file
051         * will get generated if and only if "-helpfile" and "-nohelp" is not used
052         * on the command line.
053         * @throws DocletAbortException
054         */
055        public static void generate(ConfigurationImpl configuration) {
056            HelpWriter helpgen;
057            String filename = "";
058            try {
059                filename = "help-doc.html";
060                helpgen = new HelpWriter(configuration, filename);
061                helpgen.generateHelpFile();
062                helpgen.close();
063            } catch (IOException exc) {
064                configuration.standardmessage.error(
065                            "doclet.exception_encountered",
066                            exc.toString(), filename);
067                throw new DocletAbortException();
068            }
069        }
070    
071        /**
072         * Generate the help file contents.
073         */
074        protected void generateHelpFile() {
075            printHtmlHeader(configuration.getText("doclet.Window_Help_title"),
076                null, true);
077            printTop();
078            navLinks(true);  hr();
079    
080            printHelpFileContents();
081    
082            navLinks(false);
083            printBottom();
084            printBodyHtmlEnd();
085        }
086    
087        /**
088         * Print the help file contents from the resource file. While generating the
089         * help file contents it also keeps track of user options. If "-notree"
090         * is used, then the "overview-tree.html" will not get generated and hence
091         * help information also will not get generated.
092         */
093        protected void printHelpFileContents() {
094            center(); h1(); printText("doclet.Help_line_1"); h1End(); centerEnd();
095            printText("doclet.Help_line_2");
096            if (configuration.createoverview) {
097                h3(); printText("doclet.Overview"); h3End();
098                blockquote(); p();
099                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();
136    
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();
149    
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();
161    
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();
207    
208            h3(); printText("doclet.Serialized_Form"); h3End();
209            printText("doclet.Help_line_27"); p();
210    
211            h3(); printText("doclet.Constants_Summary"); h3End();
212            printText("doclet.Help_line_28"); p();
213    
214            font("-1"); em();
215            printText("doclet.Help_line_29");
216            emEnd(); fontEnd(); br();
217            hr();
218        }
219    
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    }