langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java
author alanb
Thu, 17 Mar 2016 19:04:28 +0000
changeset 36526 3b41f1c69604
parent 35426 374342e56a56
child 39090 10c2cda4358d
permissions -rw-r--r--
8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: jjg, jlahoda, vromero, mcimadamore, bpatel, ksrini, darcy, anazarov, dfuchs Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, jan.lahoda@oracle.com, vicente.romero@oracle.com, andreas.lundblad@oracle.com, andrey.x.nazarov@oracle.com, chris.hegarty@oracle.com, erik.joelsson@oracle.com, kumar.x.srinivasan@oracle.com, sundararajan.athijegannathan@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
     2
 * Copyright (c) 2003, 2016, 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
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    26
package jdk.javadoc.internal.doclets.toolkit;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    27
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    28
import java.util.SortedSet;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    29
import java.util.TreeSet;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    30
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    31
import javax.lang.model.SourceVersion;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    32
import javax.lang.model.element.PackageElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    33
import javax.lang.model.element.TypeElement;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    35
import jdk.javadoc.doclet.DocletEnvironment;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    36
import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    37
import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    38
import jdk.javadoc.internal.doclets.toolkit.util.ClassTree;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    39
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    40
import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    41
import jdk.javadoc.internal.doclets.toolkit.util.PackageListWriter;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    42
import jdk.javadoc.internal.doclets.toolkit.util.Utils;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    43
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    44
import static javax.tools.Diagnostic.Kind.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * An abstract implementation of a Doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    49
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 14258
diff changeset
    50
 *  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
    51
 *  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
    52
 *  deletion without notice.</b>
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
 * @author Jamie Ho
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
public abstract class AbstractDoclet {
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
     * The global configuration information for this run.
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
     */
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    61
    public Configuration configuration;
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22159
diff changeset
    62
    /*
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22159
diff changeset
    63
     *  a handle to our utility methods
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22159
diff changeset
    64
     */
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22159
diff changeset
    65
    protected Utils utils;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * The only doclet that may use this toolkit is {@value}
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     */
14542
7062120649c2 8000800: javadoc uses static non-final fields
jjg
parents: 14368
diff changeset
    70
    private static final String TOOLKIT_DOCLET_NAME =
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    71
        jdk.javadoc.internal.doclets.formats.html.HtmlDoclet.class.getName();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * Verify that the only doclet that is using this toolkit is
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     * {@value #TOOLKIT_DOCLET_NAME}.
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
     */
26269
0d8efbb110b4 8054925: [javadoc] refactor the Doclet start method.
ksrini
parents: 25874
diff changeset
    77
    private boolean isValidDoclet() {
0d8efbb110b4 8054925: [javadoc] refactor the Doclet start method.
ksrini
parents: 25874
diff changeset
    78
        if (!getClass().getName().equals(TOOLKIT_DOCLET_NAME)) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
            configuration.message.error("doclet.Toolkit_Usage_Violation",
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
                TOOLKIT_DOCLET_NAME);
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     * The method that starts the execution of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    89
     * @param root   the {@link DocletEnvironment} that points to the source to document.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * @return true if the doclet executed without error.  False otherwise.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    92
    public boolean startDoclet(DocletEnvironment root) {
1475
19c0851667ca 6748541: javadoc should be reusable
jjg
parents: 10
diff changeset
    93
        configuration = configuration();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
        configuration.root = root;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    95
        configuration.cmtUtils = new CommentUtils(configuration);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    96
        configuration.utils = new Utils(configuration);
25454
376a52c9540c 8039028: [javadoc] refactor the usage of Util.java
ksrini
parents: 22159
diff changeset
    97
        utils = configuration.utils;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
    98
        configuration.workArounds = new WorkArounds(configuration);
26269
0d8efbb110b4 8054925: [javadoc] refactor the Doclet start method.
ksrini
parents: 25874
diff changeset
    99
        if (!isValidDoclet()) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   102
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
        try {
26269
0d8efbb110b4 8054925: [javadoc] refactor the Doclet start method.
ksrini
parents: 25874
diff changeset
   104
            startGeneration(root);
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 15723
diff changeset
   105
        } catch (Configuration.Fault f) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   106
            configuration.reporter.print(ERROR, f.getMessage());
16324
332d7f5fdf62 8008949: javadoc stopped copying doc-files
jjg
parents: 15723
diff changeset
   107
            return false;
20600
052970964bc1 6978886: javadoc shows stacktrace after print error resulting from disk full
kizune
parents: 16324
diff changeset
   108
        } catch (DocletAbortException e) {
052970964bc1 6978886: javadoc shows stacktrace after print error resulting from disk full
kizune
parents: 16324
diff changeset
   109
            Throwable cause = e.getCause();
052970964bc1 6978886: javadoc shows stacktrace after print error resulting from disk full
kizune
parents: 16324
diff changeset
   110
            if (cause != null) {
052970964bc1 6978886: javadoc shows stacktrace after print error resulting from disk full
kizune
parents: 16324
diff changeset
   111
                if (cause.getLocalizedMessage() != null) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   112
                    configuration.reporter.print(ERROR, cause.getLocalizedMessage());
20600
052970964bc1 6978886: javadoc shows stacktrace after print error resulting from disk full
kizune
parents: 16324
diff changeset
   113
                } else {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   114
                    configuration.reporter.print(ERROR, cause.toString());
20600
052970964bc1 6978886: javadoc shows stacktrace after print error resulting from disk full
kizune
parents: 16324
diff changeset
   115
                }
052970964bc1 6978886: javadoc shows stacktrace after print error resulting from disk full
kizune
parents: 16324
diff changeset
   116
            }
052970964bc1 6978886: javadoc shows stacktrace after print error resulting from disk full
kizune
parents: 16324
diff changeset
   117
            return false;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
        } catch (Exception exc) {
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
            return false;
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
        }
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
        return true;
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   125
     * Returns the SourceVersion indicating the features supported by this doclet.
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   126
     * @return SourceVersion
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   128
    public SourceVersion sourceVersion() {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   129
        return SourceVersion.RELEASE_8;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
    }
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
     * Create the configuration instance and returns it.
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     * @return the configuration of the doclet.
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
    public abstract Configuration configuration();
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     * Start the generation of files. Call generate methods in the individual
14368
6f4c62de6985 8001664: refactor javadoc to use abstraction to handle files
jjg
parents: 14357
diff changeset
   141
     * writers, which will in turn generate the documentation files. Call the
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
     * TreeWriter generation first to ensure the Class Hierarchy is built
06bc494ca11e Initial load
duke
parents:
diff changeset
   143
     * first and then can be used in the later generation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   144
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   145
     * @see jdk.doclet.DocletEnvironment
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   146
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   147
    private void startGeneration(DocletEnvironment root) throws Configuration.Fault, Exception {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   148
        if (root.getIncludedClasses().isEmpty()) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   149
            configuration.message.
06bc494ca11e Initial load
duke
parents:
diff changeset
   150
                error("doclet.No_Public_Classes_To_Document");
06bc494ca11e Initial load
duke
parents:
diff changeset
   151
            return;
06bc494ca11e Initial load
duke
parents:
diff changeset
   152
        }
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   153
        if (!configuration.setOptions()) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   154
            return;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   155
        }
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   156
        configuration.getDocletSpecificMsg().notice("doclet.build_version",
06bc494ca11e Initial load
duke
parents:
diff changeset
   157
            configuration.getDocletSpecificBuildDate());
06bc494ca11e Initial load
duke
parents:
diff changeset
   158
        ClassTree classtree = new ClassTree(configuration, configuration.nodeprecated);
06bc494ca11e Initial load
duke
parents:
diff changeset
   159
06bc494ca11e Initial load
duke
parents:
diff changeset
   160
        generateClassFiles(root, classtree);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   161
        configuration.utils.copyDocFiles(DocPaths.DOC_FILES);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   162
06bc494ca11e Initial load
duke
parents:
diff changeset
   163
        PackageListWriter.generate(configuration);
06bc494ca11e Initial load
duke
parents:
diff changeset
   164
        generatePackageFiles(classtree);
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   165
        generateModuleFiles();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   166
06bc494ca11e Initial load
duke
parents:
diff changeset
   167
        generateOtherFiles(root, classtree);
06bc494ca11e Initial load
duke
parents:
diff changeset
   168
        configuration.tagletManager.printReport();
06bc494ca11e Initial load
duke
parents:
diff changeset
   169
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   170
06bc494ca11e Initial load
duke
parents:
diff changeset
   171
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   172
     * Generate additional documentation that is added to the API documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   173
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   174
     * @param root     the DocletEnvironment of source to document.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   175
     * @param classtree the data structure representing the class tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   176
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   177
    protected void generateOtherFiles(DocletEnvironment root, ClassTree classtree) throws Exception {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   178
        BuilderFactory builderFactory = configuration.getBuilderFactory();
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   179
        AbstractBuilder constantsSummaryBuilder = builderFactory.getConstantsSummaryBuilder();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   180
        constantsSummaryBuilder.build();
06bc494ca11e Initial load
duke
parents:
diff changeset
   181
        AbstractBuilder serializedFormBuilder = builderFactory.getSerializedFormBuilder();
06bc494ca11e Initial load
duke
parents:
diff changeset
   182
        serializedFormBuilder.build();
06bc494ca11e Initial load
duke
parents:
diff changeset
   183
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   184
06bc494ca11e Initial load
duke
parents:
diff changeset
   185
    /**
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   186
     * Generate the module documentation.
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   187
     *
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   188
     */
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   189
    protected abstract void generateModuleFiles() throws Exception;
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   190
3b41f1c69604 8142968: Module System implementation
alanb
parents: 35426
diff changeset
   191
    /**
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   192
     * Generate the package documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   193
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   194
     * @param classtree the data structure representing the class tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   195
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   196
    protected abstract void generatePackageFiles(ClassTree classtree) throws Exception;
06bc494ca11e Initial load
duke
parents:
diff changeset
   197
06bc494ca11e Initial load
duke
parents:
diff changeset
   198
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   199
     * Generate the class documentation.
06bc494ca11e Initial load
duke
parents:
diff changeset
   200
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   201
     * @param classtree the data structure representing the class tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   202
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   203
    protected abstract void generateClassFiles(SortedSet<TypeElement> arr, ClassTree classtree);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   204
06bc494ca11e Initial load
duke
parents:
diff changeset
   205
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   206
     * Iterate through all classes and construct documentation for them.
06bc494ca11e Initial load
duke
parents:
diff changeset
   207
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   208
     * @param root      the DocletEnvironment of source to document.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   209
     * @param classtree the data structure representing the class tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   210
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   211
    protected void generateClassFiles(DocletEnvironment root, ClassTree classtree) {
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   212
        generateClassFiles(classtree);
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   213
        SortedSet<PackageElement> packages = new TreeSet<>(utils.makePackageComparator());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   214
        packages.addAll(utils.getSpecifiedPackages());
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   215
        packages.stream().forEach((pkg) -> {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   216
            generateClassFiles(utils.getAllClasses(pkg), classtree);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   217
        });
10
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
     * Generate the class files for single classes specified on the command line.
06bc494ca11e Initial load
duke
parents:
diff changeset
   222
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   223
     * @param classtree the data structure representing the class tree.
06bc494ca11e Initial load
duke
parents:
diff changeset
   224
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   225
    private void generateClassFiles(ClassTree classtree) {
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   226
        SortedSet<PackageElement> packages = configuration.typeElementCatalog.packages();
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   227
        packages.stream().forEach((pkg) -> {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   228
            generateClassFiles(configuration.typeElementCatalog.allClasses(pkg), classtree);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 26269
diff changeset
   229
        });
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   230
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
}