langtools/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDoclet.java
author bpatel
Fri, 17 Jun 2011 20:12:46 -0700
changeset 9894 a0ec54adb051
parent 9606 e5a619cb5dd3
child 14258 8d2148961366
permissions -rw-r--r--
7052425: Change the look and feel of the javadoc generate HTML pages using stylesheet Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
     2
 * Copyright (c) 1997, 2011, 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
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
import com.sun.tools.doclets.internal.toolkit.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.doclets.internal.toolkit.builders.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.doclets.internal.toolkit.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
import com.sun.javadoc.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
import java.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
import java.io.*;
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
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
public class HtmlDoclet extends AbstractDoclet {
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    44
    public HtmlDoclet() {
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    45
        configuration = (ConfigurationImpl) configuration();
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    46
    }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
     * The global configuration information for this run.
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
     */
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    51
    public ConfigurationImpl configuration;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
     * The "start" method as required by Javadoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * @param root the root of the documentation tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     * @see com.sun.javadoc.RootDoc
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
     * @return true if the doclet ran without encountering any errors.
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    public static boolean start(RootDoc root) {
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    61
        try {
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    62
            HtmlDoclet doclet = new HtmlDoclet();
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    63
            return doclet.start(doclet, root);
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    64
        } finally {
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    65
            ConfigurationImpl.reset();
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    66
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * Create the configuration instance.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * Override this method to use a different
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * configuration.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
    public Configuration configuration() {
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
        return ConfigurationImpl.getInstance();
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * Start the generation of files. Call generate methods in the individual
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     * writers, which will in turn genrate the documentation files. Call the
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * TreeWriter generation first to ensure the Class Hierarchy is built
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
     * first and then can be used in the later generation.
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
     * For new format.
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * @see com.sun.javadoc.RootDoc
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
    protected void generateOtherFiles(RootDoc root, ClassTree classtree)
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
            throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
        super.generateOtherFiles(root, classtree);
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
        if (configuration.linksource) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
            if (configuration.destDirName.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
                SourceToHTMLConverter.convertRoot(configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
                    root, configuration.destDirName + File.separator
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
                    + DocletConstants.SOURCE_OUTPUT_DIR_NAME);
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
                SourceToHTMLConverter.convertRoot(configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
                    root, DocletConstants.SOURCE_OUTPUT_DIR_NAME);
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
        if (configuration.topFile.length() == 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
            configuration.standardmessage.
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
                error("doclet.No_Non_Deprecated_Classes_To_Document");
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
        boolean nodeprecated = configuration.nodeprecated;
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
        String configdestdir = configuration.destDirName;
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
        String confighelpfile = configuration.helpfile;
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
        String configstylefile = configuration.stylesheetfile;
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
        performCopy(configdestdir, confighelpfile);
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
        performCopy(configdestdir, configstylefile);
9894
a0ec54adb051 7052425: Change the look and feel of the javadoc generate HTML pages using stylesheet
bpatel
parents: 9606
diff changeset
   113
        Util.copyResourceFile(configuration, "background.gif", false);
a0ec54adb051 7052425: Change the look and feel of the javadoc generate HTML pages using stylesheet
bpatel
parents: 9606
diff changeset
   114
        Util.copyResourceFile(configuration, "tab.gif", false);
a0ec54adb051 7052425: Change the look and feel of the javadoc generate HTML pages using stylesheet
bpatel
parents: 9606
diff changeset
   115
        Util.copyResourceFile(configuration, "titlebar.gif", false);
a0ec54adb051 7052425: Change the look and feel of the javadoc generate HTML pages using stylesheet
bpatel
parents: 9606
diff changeset
   116
        Util.copyResourceFile(configuration, "titlebar_end.gif", false);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
        // do early to reduce memory footprint
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        if (configuration.classuse) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
            ClassUseWriter.generate(configuration, classtree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        IndexBuilder indexbuilder = new IndexBuilder(configuration, nodeprecated);
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
        if (configuration.createtree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
            TreeWriter.generate(configuration, classtree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
        if (configuration.createindex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
            if (configuration.splitindex) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
                SplitIndexWriter.generate(configuration, indexbuilder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
            } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
                SingleIndexWriter.generate(configuration, indexbuilder);
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
        if (!(configuration.nodeprecatedlist || nodeprecated)) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
            DeprecatedListWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
        AllClassesFrameWriter.generate(configuration,
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
            new IndexBuilder(configuration, nodeprecated, true));
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
        FrameOutputWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
        if (configuration.createoverview) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
            PackageIndexWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   145
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
        if (configuration.helpfile.length() == 0 &&
06bc494ca11e Initial load
duke
parents:
diff changeset
   147
            !configuration.nohelp) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   148
            HelpWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
        }
7641
8b552db25f99 7006270: Several javadoc regression tests are failing on windows
bpatel
parents: 7614
diff changeset
   150
        // 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
   151
        // and replace newline with platform-specific newline.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        if (configuration.stylesheetfile.length() == 0) {
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   153
            Util.copyFile(configuration, "stylesheet.css", Util.RESOURCESDIR,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   154
                    (configdestdir.isEmpty()) ?
7641
8b552db25f99 7006270: Several javadoc regression tests are failing on windows
bpatel
parents: 7614
diff changeset
   155
                        System.getProperty("user.dir") : configdestdir, false, true);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   161
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
    protected void generateClassFiles(ClassDoc[] arr, ClassTree classtree) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        Arrays.sort(arr);
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        for(int i = 0; i < arr.length; i++) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   165
            if (!(configuration.isGeneratedDoc(arr[i]) && arr[i].isIncluded())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
                continue;
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
            ClassDoc prev = (i == 0)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
                null:
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
                arr[i-1];
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
            ClassDoc curr = arr[i];
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
            ClassDoc next = (i+1 == arr.length)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
                null:
06bc494ca11e Initial load
duke
parents:
diff changeset
   174
                arr[i+1];
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
            try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
                if (curr.isAnnotationType()) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   177
                    AbstractBuilder annotationTypeBuilder =
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
                        configuration.getBuilderFactory()
06bc494ca11e Initial load
duke
parents:
diff changeset
   179
                            .getAnnotationTypeBuilder((AnnotationTypeDoc) curr,
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
                                prev, next);
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
                    annotationTypeBuilder.build();
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
                } else {
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
                    AbstractBuilder classBuilder =
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
                        configuration.getBuilderFactory()
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
                            .getClassBuilder(curr, prev, next, classtree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   186
                    classBuilder.build();
06bc494ca11e Initial load
duke
parents:
diff changeset
   187
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   188
            } catch (Exception e) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   189
                e.printStackTrace();
06bc494ca11e Initial load
duke
parents:
diff changeset
   190
                throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   191
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
     * {@inheritDoc}
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    protected void generatePackageFiles(ClassTree classtree) throws Exception {
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
        PackageDoc[] packages = configuration.packages;
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
        if (packages.length > 1) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
            PackageIndexFrameWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   203
        PackageDoc prev = null, next;
9606
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   204
        for (int i = 0; i < packages.length; i++) {
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   205
            // 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
   206
            // 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
   207
            // and package-tree.html pages for that package.
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   208
            if (!(configuration.nodeprecated && Util.isDeprecated(packages[i]))) {
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   209
                PackageFrameWriter.generate(configuration, packages[i]);
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   210
                next = (i + 1 < packages.length &&
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   211
                        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
   212
                //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
   213
                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
   214
                AbstractBuilder packageSummaryBuilder =
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   215
                        configuration.getBuilderFactory().getPackageSummaryBuilder(
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   216
                        packages[i], prev, next);
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   217
                packageSummaryBuilder.build();
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   218
                if (configuration.createtree) {
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   219
                    PackageTreeWriter.generate(configuration,
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   220
                            packages[i], prev, next,
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   221
                            configuration.nodeprecated);
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   222
                }
e5a619cb5dd3 6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents: 7681
diff changeset
   223
                prev = packages[i];
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   226
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   227
06bc494ca11e Initial load
duke
parents:
diff changeset
   228
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   229
     * Check for doclet added options here.
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
     * @return number of arguments to option. Zero return means
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
     * option not known.  Negative value means error occurred.
06bc494ca11e Initial load
duke
parents:
diff changeset
   233
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    public static int optionLength(String option) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
        // Construct temporary configuration for check
06bc494ca11e Initial load
duke
parents:
diff changeset
   236
        return (ConfigurationImpl.getInstance()).optionLength(option);
06bc494ca11e Initial load
duke
parents:
diff changeset
   237
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   238
06bc494ca11e Initial load
duke
parents:
diff changeset
   239
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   240
     * Check that options have the correct arguments here.
06bc494ca11e Initial load
duke
parents:
diff changeset
   241
     * <P>
06bc494ca11e Initial load
duke
parents:
diff changeset
   242
     * This method is not required and will default gracefully
06bc494ca11e Initial load
duke
parents:
diff changeset
   243
     * (to true) if absent.
06bc494ca11e Initial load
duke
parents:
diff changeset
   244
     * <P>
06bc494ca11e Initial load
duke
parents:
diff changeset
   245
     * Printing option related error messages (using the provided
06bc494ca11e Initial load
duke
parents:
diff changeset
   246
     * DocErrorReporter) is the responsibility of this method.
06bc494ca11e Initial load
duke
parents:
diff changeset
   247
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   248
     * @return true if the options are valid.
06bc494ca11e Initial load
duke
parents:
diff changeset
   249
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   250
    public static boolean validOptions(String options[][],
06bc494ca11e Initial load
duke
parents:
diff changeset
   251
            DocErrorReporter reporter) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   252
        // Construct temporary configuration for check
06bc494ca11e Initial load
duke
parents:
diff changeset
   253
        return (ConfigurationImpl.getInstance()).validOptions(options, reporter);
06bc494ca11e Initial load
duke
parents:
diff changeset
   254
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   255
06bc494ca11e Initial load
duke
parents:
diff changeset
   256
    private void performCopy(String configdestdir, String filename) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   257
        try {
06bc494ca11e Initial load
duke
parents:
diff changeset
   258
            String destdir = (configdestdir.length() > 0) ?
06bc494ca11e Initial load
duke
parents:
diff changeset
   259
                configdestdir + File.separatorChar: "";
06bc494ca11e Initial load
duke
parents:
diff changeset
   260
            if (filename.length() > 0) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   261
                File helpstylefile = new File(filename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
                String parent = helpstylefile.getParent();
06bc494ca11e Initial load
duke
parents:
diff changeset
   263
                String helpstylefilename = (parent == null)?
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
                    filename:
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
                    filename.substring(parent.length() + 1);
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
                File desthelpfile = new File(destdir + helpstylefilename);
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
                if (!desthelpfile.getCanonicalPath().equals(
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
                        helpstylefile.getCanonicalPath())) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
                    configuration.message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
                        notice((SourcePosition) null,
06bc494ca11e Initial load
duke
parents:
diff changeset
   271
                            "doclet.Copying_File_0_To_File_1",
06bc494ca11e Initial load
duke
parents:
diff changeset
   272
                            helpstylefile.toString(), desthelpfile.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
                    Util.copyFile(desthelpfile, helpstylefile);
06bc494ca11e Initial load
duke
parents:
diff changeset
   274
                }
06bc494ca11e Initial load
duke
parents:
diff changeset
   275
            }
06bc494ca11e Initial load
duke
parents:
diff changeset
   276
        } catch (IOException exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   277
            configuration.message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   278
                error((SourcePosition) null,
06bc494ca11e Initial load
duke
parents:
diff changeset
   279
                    "doclet.perform_copy_exception_encountered",
06bc494ca11e Initial load
duke
parents:
diff changeset
   280
                    exc.toString());
06bc494ca11e Initial load
duke
parents:
diff changeset
   281
            throw new DocletAbortException();
06bc494ca11e Initial load
duke
parents:
diff changeset
   282
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   283
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   284
}