langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java
author bpatel
Tue, 02 Aug 2016 13:14:12 -0700
changeset 40229 09f4478d07e5
parent 35426 374342e56a56
child 40303 96a1226aca18
permissions -rw-r--r--
8154817: Fix the click-through navigation for modules Reviewed-by: jjg, 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.io.*;
0e193a8f3520 6794582: javadoc should read files using a FileManager
jjg
parents: 1787
diff changeset
    29
import java.util.*;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
40229
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
    31
import javax.lang.model.element.ModuleElement;
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    32
import javax.lang.model.element.PackageElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    33
import javax.lang.model.element.TypeElement;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    34
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    35
import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    36
import jdk.javadoc.internal.doclets.formats.html.SectionName;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    37
import jdk.javadoc.internal.doclets.toolkit.Configuration;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    38
import jdk.javadoc.internal.doclets.toolkit.Content;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    39
import jdk.javadoc.internal.doclets.toolkit.util.DocFile;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    40
import jdk.javadoc.internal.doclets.toolkit.util.DocLink;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    41
import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
    42
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
 * Class for the Html Format Code Generation specific to JavaDoc.
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
 * 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
    48
 * are used by the Sub-Classes in the package jdk.javadoc.internal.tool.standard.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
 *
14260
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    50
 *  <p><b>This is NOT part of any supported API.
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    51
 *  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
    52
 *  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
    53
 *  deletion without notice.</b>
727a84636f12 8000665: fix "internal API" comments on javadoc files
jjg
parents: 7681
diff changeset
    54
 *
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
 * @author Atul M Dambalkar
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
 * @author Robert Field
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
public abstract class HtmlDocWriter extends HtmlWriter {
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
19663
9a3447cabe1a 7052170: javadoc -charset option generates wrong meta tag
bpatel
parents: 17570
diff changeset
    60
    public static final String CONTENT_TYPE = "text/html";
9a3447cabe1a 7052170: javadoc -charset option generates wrong meta tag
bpatel
parents: 17570
diff changeset
    61
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
    62
    DocPath pathToRoot;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
    63
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
     * Constructor. Initializes the destination file name through the super
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * class HtmlWriter.
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
     * @param filename String file name.
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
     */
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    70
    public HtmlDocWriter(Configuration configuration, DocPath filename)
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    71
            throws IOException {
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    72
        super(configuration, filename);
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
    73
        this.pathToRoot = filename.parent().invert();
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
        configuration.message.notice("doclet.Generating_0",
14544
d71d992cb905 8002079: update DocFile to use a JavaFileManager
jjg
parents: 14542
diff changeset
    75
            DocFile.createFileForOutput(configuration, filename).getPath());
10
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
     * Accessor for configuration.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
    public abstract Configuration configuration();
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
    83
    public Content getHyperLink(DocPath link, String label) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
    84
        return getHyperLink(link, new StringContent(label), false, "", "", "");
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
    85
    }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
    86
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
    /**
21008
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
    88
     * Get Html Hyper Link Content.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     *
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    90
     * @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
    91
     *                   needed.
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    92
     * @param label      Tag for the link.
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    93
     * @return a content tree for the hyper link
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    94
     */
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    95
    public Content getHyperLink(String where,
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
    96
                               Content label) {
21008
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
    97
        return getHyperLink(getDocLink(where), label, "", "");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
    98
    }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
    99
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   100
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   101
     * Get Html Hyper Link Content.
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
     * @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
   104
     * @param label            Tag for the link.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   105
     * @return a content tree for the hyper link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   106
     */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   107
    public Content getHyperLink(SectionName sectionName,
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   108
                               Content label) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   109
        return getHyperLink(getDocLink(sectionName), label, "", "");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   110
    }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   111
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   112
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   113
     * Get Html Hyper Link Content.
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
     * @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
   116
     *                         will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   117
     * @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
   118
     *                         will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   119
     * @param label            Tag for the link.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   120
     * @return a content tree for the hyper link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   121
     */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   122
    public Content getHyperLink(SectionName sectionName, String where,
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   123
                               Content label) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   124
        return getHyperLink(getDocLink(sectionName, where), label, "", "");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   125
    }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   126
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   127
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   128
     * Get the link.
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
     * @param where      Position of the link in the file.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   131
     * @return a DocLink object for the hyper 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
    public DocLink getDocLink(String where) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   134
        return DocLink.fragment(getName(where));
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
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   137
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   138
     * Get the link.
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
     * @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
   141
     * @return a DocLink object for the hyper 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
    public DocLink getDocLink(SectionName sectionName) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   144
        return DocLink.fragment(sectionName.getName());
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
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   147
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   148
     * Get the link.
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
     * @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
   151
     *                         will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   152
     * @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
   153
     *                         will be created.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   154
     * @return a DocLink object for the hyper link
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   155
     */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   156
    public DocLink getDocLink(SectionName sectionName, String where) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   157
        return DocLink.fragment(sectionName.getName() + getName(where));
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
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   160
    /**
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   161
     * Convert the name to a valid HTML name.
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
     * @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
   164
     * @return a valid HTML name string.
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
    public String getName(String name) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   167
        StringBuilder sb = new StringBuilder();
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   168
        char ch;
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   169
        /* 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
   170
         * 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
   171
         * 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
   172
         * 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
   173
         * 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
   174
         *
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   175
         * 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
   176
         * 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
   177
         * 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
   178
         */
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   179
        for (int i = 0; i < name.length(); i++) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   180
            ch = name.charAt(i);
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   181
            switch (ch) {
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   182
                case '(':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   183
                case ')':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   184
                case '<':
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
                    sb.append('-');
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   188
                    break;
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
                case '[':
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
                    sb.append(":A");
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
                // 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
   196
                // 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
   197
                // 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
   198
                // "Z:Z:D".
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   199
                case '$':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   200
                    if (i == 0)
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   201
                        sb.append("Z:Z");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   202
                    sb.append(":D");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   203
                    break;
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   204
                // 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
   205
                // names can only begin with a letter.
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   206
                case '_':
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   207
                    if (i == 0)
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   208
                        sb.append("Z:Z");
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   209
                    sb.append(ch);
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   210
                    break;
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   211
                default:
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
            }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   214
        }
