author | bpatel |
Mon, 13 Apr 2015 18:05:23 -0700 | |
changeset 29957 | 7740f9657f56 |
parent 25874 | 83c19f00452c |
child 33920 | bd731341c405 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
2 |
* Copyright (c) 1998, 2015, 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 |
||
26 |
package com.sun.tools.doclets.formats.html; |
|
27 |
||
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
28 |
import java.io.*; |
14258 | 29 |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
30 |
import com.sun.tools.doclets.formats.html.markup.*; |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
31 |
import com.sun.tools.doclets.internal.toolkit.*; |
14258 | 32 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
10 | 33 |
|
34 |
/** |
|
35 |
* Generate only one index file for all the Member Names with Indexing in |
|
36 |
* Unicode Order. The name of the generated file is "index-all.html" and it is |
|
37 |
* generated in current or the destination directory. |
|
38 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
39 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
40 |
* 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
|
41 |
* 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
|
42 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
43 |
* |
10 | 44 |
* @see java.lang.Character |
45 |
* @author Atul M Dambalkar |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
46 |
* @author Bhavesh Patel (Modified) |
10 | 47 |
*/ |
48 |
public class SingleIndexWriter extends AbstractIndexWriter { |
|
49 |
||
50 |
/** |
|
51 |
* Construct the SingleIndexWriter with filename "index-all.html" and the |
|
52 |
* {@link IndexBuilder} |
|
53 |
* |
|
54 |
* @param filename Name of the index file to be generated. |
|
55 |
* @param indexbuilder Unicode based Index from {@link IndexBuilder} |
|
56 |
*/ |
|
57 |
public SingleIndexWriter(ConfigurationImpl configuration, |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
58 |
DocPath filename, |
10 | 59 |
IndexBuilder indexbuilder) throws IOException { |
60 |
super(configuration, filename, indexbuilder); |
|
61 |
} |
|
62 |
||
63 |
/** |
|
64 |
* Generate single index file, for all Unicode characters. |
|
65 |
* |
|
66 |
* @param indexbuilder IndexBuilder built by {@link IndexBuilder} |
|
67 |
* @throws DocletAbortException |
|
68 |
*/ |
|
69 |
public static void generate(ConfigurationImpl configuration, |
|
70 |
IndexBuilder indexbuilder) { |
|
71 |
SingleIndexWriter indexgen; |
|
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
72 |
DocPath filename = DocPaths.INDEX_ALL; |
10 | 73 |
try { |
74 |
indexgen = new SingleIndexWriter(configuration, |
|
75 |
filename, indexbuilder); |
|
76 |
indexgen.generateIndexFile(); |
|
77 |
indexgen.close(); |
|
78 |
} catch (IOException exc) { |
|
79 |
configuration.standardmessage.error( |
|
80 |
"doclet.exception_encountered", |
|
81 |
exc.toString(), filename); |
|
19667
fdfce85627a9
8001669: javadoc internal DocletAbortException should set cause when appropriate
jjg
parents:
14357
diff
changeset
|
82 |
throw new DocletAbortException(exc); |
10 | 83 |
} |
84 |
} |
|
85 |
||
86 |
/** |
|
87 |
* Generate the contents of each index file, with Header, Footer, |
|
88 |
* Member Field, Method and Constructor Description. |
|
89 |
*/ |
|
90 |
protected void generateIndexFile() throws IOException { |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
91 |
String title = configuration.getText("doclet.Window_Single_Index"); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
92 |
HtmlTree body = getBody(true, getWindowTitle(title)); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
93 |
HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER)) |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
94 |
? HtmlTree.HEADER() |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
95 |
: body; |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
96 |
addTop(htmlTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
97 |
addNavLinks(true, htmlTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
98 |
if (configuration.allowTag(HtmlTag.HEADER)) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
99 |
body.addContent(htmlTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
100 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
101 |
HtmlTree divTree = new HtmlTree(HtmlTag.DIV); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
102 |
divTree.addStyle(HtmlStyle.contentContainer); |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
103 |
addLinksForIndexes(divTree); |
10 | 104 |
for (int i = 0; i < indexbuilder.elements().length; i++) { |
105 |
Character unicode = (Character)((indexbuilder.elements())[i]); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
106 |
addContents(unicode, indexbuilder.getMemberList(unicode), divTree); |
10 | 107 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
108 |
addLinksForIndexes(divTree); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
109 |
body.addContent((configuration.allowTag(HtmlTag.MAIN)) |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
110 |
? HtmlTree.MAIN(divTree) |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
111 |
: divTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
112 |
if (configuration.allowTag(HtmlTag.FOOTER)) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
113 |
htmlTree = HtmlTree.FOOTER(); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
114 |
} |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
115 |
addNavLinks(false, htmlTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
116 |
addBottom(htmlTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
117 |
if (configuration.allowTag(HtmlTag.FOOTER)) { |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
118 |
body.addContent(htmlTree); |
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
119 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
120 |
printHtmlDocument(null, true, body); |
10 | 121 |
} |
122 |
||
123 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
124 |
* Add links for all the Index Files per unicode character. |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
125 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
126 |
* @param contentTree the content tree to which the links for indexes will be added |
10 | 127 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
128 |
protected void addLinksForIndexes(Content contentTree) { |
10 | 129 |
for (int i = 0; i < indexbuilder.elements().length; i++) { |
130 |
String unicode = (indexbuilder.elements())[i].toString(); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
131 |
contentTree.addContent( |
21008
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
19667
diff
changeset
|
132 |
getHyperLink(getNameForIndex(unicode), |
af0b915df7cc
8025633: Fix javadoc to generate valid anchor names
bpatel
parents:
19667
diff
changeset
|
133 |
new StringContent(unicode))); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
134 |
contentTree.addContent(getSpace()); |
10 | 135 |
} |
136 |
} |
|
137 |
} |