langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java
author jjg
Mon, 22 Aug 2016 16:32:40 -0700
changeset 40587 1c355ea550ed
parent 40303 96a1226aca18
child 45417 f7479ee8de69
permissions -rw-r--r--
8164130: Simplify doclet IOException handling Reviewed-by: bpatel, ksrini
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: 29957
diff changeset
     2
 * Copyright (c) 1997, 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: 2223
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: 2223
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: 2223
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2223
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 2223
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: 29957
diff changeset
    26
package jdk.javadoc.internal.doclets.formats.html.markup;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
1869
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1787
diff changeset
    28
import java.util.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
40229
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
    30
import javax.lang.model.element.ModuleElement;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    31
import javax.lang.model.element.PackageElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    32
import javax.lang.model.element.TypeElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    33
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    34
import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    35
import jdk.javadoc.internal.doclets.formats.html.SectionName;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    36
import jdk.javadoc.internal.doclets.toolkit.Configuration;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    37
import jdk.javadoc.internal.doclets.toolkit.Content;
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 40229
diff changeset
    38
import jdk.javadoc.internal.doclets.toolkit.Messages;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    39
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
    40
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    41
import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    42
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    43
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * Class for the Html Format Code Generation specific to JavaDoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
 * This Class contains methods related to the Html Code Generation which
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    49
 * are used by the Sub-Classes in the package jdk.javadoc.internal.tool.standard.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    51
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    52
 *  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: 7681
diff changeset
    53
 *  This code and its internal interfaces are subject to change or
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    54
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    55
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
public abstract class HtmlDocWriter extends HtmlWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
19663
9a3447cabe1a 7052170: javadoc -charset option generates wrong meta tag
bpatel
parents: 17570
diff changeset
    61
    public static final String CONTENT_TYPE = "text/html";