af0b915df7cc 8025633: Fix javadoc to generate valid anchor names
bpatel
parents: 19920
diff changeset
   215
        return sb.toString();
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   216
    }
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   217
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   218
    /**
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   219
     * Get Html hyperlink.
14357
faf9cde2817b 8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents: 14266
diff changeset
   220
     *
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   221
     * @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
   222
     * @param label      Tag for the link.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   223
     * @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
   224
     */
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   225
    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
   226
        return getHyperLink(link, label, "", "");
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   227
    }
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   228
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   229
    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
   230
        return getHyperLink(link, label, "", "");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   231
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   232
17563
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   233
    public Content getHyperLink(DocPath link,
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   234
                               Content label, boolean strong,
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   235
                               String stylename, String title, String target) {
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   236
        return getHyperLink(new DocLink(link), label, strong,
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   237
                stylename, title, target);
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   238
    }
e8ddeb9bd17c 8011668: Allow HTMLWriter.getResource to take Content args
jjg
parents: 17560
diff changeset
   239
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   240
    public Content getHyperLink(DocLink link,
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   241
                               Content label, boolean strong,
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   242
                               String stylename, String title, String target) {
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   243
        Content body = label;
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   244
        if (strong) {
21478
fa4c7cda1b41 8026567: Use meaningful style names for strong and italic styles.
bpatel
parents: 21008
diff changeset
   245
            body = HtmlTree.SPAN(HtmlStyle.typeNameLink, body);
17560
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   246
        }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   247
        if (stylename != null && stylename.length() != 0) {
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   248
            HtmlTree t = new HtmlTree(HtmlTag.FONT, body);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   249
            t.addAttr(HtmlAttr.CLASS, stylename);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   250
            body = t;
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   251
        }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   252
        HtmlTree l = HtmlTree.A(link.toString(), body);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   253
        if (title != null && title.length() != 0) {
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   254
            l.addAttr(HtmlAttr.TITLE, title);
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   255
        }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   256
        if (target != null && target.length() != 0) {
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   257
            l.addAttr(HtmlAttr.TARGET, target);
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
        return l;
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   260
    }
9f6771abbd1a 8011650: reduce use of RawHtml nodes in doclet
jjg
parents: 14544
diff changeset
   261
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   262
    /**
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   263
     * Get Html Hyper Link.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   264
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
   265
     * @param link       String name of the file.
06bc494ca11e Initial load
duke
parents:
diff changeset
   266
     * @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
   267
     * @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
   268
     * @param target     Target frame.
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   269
     * @return a content tree for the hyper link.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   270
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   271
    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
   272
        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
   273
    }
9eda9239cba0 8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents: 14357
diff changeset
   274
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   275
    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
   276
        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
   277
        if (title != null && title.length() != 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   278
            anchor.addAttr(HtmlAttr.TITLE, title);
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   279
        }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   280
        if (target != null && target.length() != 0) {
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   281
            anchor.addAttr(HtmlAttr.TARGET, target);
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
        return anchor;
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   284
    }
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   285
40229
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   286
    public Content getModuleFramesHyperLink(ModuleElement mdle, Content label, String target) {
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   287
        DocLink mdlLink = new DocLink(DocPaths.moduleFrame(mdle));
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   288
        DocLink mtFrameLink = new DocLink(DocPaths.moduleTypeFrame(mdle));
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   289
        DocLink cFrameLink = new DocLink(DocPaths.moduleSummary(mdle));
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   290
        HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label);
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   291
        StringBuilder onclickStr = new StringBuilder("updateModuleFrame('")
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   292
                .append(mtFrameLink.toString())
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   293
                .append("','")
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   294
                .append(cFrameLink.toString())
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   295
                .append("');");
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   296
        anchor.addAttr(HtmlAttr.TARGET, target);
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   297
        anchor.addAttr(HtmlAttr.ONCLICK, onclickStr.toString());
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   298
        return anchor;
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   299
    }
09f4478d07e5 8154817: Fix the click-through navigation for modules
bpatel
parents: 35426
diff changeset
   300
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   301
    /**
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   302
     * Get the enclosed name of the package
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   303
     *
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   304
     * @param te  TypeElement
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   305
     * @return the name
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   306
     */
35426
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   307
    public String getEnclosingPackageName(TypeElement te) {
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   308
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   309
        PackageElement encl = configuration.utils.containingPackage(te);
374342e56a56 8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents: 29957
diff changeset
   310
        return (encl.isUnnamed()) ? "" : (encl.getQualifiedName() + ".");
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   311
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   312
2216
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   313
    public boolean getMemberDetailsListPrinted() {
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   314
        return memberDetailsListPrinted;
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   315
    }
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   316
b124d5c924eb 6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents: 1869
diff changeset
   317
    /**
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   318
     * 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
   319
     * Called only when generating an HTML frames file.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   320
     *
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   321
     * @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
   322
     * @param configuration the configuration object
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29429
diff changeset
   323
     * @param body the body content tree to be added to the HTML document
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   324
     */
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   325
    public void printFramesDocument(String title, ConfigurationImpl configuration,
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   326
            HtmlTree body) throws IOException {
29957
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29429
diff changeset
   327
        Content htmlDocType = configuration.isOutputHtml5()
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29429
diff changeset
   328
                ? DocType.HTML5
7740f9657f56 8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents: 29429
diff changeset
   329
                : DocType.TRANSITIONAL;
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   330
        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
   331
        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
   332
        head.addContent(getGeneratedBy(!configuration.notimestamp));
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   333
        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
   334
        head.addContent(windowTitle);
26665
e813baa25bf2 8047745: Javadoc should include encoding information in generated html files
bpatel
parents: 25874
diff changeset
   335
        Content meta = HtmlTree.META("Content-Type", CONTENT_TYPE,
e813baa25bf2 8047745: Javadoc should include encoding information in generated html files
bpatel
parents: 25874
diff changeset
   336
                (configuration.charset.length() > 0) ?
e813baa25bf2 8047745: Javadoc should include encoding information in generated html files
bpatel
parents: 25874
diff changeset
   337
                        configuration.charset : HtmlConstants.HTML_DEFAULT_CHARSET);
e813baa25bf2 8047745: Javadoc should include encoding information in generated html files
bpatel
parents: 25874
diff changeset
   338
        head.addContent(meta);
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   339
        head.addContent(getStyleSheetProperties(configuration));
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   340
        head.addContent(getFramesJavaScript());
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   341
        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
   342
                head, body);
7614
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   343
        Content htmlDocument = new HtmlDocument(htmlDocType,
cfadc977ca75 6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents: 5520
diff changeset
   344
                htmlComment, htmlTree);
14266
69453558960d 8000673: remove dead code from HtmlWriter and subtypes
jjg
parents: 14265
diff changeset
   345
        write(htmlDocument);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   346
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   347
29429
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   348
    /**
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   349
     * 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
   350
     *
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   351
     * @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
   352
     */
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   353
    public HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) {
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   354
        String stylesheetfile = configuration.stylesheetfile;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   355
        DocPath stylesheet;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   356
        if (stylesheetfile.isEmpty()) {
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   357
            stylesheet = DocPaths.STYLESHEET;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   358
        } else {
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   359
            DocFile file = DocFile.createFileForInput(configuration, stylesheetfile);
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   360
            stylesheet = DocPath.create(file.getName());
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   361
        }
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   362
        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
   363
                pathToRoot.resolve(stylesheet).getPath(),
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   364
                "Style");
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   365
        return link;
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   366
    }
964498d4dcec 8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents: 26665
diff changeset
   367
19920
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   368
    protected Comment getGeneratedBy(boolean timestamp) {
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   369
        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
   370
        if (timestamp) {
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   371
            Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   372
            Date today = calendar.getTime();
21888
568c5da9f16b 6726154: javadoc generated with incorrect version in comment
kizune
parents: 21478
diff changeset
   373
            text += " ("+ configuration.getDocletSpecificBuildDate() + ") on " + today;
19920
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   374
        }
ead15bfdcfa0 8024288: javadoc generated-by comment should always be present
jjg
parents: 19663
diff changeset
   375
        return new Comment(text);
10
06bc494ca11e Initial load
duke
parents:
diff changeset
   376
    }
06bc494ca11e Initial load
duke
parents:
diff changeset
   377
}