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