author | ksrini |
Mon, 05 Jun 2017 13:45:34 -0700 | |
changeset 45417 | f7479ee8de69 |
parent 44564 | 4e1df2513486 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
44564 | 2 |
* Copyright (c) 1997, 2017, 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:
33920
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.formats.html.markup; |
10 | 27 |
|
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1863
diff
changeset
|
28 |
import java.io.*; |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
29 |
import java.util.*; |
2216
b124d5c924eb
6786690: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - DL tag and nesting issue
bpatel
parents:
1863
diff
changeset
|
30 |
|
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
31 |
import jdk.javadoc.doclet.DocletEnvironment.ModuleMode; |
45417 | 32 |
import jdk.javadoc.internal.doclets.toolkit.BaseConfiguration; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
40303 | 34 |
import jdk.javadoc.internal.doclets.toolkit.Resources; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
35 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFile; |
40587 | 36 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
37 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
38 |
import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
39 |
import jdk.javadoc.internal.doclets.toolkit.util.TableTabTypes; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
40 |
|
10 | 41 |
|
42 |
/** |
|
43 |
* Class for the Html format code generation. |
|
14266
69453558960d
8000673: remove dead code from HtmlWriter and subtypes
jjg
parents:
14265
diff
changeset
|
44 |
* Initializes PrintWriter with FileWriter, to enable print |
10 | 45 |
* related methods to generate the code to the named File through FileWriter. |
46 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
47 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
48 |
* 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
|
49 |
* 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
|
50 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14259
diff
changeset
|
51 |
* |
10 | 52 |
* @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:
2223
diff
changeset
|
53 |
* @author Bhavesh Patel (Modified) |
10 | 54 |
*/ |
14266
69453558960d
8000673: remove dead code from HtmlWriter and subtypes
jjg
parents:
14265
diff
changeset
|
55 |
public class HtmlWriter { |
10 | 56 |
|
57 |
/** |
|
58 |
* The window title of this file |
|
59 |
*/ |
|
60 |
protected String winTitle; |
|
61 |
||
62 |
/** |
|
63 |
* The configuration |
|
64 |
*/ |
|
45417 | 65 |
protected BaseConfiguration configuration; |
10 | 66 |
|
67 |
/** |
|
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
68 |
* Header for table displaying modules and description. |
36526 | 69 |
*/ |
70 |
protected final List<String> moduleTableHeader; |
|
71 |
||
72 |
/** |
|
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
73 |
* Header for tables displaying packages and description. |
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
74 |
*/ |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
75 |
protected final List<String> packageTableHeader; |
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
76 |
|
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
77 |
/** |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
78 |
* Header for tables displaying modules and description. |
39670
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
79 |
*/ |
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
80 |
protected final List<String> requiresTableHeader; |
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
81 |
|
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
82 |
/** |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
83 |
* Header for tables displaying packages and description. |
39670
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
84 |
*/ |
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
85 |
protected final List<String> exportedPackagesTableHeader; |
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
86 |
|
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
87 |
/** |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
88 |
* Header for tables displaying modules and exported packages. |
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
89 |
*/ |
44564 | 90 |
protected final List<String> indirectPackagesTableHeader; |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
91 |
|
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
92 |
/** |
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
93 |
* Header for tables displaying types and description. |
39670
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
94 |
*/ |
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
95 |
protected final List<String> usesTableHeader; |
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
96 |
|
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
97 |
/** |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
98 |
* Header for tables displaying types and description. |
39670
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
99 |
*/ |
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
100 |
protected final List<String> providesTableHeader; |
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
101 |
|
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
102 |
/** |
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
103 |
* Summary for use tables displaying class and package use. |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
104 |
*/ |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
105 |
protected final String useTableSummary; |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
106 |
|
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
107 |
/** |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
108 |
* Column header for class docs displaying Modifier and Type header. |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
109 |
*/ |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
110 |
protected final String modifierTypeHeader; |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
111 |
|
40303 | 112 |
private final DocFile docFile; |
14266
69453558960d
8000673: remove dead code from HtmlWriter and subtypes
jjg
parents:
14265
diff
changeset
|
113 |
|
33920 | 114 |
protected Content script; |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
115 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
116 |
|
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
117 |
/** |
10 | 118 |
* Constructor. |
119 |
* |
|
120 |
* @param path The directory path to be created for this file |
|
121 |
* or null if none to be created. |
|
122 |
*/ |
|
45417 | 123 |
public HtmlWriter(BaseConfiguration configuration, DocPath path) { |
40303 | 124 |
docFile = DocFile.createFileForOutput(configuration, path); |
10 | 125 |
this.configuration = configuration; |
40303 | 126 |
|
127 |
// The following should be converted to shared Content objects |
|
128 |
// and moved to Contents, but that will require additional |
|
129 |
// changes at the use sites. |
|
130 |
Resources resources = configuration.getResources(); |
|
36526 | 131 |
moduleTableHeader = Arrays.asList( |
40303 | 132 |
resources.getText("doclet.Module"), |
133 |
resources.getText("doclet.Description")); |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
134 |
packageTableHeader = new ArrayList<>(); |
40303 | 135 |
packageTableHeader.add(resources.getText("doclet.Package")); |
136 |
packageTableHeader.add(resources.getText("doclet.Description")); |
|
39670
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
137 |
requiresTableHeader = new ArrayList<>(); |
44564 | 138 |
requiresTableHeader.add(resources.getText("doclet.Modifier")); |
40303 | 139 |
requiresTableHeader.add(resources.getText("doclet.Module")); |
140 |
requiresTableHeader.add(resources.getText("doclet.Description")); |
|
39670
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
141 |
exportedPackagesTableHeader = new ArrayList<>(); |
40303 | 142 |
exportedPackagesTableHeader.add(resources.getText("doclet.Package")); |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
143 |
if (configuration.docEnv.getModuleMode() == ModuleMode.ALL) { |
44564 | 144 |
exportedPackagesTableHeader.add(resources.getText("doclet.Module")); |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
145 |
} |
40303 | 146 |
exportedPackagesTableHeader.add(resources.getText("doclet.Description")); |
44564 | 147 |
indirectPackagesTableHeader = new ArrayList<>(); |
148 |
indirectPackagesTableHeader.add(resources.getText("doclet.From")); |
|
149 |
indirectPackagesTableHeader.add(resources.getText("doclet.Packages")); |
|
39670
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
150 |
usesTableHeader = new ArrayList<>(); |
40303 | 151 |
usesTableHeader.add(resources.getText("doclet.Type")); |
152 |
usesTableHeader.add(resources.getText("doclet.Description")); |
|
39670
9d1eafbf29c6
8154261: Module summary page should display directives for the module
bpatel
parents:
36526
diff
changeset
|
153 |
providesTableHeader = new ArrayList<>(); |
40303 | 154 |
providesTableHeader.add(resources.getText("doclet.Type")); |
155 |
providesTableHeader.add(resources.getText("doclet.Description")); |
|
156 |
useTableSummary = resources.getText("doclet.Use_Table_Summary", |
|
157 |
resources.getText("doclet.packages")); |
|
158 |
modifierTypeHeader = resources.getText("doclet.0_and_1", |
|
159 |
resources.getText("doclet.Modifier"), |
|
160 |
resources.getText("doclet.Type")); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
161 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
162 |
|
40587 | 163 |
public void write(Content c) throws DocFileIOException { |
40303 | 164 |
try (Writer writer = docFile.openWriter()) { |
165 |
c.write(writer, true); |
|
40587 | 166 |
} catch (IOException e) { |
167 |
throw new DocFileIOException(docFile, DocFileIOException.Mode.WRITE, e); |
|
19907 | 168 |
} |
10 | 169 |
} |
170 |
||
171 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
172 |
* Returns an HtmlTree for the SCRIPT tag. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
173 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
174 |
* @return an HtmlTree for the SCRIPT tag |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
175 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
176 |
protected HtmlTree getWinTitleScript(){ |
40303 | 177 |
HtmlTree scriptTree = HtmlTree.SCRIPT(); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
178 |
if(winTitle != null && winTitle.length() > 0) { |
40303 | 179 |
String scriptCode = "<!--\n" + |
180 |
" try {\n" + |
|
181 |
" if (location.href.indexOf('is-external=true') == -1) {\n" + |
|
182 |
" parent.document.title=\"" + escapeJavaScriptChars(winTitle) + "\";\n" + |
|
183 |
" }\n" + |
|
184 |
" }\n" + |
|
185 |
" catch(err) {\n" + |
|
186 |
" }\n" + |
|
187 |
"//-->\n"; |
|
188 |
RawHtml scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL)); |
|
189 |
scriptTree.addContent(scriptContent); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
190 |
} |
40303 | 191 |
return scriptTree; |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
192 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
193 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
194 |
/** |
21026 | 195 |
* Returns a String with escaped special JavaScript characters. |
196 |
* |
|
197 |
* @param s String that needs to be escaped |
|
198 |
* @return a valid escaped JavaScript string |
|
199 |
*/ |
|
200 |
private static String escapeJavaScriptChars(String s) { |
|
201 |
StringBuilder sb = new StringBuilder(); |
|
202 |
for (int i = 0; i < s.length(); i++) { |
|
203 |
char ch = s.charAt(i); |
|
204 |
switch (ch) { |
|
205 |
case '\b': |
|
206 |
sb.append("\\b"); |
|
207 |
break; |
|
208 |
case '\t': |
|
209 |
sb.append("\\t"); |
|
210 |
break; |
|
211 |
case '\n': |
|
212 |
sb.append("\\n"); |
|
213 |
break; |
|
214 |
case '\f': |
|
215 |
sb.append("\\f"); |
|
216 |
break; |
|
217 |
case '\r': |
|
218 |
sb.append("\\r"); |
|
219 |
break; |
|
220 |
case '"': |
|
221 |
sb.append("\\\""); |
|
222 |
break; |
|
223 |
case '\'': |
|
224 |
sb.append("\\\'"); |
|
225 |
break; |
|
226 |
case '\\': |
|
227 |
sb.append("\\\\"); |
|
228 |
break; |
|
229 |
default: |
|
230 |
if (ch < 32 || ch >= 127) { |
|
231 |
sb.append(String.format("\\u%04X", (int)ch)); |
|
232 |
} else { |
|
233 |
sb.append(ch); |
|
234 |
} |
|
235 |
break; |
|
236 |
} |
|
237 |
} |
|
238 |
return sb.toString(); |
|
239 |
} |
|
240 |
||
241 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
242 |
* Returns a content tree for the SCRIPT tag for the main page(index.html). |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
243 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
244 |
* @return a content for the SCRIPT tag |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
245 |
*/ |
29429
964498d4dcec
8074521: Generate iframe instead of frame and frameset for index.html page
bpatel
parents:
25874
diff
changeset
|
246 |
protected Content getFramesJavaScript() { |
40303 | 247 |
HtmlTree scriptTree = HtmlTree.SCRIPT(); |
248 |
String scriptCode = "\n" + |
|
41630 | 249 |
" tmpTargetPage = \"\" + window.location.search;\n" + |
250 |
" if (tmpTargetPage != \"\" && tmpTargetPage != \"undefined\")\n" + |
|
251 |
" tmpTargetPage = tmpTargetPage.substring(1);\n" + |
|
252 |
" if (tmpTargetPage.indexOf(\":\") != -1 || (tmpTargetPage != \"\" && !validURL(tmpTargetPage)))\n" + |
|
253 |
" tmpTargetPage = \"undefined\";\n" + |
|
254 |
" targetPage = tmpTargetPage;\n" + |
|
40303 | 255 |
" function validURL(url) {\n" + |
256 |
" try {\n" + |
|
257 |
" url = decodeURIComponent(url);\n" + |
|
258 |
" }\n" + |
|
259 |
" catch (error) {\n" + |
|
260 |
" return false;\n" + |
|
261 |
" }\n" + |
|
262 |
" var pos = url.indexOf(\".html\");\n" + |
|
263 |
" if (pos == -1 || pos != url.length - 5)\n" + |
|
264 |
" return false;\n" + |
|
265 |
" var allowNumber = false;\n" + |
|
266 |
" var allowSep = false;\n" + |
|
267 |
" var seenDot = false;\n" + |
|
268 |
" for (var i = 0; i < url.length - 5; i++) {\n" + |
|
269 |
" var ch = url.charAt(i);\n" + |
|
270 |
" if ('a' <= ch && ch <= 'z' ||\n" + |
|
271 |
" 'A' <= ch && ch <= 'Z' ||\n" + |
|
272 |
" ch == '$' ||\n" + |
|
273 |
" ch == '_' ||\n" + |
|
274 |
" ch.charCodeAt(0) > 127) {\n" + |
|
275 |
" allowNumber = true;\n" + |
|
276 |
" allowSep = true;\n" + |
|
277 |
" } else if ('0' <= ch && ch <= '9'\n" + |
|
278 |
" || ch == '-') {\n" + |
|
279 |
" if (!allowNumber)\n" + |
|
280 |
" return false;\n" + |
|
281 |
" } else if (ch == '/' || ch == '.') {\n" + |
|
282 |
" if (!allowSep)\n" + |
|
283 |
" return false;\n" + |
|
284 |
" allowNumber = false;\n" + |
|
285 |
" allowSep = false;\n" + |
|
286 |
" if (ch == '.')\n" + |
|
287 |
" seenDot = true;\n" + |
|
288 |
" if (ch == '/' && seenDot)\n" + |
|
289 |
" return false;\n" + |
|
290 |
" } else {\n" + |
|
291 |
" return false;\n" + |
|
292 |
" }\n" + |
|
293 |
" }\n" + |
|
294 |
" return true;\n" + |
|
295 |
" }\n" + |
|
296 |
" function loadFrames() {\n" + |
|
297 |
" if (targetPage != \"\" && targetPage != \"undefined\")\n" + |
|
298 |
" top.classFrame.location = top.targetPage;\n" + |
|
299 |
" }\n"; |
|
300 |
RawHtml scriptContent = new RawHtml(scriptCode.replace("\n", DocletConstants.NL)); |
|
301 |
scriptTree.addContent(scriptContent); |
|
302 |
return scriptTree; |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
303 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
304 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
305 |
/** |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
306 |
* Returns an HtmlTree for the BODY tag. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
307 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
308 |
* @param includeScript set true if printing windowtitle script |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
309 |
* @param title title for the window |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
310 |
* @return an HtmlTree for the BODY tag |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
311 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
312 |
public HtmlTree getBody(boolean includeScript, String title) { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
313 |
HtmlTree body = new HtmlTree(HtmlTag.BODY); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
314 |
// Set window title string which is later printed |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
315 |
this.winTitle = title; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
316 |
// Don't print windowtitle script for overview-frame, allclasses-frame |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
317 |
// and package-frame |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
318 |
if (includeScript) { |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
319 |
this.script = getWinTitleScript(); |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
320 |
body.addContent(script); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
321 |
Content noScript = HtmlTree.NOSCRIPT( |
40303 | 322 |
HtmlTree.DIV(configuration.getContent("doclet.No_Script_Message"))); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
323 |
body.addContent(noScript); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
324 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
325 |
return body; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
326 |
} |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
327 |
|
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
328 |
/** |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
329 |
* Generated javascript variables for the document. |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
330 |
* |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
331 |
* @param typeMap map comprising of method and type relationship |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
332 |
* @param tabTypes set comprising of all table tab types for this class |
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
333 |
* @param elementName packages or methods table for which tabs need to be displayed |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
334 |
*/ |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
335 |
public void generateTableTabTypesScript(Map<String,Integer> typeMap, |
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
336 |
Set<? extends TableTabTypes> tabTypes, String elementName) { |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
337 |
String sep = ""; |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
338 |
StringBuilder vars = new StringBuilder("var "); |
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
339 |
vars.append(elementName) |
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
340 |
.append(" = {"); |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
341 |
for (Map.Entry<String,Integer> entry : typeMap.entrySet()) { |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
342 |
vars.append(sep); |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
343 |
sep = ","; |
30528 | 344 |
vars.append("\"") |
345 |
.append(entry.getKey()) |
|
346 |
.append("\":") |
|
347 |
.append(entry.getValue()); |
|
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
348 |
} |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
349 |
vars.append("};").append(DocletConstants.NL); |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
350 |
sep = ""; |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
351 |
vars.append("var tabs = {"); |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
352 |
for (TableTabTypes entry : tabTypes) { |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
353 |
vars.append(sep); |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
354 |
sep = ","; |
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
355 |
vars.append(entry.tableTabs().value()) |
30528 | 356 |
.append(":") |
357 |
.append("[") |
|
358 |
.append("\"") |
|
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
359 |
.append(entry.tableTabs().tabId()) |
30528 | 360 |
.append("\"") |
361 |
.append(sep) |
|
362 |
.append("\"") |
|
42831
feff6f296019
8160196: Module summary page should display information based on "api" or "detail" mode.
bpatel
parents:
41630
diff
changeset
|
363 |
.append(configuration.getText(entry.tableTabs().resourceKey())) |
30528 | 364 |
.append("\"]"); |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
365 |
} |
30528 | 366 |
vars.append("};") |
367 |
.append(DocletConstants.NL); |
|
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
368 |
addStyles(HtmlStyle.altColor, vars); |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
369 |
addStyles(HtmlStyle.rowColor, vars); |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
370 |
addStyles(HtmlStyle.tableTab, vars); |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
371 |
addStyles(HtmlStyle.activeTableTab, vars); |
36500
d31e4986dc8b
8149139: [javadoc] Modify Content to accept CharSequence
ksrini
parents:
36270
diff
changeset
|
372 |
script.addContent(new RawHtml(vars)); |
14549
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
373 |
} |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
374 |
|
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
375 |
/** |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
376 |
* Adds javascript style variables to the document. |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
377 |
* |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
378 |
* @param style style to be added as a javascript variable |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
379 |
* @param vars variable string to which the style variable will be added |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
380 |
*/ |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
381 |
public void addStyles(HtmlStyle style, StringBuilder vars) { |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
382 |
vars.append("var ").append(style).append(" = \"").append(style) |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
383 |
.append("\";").append(DocletConstants.NL); |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
384 |
} |
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
385 |
|
0599d73bf1da
8002304: Group methods by types in methods summary section
bpatel
parents:
14368
diff
changeset
|
386 |
/** |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
387 |
* Returns an HtmlTree for the TITLE tag. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
388 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
389 |
* @return an HtmlTree for the TITLE tag |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
390 |
*/ |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
391 |
public HtmlTree getTitle() { |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
392 |
HtmlTree title = HtmlTree.TITLE(new StringContent(winTitle)); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
393 |
return title; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
394 |
} |
10 | 395 |
|
2320
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
396 |
/* |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
397 |
* Returns a header for Modifier and Type column of a table. |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
398 |
*/ |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
399 |
public String getModifierTypeHeader() { |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
400 |
return modifierTypeHeader; |
5b8c377175f4
6786688: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Table must have captions and headers
bpatel
parents:
2223
diff
changeset
|
401 |
} |
10 | 402 |
} |