author | jjg |
Mon, 04 Mar 2019 11:19:34 -0800 | |
changeset 53991 | 786825220790 |
parent 53880 | 3f1e9372557f |
child 54060 | 53a95878619f |
permissions | -rw-r--r-- |
10 | 1 |
/* |
53863
d001808c57e8
8218998: Add metadata to generated API documentation files
jjg
parents:
53562
diff
changeset
|
2 |
* Copyright (c) 1998, 2019, 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; |
10 | 27 |
|
33920 | 28 |
import java.util.*; |
14258 | 29 |
|
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
30 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
31 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
32 |
import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
34 |
import jdk.javadoc.internal.doclets.toolkit.Content; |
40587 | 35 |
import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
36 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPath; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
37 |
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
38 |
import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
39 |
|
10 | 40 |
|
41 |
/** |
|
42 |
* Generate only one index file for all the Member Names with Indexing in |
|
43 |
* Unicode Order. The name of the generated file is "index-all.html" and it is |
|
44 |
* generated in current or the destination directory. |
|
45 |
* |
|
14260
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
46 |
* <p><b>This is NOT part of any supported API. |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
47 |
* 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
|
48 |
* 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
|
49 |
* deletion without notice.</b> |
727a84636f12
8000665: fix "internal API" comments on javadoc files
jjg
parents:
14258
diff
changeset
|
50 |
* |
10 | 51 |
* @see java.lang.Character |
52 |
* @author Atul M Dambalkar |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
53 |
* @author Bhavesh Patel (Modified) |
10 | 54 |
*/ |
55 |
public class SingleIndexWriter extends AbstractIndexWriter { |
|
56 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
57 |
private Set<Character> elements; |
33920 | 58 |
|
10 | 59 |
/** |
60 |
* Construct the SingleIndexWriter with filename "index-all.html" and the |
|
61 |
* {@link IndexBuilder} |
|
62 |
* |
|
40587 | 63 |
* @param configuration the configuration for this doclet |
10 | 64 |
* @param filename Name of the index file to be generated. |
65 |
* @param indexbuilder Unicode based Index from {@link IndexBuilder} |
|
66 |
*/ |
|
45417 | 67 |
public SingleIndexWriter(HtmlConfiguration configuration, |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
68 |
DocPath filename, |
40587 | 69 |
IndexBuilder indexbuilder) { |
10 | 70 |
super(configuration, filename, indexbuilder); |
71 |
} |
|
72 |
||
73 |
/** |
|
74 |
* Generate single index file, for all Unicode characters. |
|
75 |
* |
|
40587 | 76 |
* @param configuration the configuration for this doclet |
10 | 77 |
* @param indexbuilder IndexBuilder built by {@link IndexBuilder} |
40587 | 78 |
* @throws DocFileIOException if there is a problem generating the index |
10 | 79 |
*/ |
45417 | 80 |
public static void generate(HtmlConfiguration configuration, |
40587 | 81 |
IndexBuilder indexbuilder) throws DocFileIOException { |
14357
faf9cde2817b
8000741: refactor javadoc to use abstraction to handle relative paths
jjg
parents:
14260
diff
changeset
|
82 |
DocPath filename = DocPaths.INDEX_ALL; |
40587 | 83 |
SingleIndexWriter indexgen = new SingleIndexWriter(configuration, |
84 |
filename, indexbuilder); |
|
85 |
indexgen.generateIndexFile(); |
|
10 | 86 |
} |
87 |
||
88 |
/** |
|
89 |
* Generate the contents of each index file, with Header, Footer, |
|
90 |
* Member Field, Method and Constructor Description. |
|
40587 | 91 |
* @throws DocFileIOException if there is a problem generating the index |
10 | 92 |
*/ |
40587 | 93 |
protected void generateIndexFile() throws DocFileIOException { |
52644
43efb4ca6d6c
8214139: Remove wrapper methods from {Base,Html}Configuration
jjg
parents:
50167
diff
changeset
|
94 |
String title = resources.getText("doclet.Window_Single_Index"); |
29957
7740f9657f56
8072945: Javadoc should generate valid and compliant HTML5 output
bpatel
parents:
25874
diff
changeset
|
95 |
HtmlTree body = getBody(true, getWindowTitle(title)); |
53991 | 96 |
HtmlTree header = HtmlTree.HEADER(); |
97 |
addTop(header); |
|
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
47850
diff
changeset
|
98 |
navBar.setUserHeader(getUserHeaderFooter(true)); |
53991 | 99 |
header.addContent(navBar.getContent(true)); |
100 |
body.addContent(header); |
|
101 |
HtmlTree main = HtmlTree.MAIN(); |
|
102 |
main.addContent(HtmlTree.DIV(HtmlStyle.header, |
|
103 |
HtmlTree.HEADING(Headings.PAGE_TITLE_HEADING, |
|
104 |
contents.getContent("doclet.Index")))); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
105 |
HtmlTree divTree = new HtmlTree(HtmlTag.DIV); |
47846 | 106 |
divTree.setStyle(HtmlStyle.contentContainer); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
107 |
elements = new TreeSet<>(indexbuilder.getIndexMap().keySet()); |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
108 |
elements.addAll(configuration.tagSearchIndexKeys); |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
109 |
addLinksForIndexes(divTree); |
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
33920
diff
changeset
|
110 |
for (Character unicode : elements) { |
33920 | 111 |
if (configuration.tagSearchIndexMap.get(unicode) == null) { |
112 |
addContents(unicode, indexbuilder.getMemberList(unicode), divTree); |
|
113 |
} else if (indexbuilder.getMemberList(unicode) == null) { |
|
114 |
addSearchContents(unicode, configuration.tagSearchIndexMap.get(unicode), divTree); |
|
115 |
} else { |
|
116 |
addContents(unicode, indexbuilder.getMemberList(unicode), |
|
117 |
configuration.tagSearchIndexMap.get(unicode), divTree); |
|
118 |
} |
|
10 | 119 |
} |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
120 |
addLinksForIndexes(divTree); |
53991 | 121 |
main.addContent(divTree); |
122 |
body.addContent(main); |
|
123 |
HtmlTree footer = HtmlTree.FOOTER(); |
|
49551
0d4786e42471
8196200: Implement a navigation builder in javadoc
bpatel
parents:
47850
diff
changeset
|
124 |
navBar.setUserFooter(getUserHeaderFooter(false)); |
53991 | 125 |
footer.addContent(navBar.getContent(false)); |
126 |
addBottom(footer); |
|
127 |
body.addContent(footer); |
|
33920 | 128 |
createSearchIndexFiles(); |
53880
3f1e9372557f
8219497: Unused parameter in HtmlDocletWriter::printHtmlDocument
jjg
parents:
53863
diff
changeset
|
129 |
printHtmlDocument(null, "index", body); |
10 | 130 |
} |
131 |
||
132 |
/** |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
133 |
* 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
|
134 |
* |
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
135 |
* @param contentTree the content tree to which the links for indexes will be added |
10 | 136 |
*/ |
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
137 |
protected void addLinksForIndexes(Content contentTree) { |
33920 | 138 |
for (Object ch : elements) { |
139 |
String unicode = ch.toString(); |
|
7614
cfadc977ca75
6851834: Javadoc doclet needs a structured approach to generate the output HTML.
bpatel
parents:
5520
diff
changeset
|
140 |
contentTree.addContent( |
47850 | 141 |
links.createLink(getNameForIndex(unicode), |
33920 | 142 |
new StringContent(unicode))); |
40303 | 143 |
contentTree.addContent(Contents.SPACE); |
10 | 144 |
} |
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
145 |
contentTree.addContent(new HtmlTree(HtmlTag.BR)); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
146 |
contentTree.addContent(links.createLink(DocPaths.ALLCLASSES_INDEX, |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
147 |
contents.allClassesLabel)); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
148 |
if (!configuration.packages.isEmpty()) { |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
149 |
contentTree.addContent(Contents.SPACE); |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
150 |
contentTree.addContent(links.createLink(DocPaths.ALLPACKAGES_INDEX, |
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
151 |
contents.allPackagesLabel)); |
10 | 152 |
} |
153 |
} |
|
50167
cc705c956798
8196201: Generate pages to list all classes and all packages in javadoc output
bpatel
parents:
49551
diff
changeset
|
154 |
} |