author | pmuthuswamy |
Wed, 19 Sep 2018 12:14:53 +0530 | |
changeset 51797 | 3efead10e303 |
parent 50167 | cc705c956798 |
child 52644 | 43efb4ca6d6c |
permissions | -rw-r--r-- |
10 | 1 |
/* |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
2 |
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
|
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
10 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 24 |
*/ |
25 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.formats.html; |
10 | 27 |
|
47846 | 28 |
import jdk.javadoc.internal.doclets.formats.html.markup.Table; |
29 |
||
10 | 30 |
import java.util.*; |
14258 | 31 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
32 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
33 |
|
47846 | 34 |
import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
35 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
36 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
37 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
38 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
40587 | 39 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
40 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
41 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
42 |
import jdk.javadoc.internal.doclets.toolkit.util.Group; |
10 | 43 |
|
44 |
/** |
|
45 |
* Generate the package index page "overview-summary.html" for the right-hand |
|
46 |
* frame. A click on the package name on this page will update the same frame |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
47 |
* with the "package-summary.html" file for the clicked package. |
10 | 48 |
* |
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
49 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
50 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
51 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
52 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
53 |
* |
10 | 54 |
* @author Atul M Dambalkar |
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2212
diff
changeset
|
55 |
* @author Bhavesh Patel (Modified) |
10 | 56 |
*/ |
57 |
public class PackageIndexWriter extends AbstractPackageIndexWriter { |
|
58 |
||
59 |
/** |
|
60 |
* Construct the PackageIndexWriter. Also constructs the grouping |
|
61 |
* information as provided on the command line by "-group" option. Stores |
|
62 |
* the order of groups specified by the user. |
|
63 |
* |
|
40587 | 64 |
* @param configuration the configuration for this doclet |
65 |
* @param filename the path of the page to be generated |
|
10 | 66 |
* @see Group |
67 |
*/ |
|
45417 | 68 |
public PackageIndexWriter(HtmlConfiguration configuration, DocPath filename) { |
10 | 69 |
super(configuration, filename); |
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Generate the package index page for the right-hand frame. |
|
74 |
* |
|
75 |
* @param configuration the current configuration of the doclet. |
|
40587 | 76 |
* @throws DocFileIOException if there is a problem generating the package index page |
10 | 77 |
*/ |
45417 | 78 |
public static void generate(HtmlConfiguration configuration) throws DocFileIOException { |
40500
f293dbb81a53
8162353: javadoc should provide a way to disable use of frames
jjg
parents:
40303
diff
changeset
|
79 |
DocPath filename = DocPaths.overviewSummary(configuration.frames); |
40587 | 80 |
PackageIndexWriter packgen = new PackageIndexWriter(configuration, filename); |
81 |
packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true); |
|
10 | 82 |
} |
83 |
||
84 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
85 |
* Depending upon the grouping information and their titles, add |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
86 |
* separate table indices for each package group. |
10 | 87 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
88 |
* @param header the documentation tree to which the navigational links will be added |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
89 |
* @param main the documentation tree to which the packages list will be added |
10 | 90 |
*/ |
40587 | 91 |
@Override |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
92 |
protected void addIndex(Content header, Content main) { |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
93 |
addIndexContents(header, main); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
94 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
95 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
96 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
97 |
* {@inheritDoc} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
98 |
*/ |
40587 | 99 |
@Override |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
100 |
protected void addPackagesList(Content main) { |
47846 | 101 |
Map<String, SortedSet<PackageElement>> groupPackageMap |
102 |
= configuration.group.groupPackages(packages); |
|
103 |
||
104 |
if (!groupPackageMap.keySet().isEmpty()) { |
|
47447
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47427
diff
changeset
|
105 |
String tableSummary = configuration.getText("doclet.Member_Table_Summary", |
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47427
diff
changeset
|
106 |
configuration.getText("doclet.Package_Summary"), configuration.getText("doclet.packages")); |
47846 | 107 |
Table table = new Table(configuration.htmlVersion, HtmlStyle.overviewSummary) |
108 |
.setSummary(tableSummary) |
|
109 |
.setHeader(getPackageTableHeader()) |
|
110 |
.setColumnStyles(HtmlStyle.colFirst, HtmlStyle.colLast) |
|
111 |
.setDefaultTab(resources.getText("doclet.All_Packages")) |
|
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
112 |
.setTabScript(i -> "show(" + i + ");") |
47846 | 113 |
.setTabId(i -> (i == 0) ? "t0" : ("t" + (1 << (i - 1)))); |
114 |
||
115 |
// add the tabs in command-line order |
|
116 |
for (String groupName : configuration.group.getGroupList()) { |
|
117 |
Set<PackageElement> groupPackages = groupPackageMap.get(groupName); |
|
118 |
if (groupPackages != null) { |
|
119 |
table.addTab(groupName, groupPackages::contains); |
|
47447
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47427
diff
changeset
|
120 |
} |
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47427
diff
changeset
|
121 |
} |
47846 | 122 |
|
123 |
for (PackageElement pkg : configuration.packages) { |
|
124 |
if (!pkg.isUnnamed()) { |
|
125 |
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { |
|
126 |
Content packageLinkContent = getPackageLink(pkg, getPackageName(pkg)); |
|
127 |
Content summaryContent = new ContentBuilder(); |
|
128 |
addSummaryComment(pkg, summaryContent); |
|
129 |
table.addRow(pkg, packageLinkContent, summaryContent); |
|
130 |
} |
|
131 |
} |
|
47447
9887d1bc3e9c
8183037: Overview summary page should have a table with tabs for groups
bpatel
parents:
47427
diff
changeset
|
132 |
} |
47846 | 133 |
|
134 |
Content div = HtmlTree.DIV(HtmlStyle.contentContainer, table.toContent()); |
|
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
135 |
main.addContent(div); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
136 |
|
47846 | 137 |
if (table.needsScript()) { |
47847 | 138 |
getMainBodyScript().append(table.getScript()); |
10 | 139 |
} |
140 |
} |
|
141 |
} |
|
142 |
||
143 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
144 |
* Adds the overview summary comment for this documentation. Add one line |
10 | 145 |
* summary at the top of the page and generate a link to the description, |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
146 |
* which is added at the end of this page. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
147 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
148 |
* @param main the documentation tree to which the overview header will be added |
10 | 149 |
*/ |
40587 | 150 |
@Override |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
151 |
protected void addOverviewHeader(Content main) { |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
152 |
addConfigurationTitle(main); |
41452 | 153 |
if (!utils.getFullBody(configuration.overviewElement).isEmpty()) { |
43755
ae42964e27e3
8173302: Move the Description up on module and package index page
ksrini
parents:
41452
diff
changeset
|
154 |
HtmlTree div = new HtmlTree(HtmlTag.DIV); |
47846 | 155 |
div.setStyle(HtmlStyle.contentContainer); |
43755
ae42964e27e3
8173302: Move the Description up on module and package index page
ksrini
parents:
41452
diff
changeset
|
156 |
addOverviewComment(div); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
157 |
main.addContent(div); |
10 | 158 |
} |
159 |
} |
|
160 |
||
161 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
162 |
* Adds the overview comment as provided in the file specified by the |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
163 |
* "-overview" option on the command line. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
164 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
165 |
* @param htmltree the documentation tree to which the overview comment will |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
166 |
* be added |
10 | 167 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
168 |
protected void addOverviewComment(Content htmltree) { |
41452 | 169 |
if (!utils.getFullBody(configuration.overviewElement).isEmpty()) { |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
31751
diff
changeset
|
170 |
addInlineComment(configuration.overviewElement, htmltree); |
10 | 171 |
} |
172 |
} |
|
173 |
||
174 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
175 |
* Adds the top text (from the -top option), the upper |
10 | 176 |
* navigation bar, and then the title (from the"-title" |
177 |
* option), at the top of page. |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
178 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
179 |
* @param header the documentation tree to which the navigation bar header will be added |
10 | 180 |
*/ |
40587 | 181 |
@Override |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
182 |
protected void addNavigationBarHeader(Content header) { |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
183 |
addTop(header); |
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
47847
diff
changeset
|
184 |
navBar.setUserHeader(getUserHeaderFooter(true)); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
185 |
header.addContent(navBar.getContent(true)); |
10 | 186 |
} |
187 |
||
188 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
189 |
* Adds the lower navigation bar and the bottom text |
10 | 190 |
* (from the -bottom option) at the bottom of page. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
191 |
* |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
192 |
* @param footer the documentation tree to which the navigation bar footer will be added |
10 | 193 |
*/ |
40587 | 194 |
@Override |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
195 |
protected void addNavigationBarFooter(Content footer) { |
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
47847
diff
changeset
|
196 |
navBar.setUserFooter(getUserHeaderFooter(false)); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
197 |
footer.addContent(navBar.getContent(false)); |
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
50167
diff
changeset
|
198 |
addBottom(footer); |
10 | 199 |
} |
200 |
} |