1 /* |
1 /* |
2 * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
36 import com.sun.tools.doclets.internal.toolkit.util.*; |
36 import com.sun.tools.doclets.internal.toolkit.util.*; |
37 import com.sun.tools.doclint.DocLint; |
37 import com.sun.tools.doclint.DocLint; |
38 import com.sun.tools.javac.file.JavacFileManager; |
38 import com.sun.tools.javac.file.JavacFileManager; |
39 import com.sun.tools.javac.util.Context; |
39 import com.sun.tools.javac.util.Context; |
40 import com.sun.tools.javac.util.StringUtils; |
40 import com.sun.tools.javac.util.StringUtils; |
|
41 import com.sun.tools.javadoc.JavaScriptScanner; |
41 import com.sun.tools.javadoc.RootDocImpl; |
42 import com.sun.tools.javadoc.RootDocImpl; |
42 |
43 |
43 /** |
44 /** |
44 * Configure the output based on the command line options. |
45 * Configure the output based on the command line options. |
45 * <p> |
46 * <p> |
177 |
178 |
178 /** |
179 /** |
179 * Collected set of doclint options |
180 * Collected set of doclint options |
180 */ |
181 */ |
181 public Set<String> doclintOpts = new LinkedHashSet<String>(); |
182 public Set<String> doclintOpts = new LinkedHashSet<String>(); |
|
183 |
|
184 /** |
|
185 * Whether or not to check for JavaScript in doc comments. |
|
186 */ |
|
187 private boolean allowScriptInComments; |
182 |
188 |
183 /** |
189 /** |
184 * Unique Resource Handler for this package. |
190 * Unique Resource Handler for this package. |
185 */ |
191 */ |
186 public final MessageRetriever standardmessage; |
192 public final MessageRetriever standardmessage; |
281 overview = true; |
287 overview = true; |
282 } else if (opt.equals("-xdoclint")) { |
288 } else if (opt.equals("-xdoclint")) { |
283 doclintOpts.add(null); |
289 doclintOpts.add(null); |
284 } else if (opt.startsWith("-xdoclint:")) { |
290 } else if (opt.startsWith("-xdoclint:")) { |
285 doclintOpts.add(opt.substring(opt.indexOf(":") + 1)); |
291 doclintOpts.add(opt.substring(opt.indexOf(":") + 1)); |
286 } |
292 } else if (opt.equals("--allow-script-in-comments")) { |
287 } |
293 allowScriptInComments = true; |
|
294 } |
|
295 } |
|
296 |
288 if (root.specifiedClasses().length > 0) { |
297 if (root.specifiedClasses().length > 0) { |
289 Map<String,PackageDoc> map = new HashMap<String,PackageDoc>(); |
298 Map<String,PackageDoc> map = new HashMap<String,PackageDoc>(); |
290 PackageDoc pd; |
299 PackageDoc pd; |
291 ClassDoc[] classes = root.classes(); |
300 ClassDoc[] classes = root.classes(); |
292 for (int i = 0; i < classes.length; i++) { |
301 for (int i = 0; i < classes.length; i++) { |
299 setCreateOverview(); |
308 setCreateOverview(); |
300 setTopFile(root); |
309 setTopFile(root); |
301 |
310 |
302 if (root instanceof RootDocImpl) { |
311 if (root instanceof RootDocImpl) { |
303 ((RootDocImpl) root).initDocLint(doclintOpts, tagletManager.getCustomTagNames()); |
312 ((RootDocImpl) root).initDocLint(doclintOpts, tagletManager.getCustomTagNames()); |
304 } |
313 JavaScriptScanner jss = ((RootDocImpl) root).initJavaScriptScanner(isAllowScriptInComments()); |
|
314 if (jss != null) { |
|
315 // In a more object-oriented world, this would be done by methods on the Option objects. |
|
316 // Note that -windowtitle silently removes any and all HTML elements, and so does not need |
|
317 // to be handled here. |
|
318 checkJavaScript(jss, "-header", header); |
|
319 checkJavaScript(jss, "-footer", footer); |
|
320 checkJavaScript(jss, "-top", top); |
|
321 checkJavaScript(jss, "-bottom", bottom); |
|
322 checkJavaScript(jss, "-doctitle", doctitle); |
|
323 checkJavaScript(jss, "-packagesheader", packagesheader); |
|
324 } |
|
325 } |
|
326 } |
|
327 |
|
328 private void checkJavaScript(JavaScriptScanner jss, final String opt, String value) { |
|
329 jss.parse(value, new JavaScriptScanner.Reporter() { |
|
330 public void report() { |
|
331 root.printError(getText("doclet.JavaScript_in_option", opt)); |
|
332 throw new FatalError(); |
|
333 } |
|
334 }); |
305 } |
335 } |
306 |
336 |
307 /** |
337 /** |
308 * Returns the "length" of a given option. If an option takes no |
338 * Returns the "length" of a given option. If an option takes no |
309 * arguments, its length is one. If it takes one argument, it's |
339 * arguments, its length is one. If it takes one argument, it's |
335 option.equals("-serialwarn") || |
365 option.equals("-serialwarn") || |
336 option.equals("-use") || |
366 option.equals("-use") || |
337 option.equals("-nonavbar") || |
367 option.equals("-nonavbar") || |
338 option.equals("-nooverview") || |
368 option.equals("-nooverview") || |
339 option.equals("-xdoclint") || |
369 option.equals("-xdoclint") || |
340 option.startsWith("-xdoclint:")) { |
370 option.startsWith("-xdoclint:") || |
|
371 option.equals("--allow-script-in-comments")) { |
341 return 1; |
372 return 1; |
342 } else if (option.equals("-help")) { |
373 } else if (option.equals("-help")) { |
343 // Uugh: first, this should not be hidden inside optionLength, |
374 // Uugh: first, this should not be hidden inside optionLength, |
344 // and second, we should not be writing directly to stdout. |
375 // and second, we should not be writing directly to stdout. |
345 // But we have no access to a DocErrorReporter, which would |
376 // But we have no access to a DocErrorReporter, which would |