author | jjg |
Tue, 09 Oct 2012 19:10:00 -0700 | |
changeset 14258 | 8d2148961366 |
parent 14061 | 9ac68cf0048b |
child 14260 | 727a84636f12 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
2 |
* Copyright (c) 1997, 2012, 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.internal.toolkit; |
|
27 |
||
14258 | 28 |
import java.io.*; |
29 |
import java.util.*; |
|
30 |
||
31 |
import com.sun.javadoc.*; |
|
32 |
import com.sun.tools.doclets.internal.toolkit.builders.BuilderFactory; |
|
10 | 33 |
import com.sun.tools.doclets.internal.toolkit.taglets.*; |
34 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
35 |
||
36 |
/** |
|
37 |
* Configure the output based on the options. Doclets should sub-class |
|
38 |
* Configuration, to configure and add their own options. This class contains |
|
39 |
* all user options which are supported by the 1.1 doclet and the standard |
|
40 |
* doclet. |
|
41 |
* |
|
42 |
* This code is not part of an API. |
|
43 |
* It is implementation that is subject to change. |
|
44 |
* Do not use it as an API |
|
45 |
* |
|
46 |
* @author Robert Field. |
|
47 |
* @author Atul Dambalkar. |
|
48 |
* @author Jamie Ho |
|
49 |
*/ |
|
50 |
public abstract class Configuration { |
|
51 |
||
52 |
/** |
|
53 |
* The factory for builders. |
|
54 |
*/ |
|
55 |
protected BuilderFactory builderFactory; |
|
56 |
||
57 |
/** |
|
58 |
* The taglet manager. |
|
59 |
*/ |
|
60 |
public TagletManager tagletManager; |
|
61 |
||
62 |
/** |
|
63 |
* The path to the builder XML input file. |
|
64 |
*/ |
|
65 |
public String builderXMLPath; |
|
66 |
||
67 |
/** |
|
68 |
* The default path to the builder XML. |
|
69 |
*/ |
|
70 |
private static final String DEFAULT_BUILDER_XML = "resources/doclet.xml"; |
|
71 |
||
72 |
/** |
|
73 |
* The path to Taglets |
|
74 |
*/ |
|
75 |
public String tagletpath = ""; |
|
76 |
||
77 |
/** |
|
78 |
* This is true if option "-serialwarn" is used. Defualt value is false to |
|
79 |
* supress excessive warnings about serial tag. |
|
80 |
*/ |
|
81 |
public boolean serialwarn = false; |
|
82 |
||
83 |
/** |
|
84 |
* The specified amount of space between tab stops. |
|
85 |
*/ |
|
86 |
public int sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH; |
|
87 |
||
88 |
/** |
|
89 |
* True if we should generate browsable sources. |
|
90 |
*/ |
|
91 |
public boolean linksource = false; |
|
92 |
||
93 |
/** |
|
94 |
* True if command line option "-nosince" is used. Default value is |
|
95 |
* false. |
|
96 |
*/ |
|
97 |
public boolean nosince = false; |
|
98 |
||
99 |
/** |
|
100 |
* True if we should recursively copy the doc-file subdirectories |
|
101 |
*/ |
|
102 |
public boolean copydocfilesubdirs = false; |
|
103 |
||
104 |
/** |
|
105 |
* The META charset tag used for cross-platform viewing. |
|
106 |
*/ |
|
107 |
public String charset = ""; |
|
108 |
||
109 |
/** |
|
110 |
* True if user wants to add member names as meta keywords. |
|
111 |
* Set to false because meta keywords are ignored in general |
|
112 |
* by most Internet search engines. |
|
113 |
*/ |
|
114 |
public boolean keywords = false; |
|
115 |
||
116 |
/** |
|
1475 | 117 |
* The meta tag keywords instance. |
10 | 118 |
*/ |
1475 | 119 |
public final MetaKeywords metakeywords = new MetaKeywords(this); |
10 | 120 |
|
121 |
/** |
|
122 |
* The list of doc-file subdirectories to exclude |
|
123 |
*/ |
|
868 | 124 |
protected Set<String> excludedDocFileDirs; |
10 | 125 |
|
126 |
/** |
|
127 |
* The list of qualifiers to exclude |
|
128 |
*/ |
|
868 | 129 |
protected Set<String> excludedQualifiers; |
10 | 130 |
|
131 |
/** |
|
132 |
* The Root of the generated Program Structure from the Doclet API. |
|
133 |
*/ |
|
134 |
public RootDoc root; |
|
135 |
||
136 |
/** |
|
137 |
* Destination directory name, in which doclet will generate the entire |
|
138 |
* documentation. Default is current directory. |
|
139 |
*/ |
|
140 |
public String destDirName = ""; |
|
141 |
||
142 |
/** |
|
143 |
* Destination directory name, in which doclet will copy the doc-files to. |
|
144 |
*/ |
|
145 |
public String docFileDestDirName = ""; |
|
146 |
||
147 |
/** |
|
148 |
* Encoding for this document. Default is default encoding for this |
|
149 |
* platform. |
|
150 |
*/ |
|
151 |
public String docencoding = null; |
|
152 |
||
153 |
/** |
|
154 |
* True if user wants to suppress descriptions and tags. |
|
155 |
*/ |
|
156 |
public boolean nocomment = false; |
|
157 |
||
158 |
/** |
|
159 |
* Encoding for this document. Default is default encoding for this |
|
160 |
* platform. |
|
161 |
*/ |
|
162 |
public String encoding = null; |
|
163 |
||
164 |
/** |
|
165 |
* Generate author specific information for all the classes if @author |
|
166 |
* tag is used in the doc comment and if -author option is used. |
|
167 |
* <code>showauthor</code> is set to true if -author option is used. |
|
168 |
* Default is don't show author information. |
|
169 |
*/ |
|
170 |
public boolean showauthor = false; |
|
171 |
||
172 |
/** |
|
173 |
* Generate version specific information for the all the classes |
|
174 |
* if @version tag is used in the doc comment and if -version option is |
|
175 |
* used. <code>showversion</code> is set to true if -version option is |
|
176 |
* used.Default is don't show version information. |
|
177 |
*/ |
|
178 |
public boolean showversion = false; |
|
179 |
||
180 |
/** |
|
181 |
* Sourcepath from where to read the source files. Default is classpath. |
|
182 |
* |
|
183 |
*/ |
|
184 |
public String sourcepath = ""; |
|
185 |
||
186 |
/** |
|
187 |
* Don't generate deprecated API information at all, if -nodeprecated |
|
188 |
* option is used. <code>nodepracted</code> is set to true if |
|
189 |
* -nodeprecated option is used. Default is generate deprected API |
|
190 |
* information. |
|
191 |
*/ |
|
192 |
public boolean nodeprecated = false; |
|
193 |
||
194 |
/** |
|
195 |
* The catalog of classes specified on the command-line |
|
196 |
*/ |
|
197 |
public ClassDocCatalog classDocCatalog; |
|
198 |
||
199 |
/** |
|
200 |
* Message Retriever for the doclet, to retrieve message from the resource |
|
201 |
* file for this Configuration, which is common for 1.1 and standard |
|
202 |
* doclets. |
|
203 |
* |
|
204 |
* TODO: Make this private!!! |
|
205 |
*/ |
|
206 |
public MessageRetriever message = null; |
|
207 |
||
208 |
/** |
|
209 |
* True if user wants to suppress time stamp in output. |
|
210 |
* Default is false. |
|
211 |
*/ |
|
212 |
public boolean notimestamp= false; |
|
213 |
||
214 |
/** |
|
1475 | 215 |
* The package grouping instance. |
10 | 216 |
*/ |
1475 | 217 |
public final Group group = new Group(this); |
10 | 218 |
|
219 |
/** |
|
1475 | 220 |
* The tracker of external package links. |
10 | 221 |
*/ |
222 |
public final Extern extern = new Extern(this); |
|
223 |
||
224 |
/** |
|
225 |
* Return the build date for the doclet. |
|
226 |
*/ |
|
227 |
public abstract String getDocletSpecificBuildDate(); |
|
228 |
||
229 |
/** |
|
230 |
* This method should be defined in all those doclets(configurations), |
|
231 |
* which want to derive themselves from this Configuration. This method |
|
232 |
* can be used to set its own command line options. |
|
233 |
* |
|
234 |
* @param options The array of option names and values. |
|
235 |
* @throws DocletAbortException |
|
236 |
*/ |
|
237 |
public abstract void setSpecificDocletOptions(String[][] options); |
|
238 |
||
239 |
/** |
|
240 |
* Return the doclet specific {@link MessageRetriever} |
|
241 |
* @return the doclet specific MessageRetriever. |
|
242 |
*/ |
|
243 |
public abstract MessageRetriever getDocletSpecificMsg(); |
|
244 |
||
245 |
/** |
|
246 |
* An array of the packages specified on the command-line merged |
|
247 |
* with the array of packages that contain the classes specified on the |
|
248 |
* command-line. The array is sorted. |
|
249 |
*/ |
|
250 |
public PackageDoc[] packages; |
|
251 |
||
252 |
/** |
|
253 |
* Constructor. Constructs the message retriever with resource file. |
|
254 |
*/ |
|
255 |
public Configuration() { |
|
256 |
message = |
|
257 |
new MessageRetriever(this, |
|
258 |
"com.sun.tools.doclets.internal.toolkit.resources.doclets"); |
|
868 | 259 |
excludedDocFileDirs = new HashSet<String>(); |
260 |
excludedQualifiers = new HashSet<String>(); |
|
10 | 261 |
} |
262 |
||
263 |
/** |
|
264 |
* Return the builder factory for this doclet. |
|
265 |
* |
|
266 |
* @return the builder factory for this doclet. |
|
267 |
*/ |
|
268 |
public BuilderFactory getBuilderFactory() { |
|
269 |
if (builderFactory == null) { |
|
270 |
builderFactory = new BuilderFactory(this); |
|
271 |
} |
|
272 |
return builderFactory; |
|
273 |
} |
|
274 |
||
275 |
/** |
|
276 |
* This method should be defined in all those doclets |
|
277 |
* which want to inherit from this Configuration. This method |
|
278 |
* should return the number of arguments to the command line |
|
279 |
* option (including the option name). For example, |
|
280 |
* -notimestamp is a single-argument option, so this method would |
|
281 |
* return 1. |
|
282 |
* |
|
283 |
* @param option Command line option under consideration. |
|
284 |
* @return number of arguments to option (including the |
|
285 |
* option name). Zero return means option not known. |
|
286 |
* Negative value means error occurred. |
|
287 |
*/ |
|
288 |
public int optionLength(String option) { |
|
289 |
option = option.toLowerCase(); |
|
290 |
if (option.equals("-author") || |
|
291 |
option.equals("-docfilessubdirs") || |
|
292 |
option.equals("-keywords") || |
|
293 |
option.equals("-linksource") || |
|
294 |
option.equals("-nocomment") || |
|
295 |
option.equals("-nodeprecated") || |
|
296 |
option.equals("-nosince") || |
|
297 |
option.equals("-notimestamp") || |
|
298 |
option.equals("-quiet") || |
|
299 |
option.equals("-xnodate") || |
|
300 |
option.equals("-version")) { |
|
301 |
return 1; |
|
302 |
} else if (option.equals("-d") || |
|
303 |
option.equals("-docencoding") || |
|
304 |
option.equals("-encoding") || |
|
305 |
option.equals("-excludedocfilessubdir") || |
|
306 |
option.equals("-link") || |
|
307 |
option.equals("-sourcetab") || |
|
308 |
option.equals("-noqualifier") || |
|
309 |
option.equals("-output") || |
|
310 |
option.equals("-sourcepath") || |
|
311 |
option.equals("-tag") || |
|
312 |
option.equals("-taglet") || |
|
313 |
option.equals("-tagletpath")) { |
|
314 |
return 2; |
|
315 |
} else if (option.equals("-group") || |
|
316 |
option.equals("-linkoffline")) { |
|
317 |
return 3; |
|
318 |
} else { |
|
319 |
return -1; // indicate we don't know about it |
|
320 |
} |
|
321 |
} |
|
322 |
||
323 |
/** |
|
324 |
* Perform error checking on the given options. |
|
325 |
* |
|
326 |
* @param options the given options to check. |
|
327 |
* @param reporter the reporter used to report errors. |
|
328 |
*/ |
|
329 |
public abstract boolean validOptions(String options[][], |
|
330 |
DocErrorReporter reporter); |
|
331 |
||
332 |
private void initPackageArray() { |
|
868 | 333 |
Set<PackageDoc> set = new HashSet<PackageDoc>(Arrays.asList(root.specifiedPackages())); |
10 | 334 |
ClassDoc[] classes = root.specifiedClasses(); |
335 |
for (int i = 0; i < classes.length; i++) { |
|
336 |
set.add(classes[i].containingPackage()); |
|
337 |
} |
|
868 | 338 |
ArrayList<PackageDoc> results = new ArrayList<PackageDoc>(set); |
10 | 339 |
Collections.sort(results); |
868 | 340 |
packages = results.toArray(new PackageDoc[] {}); |
10 | 341 |
} |
342 |
||
343 |
/** |
|
344 |
* Set the command line options supported by this configuration. |
|
345 |
* |
|
346 |
* @param options the two dimensional array of options. |
|
347 |
*/ |
|
348 |
public void setOptions(String[][] options) { |
|
868 | 349 |
LinkedHashSet<String[]> customTagStrs = new LinkedHashSet<String[]>(); |
10 | 350 |
for (int oi = 0; oi < options.length; ++oi) { |
351 |
String[] os = options[oi]; |
|
352 |
String opt = os[0].toLowerCase(); |
|
353 |
if (opt.equals("-d")) { |
|
354 |
destDirName = addTrailingFileSep(os[1]); |
|
355 |
docFileDestDirName = destDirName; |
|
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
356 |
} else if (opt.equals("-docfilessubdirs")) { |
10 | 357 |
copydocfilesubdirs = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
358 |
} else if (opt.equals("-docencoding")) { |
10 | 359 |
docencoding = os[1]; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
360 |
} else if (opt.equals("-encoding")) { |
10 | 361 |
encoding = os[1]; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
362 |
} else if (opt.equals("-author")) { |
10 | 363 |
showauthor = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
364 |
} else if (opt.equals("-nosince")) { |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
365 |
nosince = true; |
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
366 |
} else if (opt.equals("-version")) { |
10 | 367 |
showversion = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
368 |
} else if (opt.equals("-nodeprecated")) { |
10 | 369 |
nodeprecated = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
370 |
} else if (opt.equals("-sourcepath")) { |
10 | 371 |
sourcepath = os[1]; |
372 |
} else if (opt.equals("-classpath") && |
|
373 |
sourcepath.length() == 0) { |
|
374 |
sourcepath = os[1]; |
|
375 |
} else if (opt.equals("-excludedocfilessubdir")) { |
|
376 |
addToSet(excludedDocFileDirs, os[1]); |
|
377 |
} else if (opt.equals("-noqualifier")) { |
|
378 |
addToSet(excludedQualifiers, os[1]); |
|
379 |
} else if (opt.equals("-linksource")) { |
|
380 |
linksource = true; |
|
381 |
} else if (opt.equals("-sourcetab")) { |
|
382 |
linksource = true; |
|
383 |
try { |
|
384 |
sourcetab = Integer.parseInt(os[1]); |
|
385 |
} catch (NumberFormatException e) { |
|
386 |
//Set to -1 so that warning will be printed |
|
387 |
//to indicate what is valid argument. |
|
388 |
sourcetab = -1; |
|
389 |
} |
|
390 |
if (sourcetab <= 0) { |
|
391 |
message.warning("doclet.sourcetab_warning"); |
|
392 |
sourcetab = DocletConstants.DEFAULT_TAB_STOP_LENGTH; |
|
393 |
} |
|
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
394 |
} else if (opt.equals("-notimestamp")) { |
10 | 395 |
notimestamp = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
396 |
} else if (opt.equals("-nocomment")) { |
10 | 397 |
nocomment = true; |
398 |
} else if (opt.equals("-tag") || opt.equals("-taglet")) { |
|
399 |
customTagStrs.add(os); |
|
400 |
} else if (opt.equals("-tagletpath")) { |
|
401 |
tagletpath = os[1]; |
|
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
402 |
} else if (opt.equals("-keywords")) { |
10 | 403 |
keywords = true; |
13842
6908f6badce4
7180906: Javadoc tool does not apply parameter -nosince
bpatel
parents:
9606
diff
changeset
|
404 |
} else if (opt.equals("-serialwarn")) { |
10 | 405 |
serialwarn = true; |
406 |
} else if (opt.equals("-group")) { |
|
407 |
group.checkPackageGroups(os[1], os[2]); |
|
408 |
} else if (opt.equals("-link")) { |
|
409 |
String url = os[1]; |
|
410 |
extern.url(url, url, root, false); |
|
411 |
} else if (opt.equals("-linkoffline")) { |
|
412 |
String url = os[1]; |
|
413 |
String pkglisturl = os[2]; |
|
414 |
extern.url(url, pkglisturl, root, true); |
|
415 |
} |
|
416 |
} |
|
417 |
if (sourcepath.length() == 0) { |
|
418 |
sourcepath = System.getProperty("env.class.path") == null ? "" : |
|
419 |
System.getProperty("env.class.path"); |
|
420 |
} |
|
421 |
if (docencoding == null) { |
|
422 |
docencoding = encoding; |
|
423 |
} |
|
424 |
||
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
425 |
classDocCatalog = new ClassDocCatalog(root.specifiedClasses(), this); |
10 | 426 |
initTagletManager(customTagStrs); |
427 |
} |
|
428 |
||
429 |
/** |
|
430 |
* Set the command line options supported by this configuration. |
|
431 |
* |
|
432 |
* @throws DocletAbortException |
|
433 |
*/ |
|
434 |
public void setOptions() { |
|
435 |
initPackageArray(); |
|
436 |
setOptions(root.options()); |
|
437 |
setSpecificDocletOptions(root.options()); |
|
438 |
} |
|
439 |
||
440 |
||
441 |
/** |
|
442 |
* Initialize the taglet manager. The strings to initialize the simple custom tags should |
|
443 |
* be in the following format: "[tag name]:[location str]:[heading]". |
|
444 |
* @param customTagStrs the set two dimentional arrays of strings. These arrays contain |
|
445 |
* either -tag or -taglet arguments. |
|
446 |
*/ |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1475
diff
changeset
|
447 |
private void initTagletManager(Set<String[]> customTagStrs) { |
10 | 448 |
tagletManager = tagletManager == null ? |
449 |
new TagletManager(nosince, showversion, showauthor, message) : |
|
450 |
tagletManager; |
|
451 |
String[] args; |
|
1789
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1475
diff
changeset
|
452 |
for (Iterator<String[]> it = customTagStrs.iterator(); it.hasNext(); ) { |
7ac8c0815000
6765045: Remove rawtypes warnings from langtools
mcimadamore
parents:
1475
diff
changeset
|
453 |
args = it.next(); |
10 | 454 |
if (args[0].equals("-taglet")) { |
455 |
tagletManager.addCustomTag(args[1], tagletpath); |
|
456 |
continue; |
|
457 |
} |
|
458 |
String[] tokens = Util.tokenize(args[1], |
|
459 |
TagletManager.SIMPLE_TAGLET_OPT_SEPERATOR, 3); |
|
460 |
if (tokens.length == 1) { |
|
461 |
String tagName = args[1]; |
|
462 |
if (tagletManager.isKnownCustomTag(tagName)) { |
|
463 |
//reorder a standard tag |
|
464 |
tagletManager.addNewSimpleCustomTag(tagName, null, ""); |
|
465 |
} else { |
|
466 |
//Create a simple tag with the heading that has the same name as the tag. |
|
467 |
StringBuffer heading = new StringBuffer(tagName + ":"); |
|
468 |
heading.setCharAt(0, Character.toUpperCase(tagName.charAt(0))); |
|
469 |
tagletManager.addNewSimpleCustomTag(tagName, heading.toString(), "a"); |
|
470 |
} |
|
471 |
} else if (tokens.length == 2) { |
|
472 |
//Add simple taglet without heading, probably to excluding it in the output. |
|
473 |
tagletManager.addNewSimpleCustomTag(tokens[0], tokens[1], ""); |
|
474 |
} else if (tokens.length >= 3) { |
|
475 |
tagletManager.addNewSimpleCustomTag(tokens[0], tokens[2], tokens[1]); |
|
476 |
} else { |
|
477 |
message.error("doclet.Error_invalid_custom_tag_argument", args[1]); |
|
478 |
} |
|
479 |
} |
|
480 |
} |
|
481 |
||
868 | 482 |
private void addToSet(Set<String> s, String str){ |
10 | 483 |
StringTokenizer st = new StringTokenizer(str, ":"); |
484 |
String current; |
|
485 |
while(st.hasMoreTokens()){ |
|
486 |
current = st.nextToken(); |
|
487 |
s.add(current); |
|
488 |
} |
|
489 |
} |
|
490 |
||
491 |
/** |
|
14061
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
492 |
* Add a trailing file separator, if not found. Remove superfluous |
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
493 |
* file separators if any. Preserve the front double file separator for |
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
494 |
* UNC paths. |
10 | 495 |
* |
496 |
* @param path Path under consideration. |
|
497 |
* @return String Properly constructed path string. |
|
498 |
*/ |
|
14061
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
499 |
public static String addTrailingFileSep(String path) { |
10 | 500 |
String fs = System.getProperty("file.separator"); |
501 |
String dblfs = fs + fs; |
|
502 |
int indexDblfs; |
|
14061
9ac68cf0048b
4696488: javadoc doesn't handle UNC paths for destination directory
bpatel
parents:
13842
diff
changeset
|
503 |
while ((indexDblfs = path.indexOf(dblfs, 1)) >= 0) { |
10 | 504 |
path = path.substring(0, indexDblfs) + |
505 |
path.substring(indexDblfs + fs.length()); |
|
506 |
} |
|
507 |
if (!path.endsWith(fs)) |
|
508 |
path += fs; |
|
509 |
return path; |
|
510 |
} |
|
511 |
||
512 |
/** |
|
513 |
* This checks for the validity of the options used by the user. |
|
514 |
* This works exactly like |
|
515 |
* {@link com.sun.javadoc.Doclet#validOptions(String[][], |
|
516 |
* DocErrorReporter)}. This will validate the options which are shared |
|
517 |
* by our doclets. For example, this method will flag an error using |
|
518 |
* the DocErrorReporter if user has used "-nohelp" and "-helpfile" option |
|
519 |
* together. |
|
520 |
* |
|
521 |
* @param options options used on the command line. |
|
522 |
* @param reporter used to report errors. |
|
523 |
* @return true if all the options are valid. |
|
524 |
*/ |
|
525 |
public boolean generalValidOptions(String options[][], |
|
526 |
DocErrorReporter reporter) { |
|
527 |
boolean docencodingfound = false; |
|
528 |
String encoding = ""; |
|
529 |
for (int oi = 0; oi < options.length; oi++) { |
|
530 |
String[] os = options[oi]; |
|
531 |
String opt = os[0].toLowerCase(); |
|
532 |
if (opt.equals("-d")) { |
|
533 |
String destdirname = addTrailingFileSep(os[1]); |
|
534 |
File destDir = new File(destdirname); |
|
535 |
if (!destDir.exists()) { |
|
536 |
//Create the output directory (in case it doesn't exist yet) |
|
537 |
reporter.printNotice(getText("doclet.dest_dir_create", |
|
538 |
destdirname)); |
|
539 |
(new File(destdirname)).mkdirs(); |
|
540 |
} else if (!destDir.isDirectory()) { |
|
541 |
reporter.printError(getText( |
|
542 |
"doclet.destination_directory_not_directory_0", |
|
543 |
destDir.getPath())); |
|
544 |
return false; |
|
545 |
} else if (!destDir.canWrite()) { |
|
546 |
reporter.printError(getText( |
|
547 |
"doclet.destination_directory_not_writable_0", |
|
548 |
destDir.getPath())); |
|
549 |
return false; |
|
550 |
} |
|
551 |
} else if (opt.equals("-docencoding")) { |
|
552 |
docencodingfound = true; |
|
553 |
if (!checkOutputFileEncoding(os[1], reporter)) { |
|
554 |
return false; |
|
555 |
} |
|
556 |
} else if (opt.equals("-encoding")) { |
|
557 |
encoding = os[1]; |
|
558 |
} |
|
559 |
} |
|
560 |
if (!docencodingfound && encoding.length() > 0) { |
|
561 |
if (!checkOutputFileEncoding(encoding, reporter)) { |
|
562 |
return false; |
|
563 |
} |
|
564 |
} |
|
565 |
return true; |
|
566 |
} |
|
567 |
||
568 |
/** |
|
569 |
* Check the validity of the given Source or Output File encoding on this |
|
570 |
* platform. |
|
571 |
* |
|
572 |
* @param docencoding output file encoding. |
|
573 |
* @param reporter used to report errors. |
|
574 |
*/ |
|
575 |
private boolean checkOutputFileEncoding(String docencoding, |
|
576 |
DocErrorReporter reporter) { |
|
577 |
OutputStream ost= new ByteArrayOutputStream(); |
|
578 |
OutputStreamWriter osw = null; |
|
579 |
try { |
|
580 |
osw = new OutputStreamWriter(ost, docencoding); |
|
581 |
} catch (UnsupportedEncodingException exc) { |
|
582 |
reporter.printError(getText("doclet.Encoding_not_supported", |
|
583 |
docencoding)); |
|
584 |
return false; |
|
585 |
} finally { |
|
586 |
try { |
|
587 |
if (osw != null) { |
|
588 |
osw.close(); |
|
589 |
} |
|
590 |
} catch (IOException exc) { |
|
591 |
} |
|
592 |
} |
|
593 |
return true; |
|
594 |
} |
|
595 |
||
596 |
/** |
|
597 |
* Return true if the given doc-file subdirectory should be excluded and |
|
598 |
* false otherwise. |
|
599 |
* @param docfilesubdir the doc-files subdirectory to check. |
|
600 |
*/ |
|
601 |
public boolean shouldExcludeDocFileDir(String docfilesubdir){ |
|
602 |
if (excludedDocFileDirs.contains(docfilesubdir)) { |
|
603 |
return true; |
|
604 |
} else { |
|
605 |
return false; |
|
606 |
} |
|
607 |
} |
|
608 |
||
609 |
/** |
|
610 |
* Return true if the given qualifier should be excluded and false otherwise. |
|
611 |
* @param qualifier the qualifier to check. |
|
612 |
*/ |
|
613 |
public boolean shouldExcludeQualifier(String qualifier){ |
|
614 |
if (excludedQualifiers.contains("all") || |
|
615 |
excludedQualifiers.contains(qualifier) || |
|
616 |
excludedQualifiers.contains(qualifier + ".*")) { |
|
617 |
return true; |
|
618 |
} else { |
|
619 |
int index = -1; |
|
620 |
while ((index = qualifier.indexOf(".", index + 1)) != -1) { |
|
621 |
if (excludedQualifiers.contains(qualifier.substring(0, index + 1) + "*")) { |
|
622 |
return true; |
|
623 |
} |
|
624 |
} |
|
625 |
return false; |
|
626 |
} |
|
627 |
} |
|
628 |
||
629 |
/** |
|
630 |
* Return the qualified name of the <code>ClassDoc</code> if it's qualifier is not excluded. Otherwise, |
|
631 |
* return the unqualified <code>ClassDoc</code> name. |
|
632 |
* @param cd the <code>ClassDoc</code> to check. |
|
633 |
*/ |
|
634 |
public String getClassName(ClassDoc cd) { |
|
635 |
PackageDoc pd = cd.containingPackage(); |
|
636 |
if (pd != null && shouldExcludeQualifier(cd.containingPackage().name())) { |
|
637 |
return cd.name(); |
|
638 |
} else { |
|
639 |
return cd.qualifiedName(); |
|
640 |
} |
|
641 |
} |
|
642 |
||
643 |
public String getText(String key) { |
|
644 |
try { |
|
645 |
//Check the doclet specific properties file. |
|
646 |
return getDocletSpecificMsg().getText(key); |
|
647 |
} catch (Exception e) { |
|
648 |
//Check the shared properties file. |
|
649 |
return message.getText(key); |
|
650 |
} |
|
651 |
} |
|
652 |
||
653 |
public String getText(String key, String a1) { |
|
654 |
try { |
|
655 |
//Check the doclet specific properties file. |
|
656 |
return getDocletSpecificMsg().getText(key, a1); |
|
657 |
} catch (Exception e) { |
|
658 |
//Check the shared properties file. |
|
659 |
return message.getText(key, a1); |
|
660 |
} |
|
661 |
} |
|
662 |
||
663 |
public String getText(String key, String a1, String a2) { |
|
664 |
try { |
|
665 |
//Check the doclet specific properties file. |
|
666 |
return getDocletSpecificMsg().getText(key, a1, a2); |
|
667 |
} catch (Exception e) { |
|
668 |
//Check the shared properties file. |
|
669 |
return message.getText(key, a1, a2); |
|
670 |
} |
|
671 |
} |
|
672 |
||
673 |
public String getText(String key, String a1, String a2, String a3) { |
|
674 |
try { |
|
675 |
//Check the doclet specific properties file. |
|
676 |
return getDocletSpecificMsg().getText(key, a1, a2, a3); |
|
677 |
} catch (Exception e) { |
|
678 |
//Check the shared properties file. |
|
679 |
return message.getText(key, a1, a2, a3); |
|
680 |
} |
|
681 |
} |
|
682 |
||
683 |
/** |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
684 |
* Return true if the ClassDoc element is getting documented, depending upon |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
685 |
* -nodeprecated option and the deprecation information. Return true if |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
686 |
* -nodeprecated is not used. Return false if -nodeprecated is used and if |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
687 |
* either ClassDoc element is deprecated or the containing package is deprecated. |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
688 |
* |
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
689 |
* @param cd the ClassDoc for which the page generation is checked |
10 | 690 |
*/ |
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
691 |
public boolean isGeneratedDoc(ClassDoc cd) { |
10 | 692 |
if (!nodeprecated) { |
693 |
return true; |
|
694 |
} |
|
9606
e5a619cb5dd3
6492694: @deprecated tag doesn't work in package-info files.
bpatel
parents:
5520
diff
changeset
|
695 |
return !(Util.isDeprecated(cd) || Util.isDeprecated(cd.containingPackage())); |
10 | 696 |
} |
697 |
||
698 |
/** |
|
699 |
* Return the doclet specific instance of a writer factory. |
|
700 |
* @return the {@link WriterFactory} for the doclet. |
|
701 |
*/ |
|
702 |
public abstract WriterFactory getWriterFactory(); |
|
703 |
||
704 |
/** |
|
705 |
* Return the input stream to the builder XML. |
|
706 |
* |
|
707 |
* @return the input steam to the builder XML. |
|
708 |
* @throws FileNotFoundException when the given XML file cannot be found. |
|
709 |
*/ |
|
710 |
public InputStream getBuilderXML() throws FileNotFoundException { |
|
711 |
return builderXMLPath == null ? |
|
712 |
Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) : |
|
713 |
new FileInputStream(new File(builderXMLPath)); |
|
714 |
} |
|
715 |
||
716 |
/** |
|
1863
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
717 |
* Return the Locale for this document. |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
718 |
*/ |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
719 |
public abstract Locale getLocale(); |
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
720 |
|
e5de9abc0eb1
6786682: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - HTML tag should have lang attribute
bpatel
parents:
1789
diff
changeset
|
721 |
/** |
10 | 722 |
* Return the comparator that will be used to sort member documentation. |
723 |
* To no do any sorting, return null. |
|
724 |
* |
|
725 |
* @return the {@link java.util.Comparator} used to sort members. |
|
726 |
*/ |
|
868 | 727 |
public abstract Comparator<ProgramElementDoc> getMemberComparator(); |
10 | 728 |
} |