langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
author bpatel
Mon, 19 Nov 2012 16:10:34 -0800
changeset 14549 0599d73bf1da
parent 14542 7062120649c2
child 15723 58a73dac9ee4
permissions -rw-r--r--
8002304: Group methods by types in methods summary section Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9894
diff changeset
     2
 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
10
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
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
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
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 1652
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
package com.sun.tools.doclets.formats.html;
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
14258
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9894
diff changeset
    27
import java.io.*;
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9894
diff changeset
    28
import java.util.*;
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9894
diff changeset
    29
8d2148961366 8000663: clean up langtools imports
jjg
parents: 9894
diff changeset
    30
import com.sun.javadoc.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import com.sun.tools.doclets.internal.toolkit.builders.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
06bc494ca11e Initial load
duke
parents:
diff changeset
    35
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * The class with "start" method, calls individual Writers.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    38
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    39
 *  If you write code that depends on this, you do so at your own risk.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    40
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    41
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    42
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
public class HtmlDoclet extends AbstractDoclet {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    49
    // An instance will be created by validOptions, and used by start.
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    50
    private static HtmlDoclet docletToStart = null;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    51
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    52
    public HtmlDoclet() {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    53
        configuration = new ConfigurationImpl();
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    54
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     * The global configuration information for this run.
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     */
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    59
    public final ConfigurationImpl configuration;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     * The "start" method as required by Javadoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
     * @param root the root of the documentation tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * @see com.sun.javadoc.RootDoc
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * @return true if the doclet ran without encountering any errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    public static boolean start(RootDoc root) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    69
        // In typical use, options will have been set up by calling validOptions,
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    70
        // which will create an HtmlDoclet for use here.
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    71
        HtmlDoclet doclet;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    72
        if (docletToStart != null) {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    73
            doclet = docletToStart;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    74
            docletToStart = null;
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    75
        } else {
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    76
            doclet = new HtmlDoclet();
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    77
        }
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    78
        return doclet.start(doclet, root);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     * Create the configuration instance.
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     * Override this method to use a different
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * configuration.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    public Configuration configuration() {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    87
        return configuration;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Start the generation of files. Call generate methods in the individual
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     * writers, which will in turn genrate the documentation files. Call the
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * TreeWriter generation first to ensure the Class Hierarchy is built
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * first and then can be used in the later generation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     * For new format.
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
     * @see com.sun.javadoc.RootDoc
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    protected void generateOtherFiles(RootDoc root, ClassTree classtree)
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
            throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        super.generateOtherFiles(root, classtree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        if (configuration.linksource) {
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14260
diff changeset
   104
            SourceToHTMLConverter.convertRoot(configuration,
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14260
diff changeset
   105
                root, DocPaths.SOURCE_OUTPUT);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14260
diff changeset
   108
        if (configuration.topFile.isEmpty()) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
            configuration.standardmessage.
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
                error("doclet.No_Non_Deprecated_Classes_To_Document");
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
        boolean nodeprecated = configuration.nodeprecated;
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   114
        performCopy(configuration.helpfile);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   115
        performCopy(configuration.stylesheetfile);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   116
        copyResourceFile("background.gif");
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   117
        copyResourceFile("tab.gif");
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   118
        copyResourceFile("titlebar.gif");
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   119
        copyResourceFile("titlebar_end.gif");
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14542
diff changeset
   120
        copyResourceFile("activetitlebar.gif");
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14542
diff changeset
   121
        copyResourceFile("activetitlebar_end.gif");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
        // do early to reduce memory footprint
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        if (configuration.classuse) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
            ClassUseWriter.generate(configuration, classtree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        IndexBuilder indexbuilder = new IndexBuilder(configuration, nodeprecated);
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
        if (configuration.createtree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
            TreeWriter.generate(configuration, classtree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
        if (configuration.createindex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
            if (configuration.splitindex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
                SplitIndexWriter.generate(configuration, indexbuilder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
                SingleIndexWriter.generate(configuration, indexbuilder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
        if (!(configuration.nodeprecatedlist || nodeprecated)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
            DeprecatedListWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        AllClassesFrameWriter.generate(configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            new IndexBuilder(configuration, nodeprecated, true));
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        FrameOutputWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
        if (configuration.createoverview) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
            PackageIndexWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
        if (configuration.helpfile.length() == 0 &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
            !configuration.nohelp) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   153
            HelpWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   154
        }
7641
8b552db25f99 7006270: Several javadoc regression tests are failing on windows
bpatel
parents: 7614
diff changeset
   155
        // If a stylesheet file is not specified, copy the default stylesheet
8b552db25f99 7006270: Several javadoc regression tests are failing on windows
bpatel
parents: 7614
diff changeset
   156
        // and replace newline with platform-specific newline.
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14542
diff changeset
   157
        DocFile f;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        if (configuration.stylesheetfile.length() == 0) {
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14542
diff changeset
   159
            f = DocFile.createFileForOutput(configuration, DocPaths.STYLESHEET);
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   160
            f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.STYLESHEET), false, true);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
        }
14549
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14542
diff changeset
   162
        f = DocFile.createFileForOutput(configuration, DocPaths.JAVASCRIPT);
0599d73bf1da 8002304: Group methods by types in methods summary section
bpatel
parents: 14542
diff changeset
   163
        f.copyResource(DocPaths.RESOURCES.resolve(DocPaths.JAVASCRIPT), true, true);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    protected void generateClassFiles(ClassDoc[] arr, ClassTree classtree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
        Arrays.sort(arr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
        for(int i = 0; i < arr.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
            if (!(configuration.isGeneratedDoc(arr[i]) && arr[i].isIncluded())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
            ClassDoc prev = (i == 0)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
                null:
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
                arr[i-1];
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
            ClassDoc curr = arr[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
            ClassDoc next = (i+1 == arr.length)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
                null:
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
                arr[i+1];
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
            try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
                if (curr.isAnnotationType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
                    AbstractBuilder annotationTypeBuilder =
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
                        configuration.getBuilderFactory()
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
                            .getAnnotationTypeBuilder((AnnotationTypeDoc) curr,
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
                                prev, next);
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
                    annotationTypeBuilder.build();
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
                    AbstractBuilder classBuilder =
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
                        configuration.getBuilderFactory()
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
                            .getClassBuilder(curr, prev, next, classtree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
                    classBuilder.build();
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
            } catch (Exception e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
                e.printStackTrace();
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
                throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    protected void generatePackageFiles(ClassTree classtree) throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
        PackageDoc[] packages = configuration.packages;
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
        if (packages.length > 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   208
            PackageIndexFrameWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
        PackageDoc prev = null, next;
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   211
        for (int i = 0; i < packages.length; i++) {
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   212
            // if -nodeprecated option is set and the package is marked as
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   213
            // deprecated, do not generate the package-summary.html, package-frame.html
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   214
            // and package-tree.html pages for that package.
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   215
            if (!(configuration.nodeprecated && Util.isDeprecated(packages[i]))) {
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   216
                PackageFrameWriter.generate(configuration, packages[i]);
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   217
                next = (i + 1 < packages.length &&
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   218
                        packages[i + 1].name().length() > 0) ? packages[i + 1] : null;
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   219
                //If the next package is unnamed package, skip 2 ahead if possible
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   220
                next = (i + 2 < packages.length && next == null) ? packages[i + 2] : next;
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   221
                AbstractBuilder packageSummaryBuilder =
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   222
                        configuration.getBuilderFactory().getPackageSummaryBuilder(
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   223
                        packages[i], prev, next);
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   224
                packageSummaryBuilder.build();
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   225
                if (configuration.createtree) {
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   226
                    PackageTreeWriter.generate(configuration,
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   227
                            packages[i], prev, next,
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   228
                            configuration.nodeprecated);
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   229
                }
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   230
                prev = packages[i];
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   235
    public static final ConfigurationImpl sharedInstanceForOptions =
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   236
            new ConfigurationImpl();
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   237
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
     * Check for doclet added options here.
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     * @return number of arguments to option. Zero return means
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
     * option not known.  Negative value means error occurred.
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
    public static int optionLength(String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
        // Construct temporary configuration for check
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   246
        return sharedInstanceForOptions.optionLength(option);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
     * Check that options have the correct arguments here.
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
     * <P>
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
     * This method is not required and will default gracefully
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
     * (to true) if absent.
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
     * <P>
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
     * Printing option related error messages (using the provided
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
     * DocErrorReporter) is the responsibility of this method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
     * @return true if the options are valid.
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
    public static boolean validOptions(String options[][],
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
            DocErrorReporter reporter) {
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   262
        docletToStart = new HtmlDoclet();
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
   263
        return docletToStart.configuration.validOptions(options, reporter);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   266
    /**
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   267
     * Copy a file in the resources directory to the destination directory.
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   268
     * @param resource   The name of the resource file to copy
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   269
     */
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   270
    private void copyResourceFile(String resource) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   271
        DocPath p = DocPaths.RESOURCES.resolve(resource);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   272
        DocFile f = DocFile.createFileForOutput(configuration, p);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   273
        f.copyResource(p, false, false);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   274
    }
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   275
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   276
    private void performCopy(String filename) {
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   277
        if (filename.isEmpty())
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   278
            return;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   279
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
        try {
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   281
            DocFile fromfile = DocFile.createFileForInput(configuration, filename);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   282
            DocPath path = DocPath.create(fromfile.getName());
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   283
            DocFile toFile = DocFile.createFileForOutput(configuration, path);
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   284
            if (toFile.isSameFile(fromfile))
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   285
                return;
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   286
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   287
            configuration.message.notice((SourcePosition) null,
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   288
                    "doclet.Copying_File_0_To_File_1",
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   289
                    fromfile.toString(), path.getPath());
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   290
            toFile.copyFile(fromfile);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   291
        } catch (IOException exc) {
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   292
            configuration.message.error((SourcePosition) null,
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   293
                    "doclet.perform_copy_exception_encountered",
06bc494ca11e Initial load
duke
parents:
diff changeset
   294
                    exc.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   295
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   296
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   297
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   298
}