author | pmuthuswamy |
Wed, 19 Sep 2018 12:14:53 +0530 | |
changeset 51797 | 3efead10e303 |
parent 48654 | 36f58bd6269f |
child 53863 | d001808c57e8 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47850
diff
changeset
|
2 |
* Copyright (c) 1998, 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:
29957
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.formats.html; |
10 | 27 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
28 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
29 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
30 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
31 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
32 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
47850 | 34 |
import jdk.javadoc.internal.doclets.formats.html.markup.Links; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
35 |
import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
36 |
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
37 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
40587 | 38 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
39 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
40 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
41 |
|
10 | 42 |
|
43 |
/** |
|
44 |
* Generate the package index for the left-hand frame in the generated output. |
|
45 |
* A click on the package name in this frame will update the page in the bottom |
|
46 |
* left hand frame with the listing of contents of the clicked package. |
|
47 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
48 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
49 |
* If you write code that depends on this, you do so at your own risk. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
50 |
* This code and its internal interfaces are subject to change or |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
51 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
52 |
* |
10 | 53 |
* @author Atul M Dambalkar |
54 |
*/ |
|
55 |
public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { |
|
56 |
||
57 |
/** |
|
58 |
* Construct the PackageIndexFrameWriter object. |
|
59 |
* |
|
60 |
* @param filename Name of the package index file to be generated. |
|
61 |
*/ |
|
45417 | 62 |
public PackageIndexFrameWriter(HtmlConfiguration configuration, DocPath filename) { |
10 | 63 |
super(configuration, filename); |
64 |
} |
|
65 |
||
66 |
/** |
|
67 |
* Generate the package index file named "overview-frame.html". |
|
40587 | 68 |
* @throws DocFileIOException |
10 | 69 |
*/ |
45417 | 70 |
public static void generate(HtmlConfiguration configuration) throws DocFileIOException { |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
71 |
DocPath filename = DocPaths.OVERVIEW_FRAME; |
40587 | 72 |
PackageIndexFrameWriter packgen = new PackageIndexFrameWriter(configuration, filename); |
73 |
packgen.buildPackageIndexFile("doclet.Window_Overview", false); |
|
10 | 74 |
} |
75 |
||
76 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
77 |
* {@inheritDoc} |
10 | 78 |
*/ |
40587 | 79 |
@Override |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
48654
diff
changeset
|
80 |
protected void addPackagesList(Content main) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
81 |
Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, |
40303 | 82 |
contents.packagesLabel); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
48654
diff
changeset
|
83 |
HtmlTree htmlTree = HtmlTree.DIV(HtmlStyle.indexContainer, heading); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
84 |
HtmlTree ul = new HtmlTree(HtmlTag.UL); |
40303 | 85 |
ul.setTitle(contents.packagesLabel); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
86 |
for (PackageElement aPackage : packages) { |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
7681
diff
changeset
|
87 |
// Do not list the package if -nodeprecated option is set and the |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
7681
diff
changeset
|
88 |
// package is marked as deprecated. |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
19667
diff
changeset
|
89 |
if (aPackage != null && |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
25287
diff
changeset
|
90 |
(!(configuration.nodeprecated && utils.isDeprecated(aPackage)))) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
19667
diff
changeset
|
91 |
ul.addContent(getPackage(aPackage)); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
92 |
} |
10 | 93 |
} |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
94 |
htmlTree.addContent(ul); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
48654
diff
changeset
|
95 |
main.addContent(htmlTree); |
10 | 96 |
} |
97 |
||
98 |
/** |
|
25287 | 99 |
* Returns each package name as a separate link. |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
100 |
* |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
101 |
* @param pe PackageElement |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
102 |
* @return content for the package link |
10 | 103 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
104 |
protected Content getPackage(PackageElement pe) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
105 |
Content packageLinkContent; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
106 |
Content packageLabel; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
107 |
if (pe.isUnnamed()) { |
17560 | 108 |
packageLabel = new StringContent("<unnamed package>"); |
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47850
diff
changeset
|
109 |
packageLinkContent = links.createLink(DocPaths.PACKAGE_FRAME, |
14358
9eda9239cba0
8000416: refactor javadoc to provide and use an abstraction for relative URIs
jjg
parents:
14357
diff
changeset
|
110 |
packageLabel, "", "packageFrame"); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
111 |
} else { |
36500
d31e4986dc8b
8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents:
35426
diff
changeset
|
112 |
packageLabel = getPackageLabel(pe.getQualifiedName()); |
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47850
diff
changeset
|
113 |
packageLinkContent = links.createLink(pathString(pe, |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
114 |
DocPaths.PACKAGE_FRAME), packageLabel, "", |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
29957
diff
changeset
|
115 |
"packageFrame"); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
116 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
117 |
Content li = HtmlTree.LI(packageLinkContent); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
118 |
return li; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
119 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
120 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
121 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
122 |
* {@inheritDoc} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
123 |
*/ |
40587 | 124 |
@Override |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
48654
diff
changeset
|
125 |
protected void addNavigationBarHeader(Content header) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
126 |
Content headerContent; |
10 | 127 |
if (configuration.packagesheader.length() > 0) { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
128 |
headerContent = new RawHtml(replaceDocRootDir(configuration.packagesheader)); |
10 | 129 |
} else { |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
130 |
headerContent = new RawHtml(replaceDocRootDir(configuration.header)); |
10 | 131 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
132 |
Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
133 |
HtmlStyle.bar, headerContent); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
48654
diff
changeset
|
134 |
header.addContent(heading); |
10 | 135 |
} |
136 |
||
137 |
/** |
|
138 |
* Do nothing as there is no overview information in this page. |
|
139 |
*/ |
|
40587 | 140 |
@Override |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
141 |
protected void addOverviewHeader(Content body) { |
10 | 142 |
} |
143 |
||
144 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
145 |
* Adds "All Classes" link for the top of the left-hand frame page to the |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
146 |
* documentation tree. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
147 |
* |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
148 |
* @param ul the Content object to which the "All Classes" link should be added |
10 | 149 |
*/ |
40587 | 150 |
@Override |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
151 |
protected void addAllClassesLink(Content ul) { |
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47850
diff
changeset
|
152 |
Content linkContent = links.createLink(DocPaths.ALLCLASSES_FRAME, |
40303 | 153 |
contents.allClassesLabel, "", "packageFrame"); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
154 |
Content li = HtmlTree.LI(linkContent); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
155 |
ul.addContent(li); |
15723
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14358
diff
changeset
|
156 |
} |
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14358
diff
changeset
|
157 |
|
58a73dac9ee4
8006124: javadoc/doclet should be updated to support profiles
bpatel
parents:
14358
diff
changeset
|
158 |
/** |
36526 | 159 |
* Adds "All Modules" link for the top of the left-hand frame page to the |
160 |
* documentation tree. |
|
161 |
* |
|
162 |
* @param ul the Content object to which the "All Modules" link should be added |
|
163 |
*/ |
|
40587 | 164 |
@Override |
36526 | 165 |
protected void addAllModulesLink(Content ul) { |
48654
36f58bd6269f
8195796: Reduce the size of relative URLs in generated docs
jjg
parents:
47850
diff
changeset
|
166 |
Content linkContent = links.createLink(DocPaths.MODULE_OVERVIEW_FRAME, |
40303 | 167 |
contents.allModulesLabel, "", "packageListFrame"); |
36526 | 168 |
Content li = HtmlTree.LI(linkContent); |
169 |
ul.addContent(li); |
|
170 |
} |
|
171 |
||
172 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
173 |
* {@inheritDoc} |
10 | 174 |
*/ |
40587 | 175 |
@Override |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
48654
diff
changeset
|
176 |
protected void addNavigationBarFooter(Content footer) { |
40303 | 177 |
Content p = HtmlTree.P(Contents.SPACE); |
51797
3efead10e303
8210047: some pages contain content outside of landmark region
pmuthuswamy
parents:
48654
diff
changeset
|
178 |
footer.addContent(p); |
10 | 179 |
} |
180 |
} |