9a3447cabe1a 7052170: javadoc -charset option generates wrong meta tag
bpatel
parents: 17570
diff changeset
    62
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
    63
    DocPath pathToRoot;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
    64
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * Constructor. Initializes the destination file name through the super
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     * class HtmlWriter.
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     *
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
    69
     * @param configuration the configuration for this doclet
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
     * @param filename String file name.
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     */
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 40229
diff changeset
    72
    public HtmlDocWriter(Configuration configuration, DocPath filename) {
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    73
        super(configuration, filename);
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
    74
        this.pathToRoot = filename.parent().invert();
40303
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 40229
diff changeset
    75
        Messages messages = configuration.getMessages();
96a1226aca18 8160697: HTMLWriter needs perf cleanup
jjg
parents: 40229
diff changeset
    76
        messages.notice("doclet.Generating_0",
14544
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
    77
            DocFile.createFileForOutput(configuration, filename).getPath());
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     * Accessor for configuration.
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
    82
     * @return the configuration for this doclet
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    public abstract Configuration configuration();
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
    86
    public Content getHyperLink(DocPath link, String label) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
    87
        return getHyperLink(link, new StringContent(label), false, "", "", "");
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
    88
    }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
    89
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
    /**
21008
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
    91
     * Get Html Hyper Link Content.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     *
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    93
     * @param where      Position of the link in the file. Character '#' is not
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    94
     *                   needed.
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    95
     * @param label      Tag for the link.
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    96
     * @return a content tree for the hyper link
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    97
     */
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    98
    public Content getHyperLink(String where,
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    99
                               Content label) {
21008
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   100
        return getHyperLink(getDocLink(where), label, "", "");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   101
    }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   102
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   103
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   104
     * Get Html Hyper Link Content.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   105
     *
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   106
     * @param sectionName      The section name to which the link will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   107
     * @param label            Tag for the link.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   108
     * @return a content tree for the hyper link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   109
     */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   110
    public Content getHyperLink(SectionName sectionName,
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   111
                               Content label) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   112
        return getHyperLink(getDocLink(sectionName), label, "", "");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   113
    }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   114
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   115
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   116
     * Get Html Hyper Link Content.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   117
     *
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   118
     * @param sectionName      The section name combined with where to which the link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   119
     *                         will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   120
     * @param where            The fragment combined with sectionName to which the link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   121
     *                         will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   122
     * @param label            Tag for the link.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   123
     * @return a content tree for the hyper link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   124
     */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   125
    public Content getHyperLink(SectionName sectionName, String where,
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   126
                               Content label) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   127
        return getHyperLink(getDocLink(sectionName, where), label, "", "");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   128
    }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   129
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   130
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   131
     * Get the link.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   132
     *
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   133
     * @param where      Position of the link in the file.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   134
     * @return a DocLink object for the hyper link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   135
     */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   136
    public DocLink getDocLink(String where) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   137
        return DocLink.fragment(getName(where));
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   138
    }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   139
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   140
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   141
     * Get the link.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   142
     *
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   143
     * @param sectionName      The section name to which the link will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   144
     * @return a DocLink object for the hyper link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   145
     */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   146
    public DocLink getDocLink(SectionName sectionName) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   147
        return DocLink.fragment(sectionName.getName());
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   148
    }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   149
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   150
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   151
     * Get the link.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   152
     *
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   153
     * @param sectionName      The section name combined with where to which the link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   154
     *                         will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   155
     * @param where            The fragment combined with sectionName to which the link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   156
     *                         will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   157
     * @return a DocLink object for the hyper link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   158
     */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   159
    public DocLink getDocLink(SectionName sectionName, String where) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   160
        return DocLink.fragment(sectionName.getName() + getName(where));
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   161
    }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   162
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   163
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   164
     * Convert the name to a valid HTML name.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   165
     *
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   166
     * @param name the name that needs to be converted to valid HTML name.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   167
     * @return a valid HTML name string.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   168
     */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   169
    public String getName(String name) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   170
        StringBuilder sb = new StringBuilder();
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   171
        char ch;
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   172
        /* The HTML 4 spec at http://www.w3.org/TR/html4/types.html#h-6.2 mentions
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   173
         * that the name/id should begin with a letter followed by other valid characters.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   174
         * The HTML 5 spec (draft) is more permissive on names/ids where the only restriction
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   175
         * is that it should be at least one character long and should not contain spaces.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   176
         * The spec draft is @ http://www.w3.org/html/wg/drafts/html/master/dom.html#the-id-attribute.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   177
         *
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   178
         * For HTML 4, we need to check for non-characters at the beginning of the name and
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   179
         * substitute it accordingly, "_" and "$" can appear at the beginning of a member name.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   180
         * The method substitutes "$" with "Z:Z:D" and will prefix "_" with "Z:Z".
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   181
         */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   182
        for (int i = 0; i < name.length(); i++) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   183
            ch = name.charAt(i);
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   184
            switch (ch) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   185
                case '(':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   186
                case ')':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   187
                case '<':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   188
                case '>':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   189
                case ',':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   190
                    sb.append('-');
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   191
                    break;
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   192
                case ' ':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   193
                case '[':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   194
                    break;
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   195
                case ']':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   196
                    sb.append(":A");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   197
                    break;
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   198
                // Any appearance of $ needs to be substituted with ":D" and not with hyphen
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   199
                // since a field name "P$$ and a method P(), both valid member names, can end
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   200
                // up as "P--". A member name beginning with $ needs to be substituted with
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   201
                // "Z:Z:D".
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   202
                case '$':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   203
                    if (i == 0)
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   204
                        sb.append("Z:Z");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   205
                    sb.append(":D");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   206
                    break;
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   207
                // A member name beginning with _ needs to be prefixed with "Z:Z" since valid anchor
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   208
                // names can only begin with a letter.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   209
                case '_':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   210
                    if (i == 0)
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   211
                        sb.append("Z:Z");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   212
                    sb.append(ch);
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   213
                    break;
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   214
                default:
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   215
                    sb.append(ch);
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   216
            }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   217
        }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   218
        return sb.toString();
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   219
    }
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   220
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   221
    /**
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   222
     * Get Html hyperlink.
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   223
     *
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   224
     * @param link       path of the file.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   225
     * @param label      Tag for the link.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   226
     * @return a content tree for the hyper link
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   227
     */
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   228
    public Content getHyperLink(DocPath link, Content label) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   229
        return getHyperLink(link, label, "", "");
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   230
    }
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   231
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   232
    public Content getHyperLink(DocLink link, Content label) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   233
        return getHyperLink(link, label, "", "");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   234
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   235
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   236
    public Content getHyperLink(DocPath link,
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   237
                               Content label, boolean strong,
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   238
                               String stylename, String title, String target) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   239
        return getHyperLink(new DocLink(link), label, strong,
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   240
                stylename, title, target);
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   241
    }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   242
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   243
    public Content getHyperLink(DocLink link,
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   244
                               Content label, boolean strong,
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   245
                               String stylename, String title, String target) {
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   246
        Content body = label;
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   247
        if (strong) {
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21008
diff changeset
   248
            body = HtmlTree.SPAN(HtmlStyle.typeNameLink, body);
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   249
        }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   250
        if (stylename != null && stylename.length() != 0) {
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   251
            HtmlTree t = new HtmlTree(HtmlTag.FONT, body);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   252
            t.addAttr(HtmlAttr.CLASS, stylename);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   253
            body = t;
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   254
        }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   255
        HtmlTree l = HtmlTree.A(link.toString(), body);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   256
        if (title != null && title.length() != 0) {
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   257
            l.addAttr(HtmlAttr.TITLE, title);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   258
        }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   259
        if (target != null && target.length() != 0) {
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   260
            l.addAttr(HtmlAttr.TARGET, target);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   261
        }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   262
        return l;
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   263
    }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   264
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   266
     * Get Html Hyper Link.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   267
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   268
     * @param link       String name of the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   269
     * @param label      Tag for the link.
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   270
     * @param title      String that describes the link's content for accessibility.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   271
     * @param target     Target frame.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   272
     * @return a content tree for the hyper link.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   273
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   274
    public Content getHyperLink(DocPath link, Content label, String title, String target) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   275
        return getHyperLink(new DocLink(link), label, title, target);
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   276
    }
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   277
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   278
    public Content getHyperLink(DocLink link, Content label, String title, String target) {
14358
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   279
        HtmlTree anchor = HtmlTree.A(link.toString(), label);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   280
        if (title != null && title.length() != 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   281
            anchor.addAttr(HtmlAttr.TITLE, title);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   282
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   283
        if (target != null && target.length() != 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   284
            anchor.addAttr(HtmlAttr.TARGET, target);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   285
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   286
        return anchor;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   287
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   288
40229
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   289
    public Content getModuleFramesHyperLink(ModuleElement mdle, Content label, String target) {
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   290
        DocLink mdlLink = new DocLink(DocPaths.moduleFrame(mdle));
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   291
        DocLink mtFrameLink = new DocLink(DocPaths.moduleTypeFrame(mdle));
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   292
        DocLink cFrameLink = new DocLink(DocPaths.moduleSummary(mdle));
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   293
        HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label);
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
   294
        String onclickStr = "updateModuleFrame('" + mtFrameLink + "','" + cFrameLink + "');";
40229
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   295
        anchor.addAttr(HtmlAttr.TARGET, target);
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
   296
        anchor.addAttr(HtmlAttr.ONCLICK, onclickStr);
40229
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   297
        return anchor;
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   298
    }
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   299
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   300
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   301
     * Get the enclosed name of the package
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   302
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   303
     * @param te  TypeElement
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   304
     * @return the name
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   305
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   306
    public String getEnclosingPackageName(TypeElement te) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   307
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   308
        PackageElement encl = configuration.utils.containingPackage(te);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   309
        return (encl.isUnnamed()) ? "" : (encl.getQualifiedName() + ".");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   310
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   312
    /**
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   313
     * Print the frames version of the Html file header.
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   314
     * Called only when generating an HTML frames file.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   315
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   316
     * @param title Title of this HTML document
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   317
     * @param configuration the configuration object
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29429
diff changeset
   318
     * @param body the body content tree to be added to the HTML document
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
   319
     * @throws DocFileIOException if there is an error writing the frames document
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
     */
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   321
    public void printFramesDocument(String title, ConfigurationImpl configuration,
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
   322
            HtmlTree body) throws DocFileIOException {
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29429
diff changeset
   323
        Content htmlDocType = configuration.isOutputHtml5()
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29429
diff changeset
   324
                ? DocType.HTML5
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29429
diff changeset
   325
                : DocType.TRANSITIONAL;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   326
        Content htmlComment = new Comment(configuration.getText("doclet.New_Page"));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   327
        Content head = new HtmlTree(HtmlTag.HEAD);
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   328
        head.addContent(getGeneratedBy(!configuration.notimestamp));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   329
        Content windowTitle = HtmlTree.TITLE(new StringContent(title));
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   330
        head.addContent(windowTitle);
26665
e813baa25bf2 8047745: Javadoc should include encoding information in generated html files
bpatel
parents: 25874
diff changeset
   331
        Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
e813baa25bf2 8047745: Javadoc should include encoding information in generated html files
bpatel
parents: 25874
diff changeset
   332
                (configuration.charset.length() > 0) ?
e813baa25bf2 8047745: Javadoc should include encoding information in generated html files
bpatel
parents: 25874
diff changeset
   333
                        configuration.charset : HtmlConstants.HTML_DEFAULT_CHARSET);
e813baa25bf2 8047745: Javadoc should include encoding information in generated html files
bpatel
parents: 25874
diff changeset
   334
        head.addContent(meta);
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   335
        head.addContent(getStyleSheetProperties(configuration));
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   336
        head.addContent(getFramesJavaScript());
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   337
        Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(),
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   338
                head, body);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   339
        Content htmlDocument = new HtmlDocument(htmlDocType,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   340
                htmlComment, htmlTree);
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
   341
        write(htmlDocument);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   342
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   343
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   344
    /**
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   345
     * Returns a link to the stylesheet file.
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   346
     *
40587
1c355ea550ed 8164130: Simplify doclet IOException handling
jjg
parents: 40303
diff changeset
   347
     * @param configuration the configuration for this doclet
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   348
     * @return an HtmlTree for the lINK tag which provides the stylesheet location
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   349
     */
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   350
    public HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   351
        String stylesheetfile = configuration.stylesheetfile;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   352
        DocPath stylesheet;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   353
        if (stylesheetfile.isEmpty()) {
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   354
            stylesheet = DocPaths.STYLESHEET;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   355
        } else {
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   356
            DocFile file = DocFile.createFileForInput(configuration, stylesheetfile);
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   357
            stylesheet = DocPath.create(file.getName());
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   358
        }
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   359
        HtmlTree link = HtmlTree.LINK("stylesheet", "text/css",
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   360
                pathToRoot.resolve(stylesheet).getPath(),
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   361
                "Style");
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   362
        return link;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   363
    }
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   364
19920
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   365
    protected Comment getGeneratedBy(boolean timestamp) {
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   366
        String text = "Generated by javadoc"; // marker string, deliberately not localized
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   367
        if (timestamp) {
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   368
            Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   369
            Date today = calendar.getTime();
21888
568c5da9f16b 6726154: javadoc generated with incorrect version in comment
kizune
parents: 21478
diff changeset
   370
            text += " ("+ configuration.getDocletSpecificBuildDate() + ") on " + today;
19920
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   371
        }
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   372
        return new Comment(text);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   373
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   374
}