src/share/classes/com/sun/tools/doclets/formats/html/PackageIndexWriter.java

Tue, 20 Aug 2013 14:55:20 -0700

author
jjg
date
Tue, 20 Aug 2013 14:55:20 -0700
changeset 1964
79e341614c50
parent 1952
3d4f0fa2ad05
child 1985
0e6577980181
permissions
-rw-r--r--

8022080: javadoc generates invalid HTML in Turkish locale
Reviewed-by: bpatel

     1 /*
     2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     8  * particular file as subject to the "Classpath" exception as provided
     9  * by Oracle in the LICENSE file that accompanied this code.
    10  *
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    14  * version 2 for more details (a copy is included in the LICENSE file that
    15  * accompanied this code).
    16  *
    17  * You should have received a copy of the GNU General Public License version
    18  * 2 along with this work; if not, write to the Free Software Foundation,
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    20  *
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    22  * or visit www.oracle.com if you need additional information or have any
    23  * questions.
    24  */
    26 package com.sun.tools.doclets.formats.html;
    28 import java.io.*;
    29 import java.util.*;
    31 import com.sun.javadoc.*;
    32 import com.sun.tools.javac.jvm.Profile;
    33 import com.sun.tools.doclets.formats.html.markup.*;
    34 import com.sun.tools.doclets.internal.toolkit.*;
    35 import com.sun.tools.doclets.internal.toolkit.util.*;
    37 /**
    38  * Generate the package index page "overview-summary.html" for the right-hand
    39  * frame. A click on the package name on this page will update the same frame
    40  * with the "package-summary.html" file for the clicked package.
    41  *
    42  *  <p><b>This is NOT part of any supported API.
    43  *  If you write code that depends on this, you do so at your own risk.
    44  *  This code and its internal interfaces are subject to change or
    45  *  deletion without notice.</b>
    46  *
    47  * @author Atul M Dambalkar
    48  * @author Bhavesh Patel (Modified)
    49  */
    50 public class PackageIndexWriter extends AbstractPackageIndexWriter {
    52     /**
    53      * Root of the program structure. Used for "overview" documentation.
    54      */
    55     private RootDoc root;
    57     /**
    58      * Map representing the group of packages as specified on the command line.
    59      *
    60      * @see Group
    61      */
    62     private Map<String,List<PackageDoc>> groupPackageMap;
    64     /**
    65      * List to store the order groups as specified on the command line.
    66      */
    67     private List<String> groupList;
    69     /**
    70      * Construct the PackageIndexWriter. Also constructs the grouping
    71      * information as provided on the command line by "-group" option. Stores
    72      * the order of groups specified by the user.
    73      *
    74      * @see Group
    75      */
    76     public PackageIndexWriter(ConfigurationImpl configuration,
    77                               DocPath filename)
    78                        throws IOException {
    79         super(configuration, filename);
    80         this.root = configuration.root;
    81         groupPackageMap = configuration.group.groupPackages(packages);
    82         groupList = configuration.group.getGroupList();
    83     }
    85     /**
    86      * Generate the package index page for the right-hand frame.
    87      *
    88      * @param configuration the current configuration of the doclet.
    89      */
    90     public static void generate(ConfigurationImpl configuration) {
    91         PackageIndexWriter packgen;
    92         DocPath filename = DocPaths.OVERVIEW_SUMMARY;
    93         try {
    94             packgen = new PackageIndexWriter(configuration, filename);
    95             packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true);
    96             packgen.close();
    97         } catch (IOException exc) {
    98             configuration.standardmessage.error(
    99                         "doclet.exception_encountered",
   100                         exc.toString(), filename);
   101             throw new DocletAbortException();
   102         }
   103     }
   105     /**
   106      * Depending upon the grouping information and their titles, add
   107      * separate table indices for each package group.
   108      *
   109      * @param body the documentation tree to which the index will be added
   110      */
   111     protected void addIndex(Content body) {
   112         for (int i = 0; i < groupList.size(); i++) {
   113         String groupname = groupList.get(i);
   114         List<PackageDoc> list = groupPackageMap.get(groupname);
   115             if (list != null && list.size() > 0) {
   116                 addIndexContents(list.toArray(new PackageDoc[list.size()]),
   117                         groupname, configuration.getText("doclet.Member_Table_Summary",
   118                         groupname, configuration.getText("doclet.packages")), body);
   119             }
   120         }
   121     }
   123     /**
   124      * {@inheritDoc}
   125      */
   126     protected void addProfilesList(Content profileSummary, Content body) {
   127         Content h2 = HtmlTree.HEADING(HtmlTag.H2, profileSummary);
   128         Content profilesDiv = HtmlTree.DIV(h2);
   129         Content ul = new HtmlTree(HtmlTag.UL);
   130         String profileName;
   131         for (int i = 1; i < configuration.profiles.getProfileCount(); i++) {
   132             profileName = Profile.lookup(i).name;
   133             Content profileLinkContent = getTargetProfileLink("classFrame",
   134                     new StringContent(profileName), profileName);
   135             Content li = HtmlTree.LI(profileLinkContent);
   136             ul.addContent(li);
   137         }
   138         profilesDiv.addContent(ul);
   139         Content div = HtmlTree.DIV(HtmlStyle.contentContainer, profilesDiv);
   140         body.addContent(div);
   141     }
   143     /**
   144      * {@inheritDoc}
   145      */
   146     protected void addPackagesList(PackageDoc[] packages, String text,
   147             String tableSummary, Content body) {
   148         Content table = HtmlTree.TABLE(HtmlStyle.overviewSummary, 0, 3, 0, tableSummary,
   149                 getTableCaption(new RawHtml(text)));
   150         table.addContent(getSummaryTableHeader(packageTableHeader, "col"));
   151         Content tbody = new HtmlTree(HtmlTag.TBODY);
   152         addPackagesList(packages, tbody);
   153         table.addContent(tbody);
   154         Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table);
   155         body.addContent(div);
   156     }
   158     /**
   159      * Adds list of packages in the index table. Generate link to each package.
   160      *
   161      * @param packages Packages to which link is to be generated
   162      * @param tbody the documentation tree to which the list will be added
   163      */
   164     protected void addPackagesList(PackageDoc[] packages, Content tbody) {
   165         for (int i = 0; i < packages.length; i++) {
   166             if (packages[i] != null && packages[i].name().length() > 0) {
   167                 if (configuration.nodeprecated && Util.isDeprecated(packages[i]))
   168                     continue;
   169                 Content packageLinkContent = getPackageLink(packages[i],
   170                         getPackageName(packages[i]));
   171                 Content tdPackage = HtmlTree.TD(HtmlStyle.colFirst, packageLinkContent);
   172                 HtmlTree tdSummary = new HtmlTree(HtmlTag.TD);
   173                 tdSummary.addStyle(HtmlStyle.colLast);
   174                 addSummaryComment(packages[i], tdSummary);
   175                 HtmlTree tr = HtmlTree.TR(tdPackage);
   176                 tr.addContent(tdSummary);
   177                 if (i%2 == 0)
   178                     tr.addStyle(HtmlStyle.altColor);
   179                 else
   180                     tr.addStyle(HtmlStyle.rowColor);
   181                 tbody.addContent(tr);
   182             }
   183         }
   184     }
   186     /**
   187      * Adds the overview summary comment for this documentation. Add one line
   188      * summary at the top of the page and generate a link to the description,
   189      * which is added at the end of this page.
   190      *
   191      * @param body the documentation tree to which the overview header will be added
   192      */
   193     protected void addOverviewHeader(Content body) {
   194         if (root.inlineTags().length > 0) {
   195             HtmlTree subTitleDiv = new HtmlTree(HtmlTag.DIV);
   196             subTitleDiv.addStyle(HtmlStyle.subTitle);
   197             addSummaryComment(root, subTitleDiv);
   198             Content div = HtmlTree.DIV(HtmlStyle.header, subTitleDiv);
   199             Content see = seeLabel;
   200             see.addContent(" ");
   201             Content descPara = HtmlTree.P(see);
   202             Content descLink = getHyperLink(DocLink.fragment("overview_description"),
   203                 descriptionLabel, "", "");
   204             descPara.addContent(descLink);
   205             div.addContent(descPara);
   206             body.addContent(div);
   207         }
   208     }
   210     /**
   211      * Adds the overview comment as provided in the file specified by the
   212      * "-overview" option on the command line.
   213      *
   214      * @param htmltree the documentation tree to which the overview comment will
   215      *                 be added
   216      */
   217     protected void addOverviewComment(Content htmltree) {
   218         if (root.inlineTags().length > 0) {
   219             htmltree.addContent(getMarkerAnchor("overview_description"));
   220             addInlineComment(root, htmltree);
   221         }
   222     }
   224     /**
   225      * Adds the tag information as provided in the file specified by the
   226      * "-overview" option on the command line.
   227      *
   228      * @param body the documentation tree to which the overview will be added
   229      */
   230     protected void addOverview(Content body) throws IOException {
   231         HtmlTree div = new HtmlTree(HtmlTag.DIV);
   232         div.addStyle(HtmlStyle.contentContainer);
   233         addOverviewComment(div);
   234         addTagsInfo(root, div);
   235         body.addContent(div);
   236     }
   238     /**
   239      * Adds the top text (from the -top option), the upper
   240      * navigation bar, and then the title (from the"-title"
   241      * option), at the top of page.
   242      *
   243      * @body the documentation tree to which the navigation bar header will be added
   244      */
   245     protected void addNavigationBarHeader(Content body) {
   246         addTop(body);
   247         addNavLinks(true, body);
   248         addConfigurationTitle(body);
   249     }
   251     /**
   252      * Adds the lower navigation bar and the bottom text
   253      * (from the -bottom option) at the bottom of page.
   254      *
   255      * @param body the documentation tree to which the navigation bar footer will be added
   256      */
   257     protected void addNavigationBarFooter(Content body) {
   258         addNavLinks(false, body);
   259         addBottom(body);
   260     }
   261 }

mercurial