author | jjg |
Mon, 22 Aug 2016 16:32:40 -0700 | |
changeset 40587 | 1c355ea550ed |
parent 40508 | 74ef30d16fb9 |
child 45417 | f7479ee8de69 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
39364
bd6d4a7936b4
8160301: javadoc RootDoclmpl and DocEnv needs to be renamed
ksrini
parents:
35426
diff
changeset
|
2 |
* Copyright (c) 1998, 2016, 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:
25874
diff
changeset
|
26 |
package jdk.javadoc.internal.doclets.toolkit.util; |
10 | 27 |
|
28 |
import java.io.*; |
|
29 |
||
35426
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
30 |
import javax.lang.model.element.PackageElement; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
31 |
|
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
32 |
import jdk.javadoc.doclet.DocletEnvironment; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
33 |
import jdk.javadoc.internal.doclets.toolkit.Configuration; |
374342e56a56
8035473: [javadoc] Revamp the existing Doclet APIs
ksrini
parents:
25874
diff
changeset
|
34 |
|
14258 | 35 |
|
10 | 36 |
/** |
37 |
* Write out the package index. |
|
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> |
10 | 43 |
* |
44 |
* @author Atul M Dambalkar |
|
45 |
*/ |
|
40587 | 46 |
public class PackageListWriter { |
10 | 47 |
|
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
48 |
private final Configuration configuration; |
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
49 |
private final Utils utils; |
40587 | 50 |
private final DocFile file; |
10 | 51 |
|
52 |
/** |
|
53 |
* Constructor. |
|
54 |
* |
|
55 |
* @param configuration the current configuration of the doclet. |
|
56 |
*/ |
|
40587 | 57 |
public PackageListWriter(Configuration configuration) { |
58 |
file = DocFile.createFileForOutput(configuration, DocPaths.PACKAGE_LIST); |
|
10 | 59 |
this.configuration = configuration; |
25454
376a52c9540c
8039028: [javadoc] refactor the usage of Util.java
ksrini
parents:
22163
diff
changeset
|
60 |
this.utils = configuration.utils; |
10 | 61 |
} |
62 |
||
63 |
/** |
|
64 |
* Generate the package index. |
|
65 |
* |
|
66 |
* @param configuration the current configuration of the doclet. |
|
40587 | 67 |
* @throws DocFileIOException if there is a problem writing the output |
10 | 68 |
*/ |
40587 | 69 |
public static void generate(Configuration configuration) throws DocFileIOException { |
70 |
PackageListWriter packgen = new PackageListWriter(configuration); |
|
71 |
packgen.generatePackageListFile(configuration.docEnv); |
|
72 |
} |
|
73 |
||
74 |
protected void generatePackageListFile(DocletEnvironment docEnv) throws DocFileIOException { |
|
75 |
try (BufferedWriter out = new BufferedWriter(file.openWriter())) { |
|
76 |
for (PackageElement pkg : configuration.packages) { |
|
77 |
// if the -nodeprecated option is set and the package is marked as |
|
78 |
// deprecated, do not include it in the packages list. |
|
79 |
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { |
|
80 |
out.write(pkg.toString()); |
|
81 |
out.newLine(); |
|
82 |
} |
|
83 |
} |
|
84 |
} catch (IOException e) { |
|
85 |
throw new DocFileIOException(file, DocFileIOException.Mode.WRITE, e); |
|
10 | 86 |
} |
87 |
} |
|
88 |
} |