Tue, 03 Dec 2013 14:21:45 -0800
8025416: doclet not substituting {@docRoot} in some cases
Reviewed-by: jjg
duke@1 | 1 | /* |
jjg@1490 | 2 | * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.doclets.formats.html; |
duke@1 | 27 | |
jjg@1357 | 28 | import java.net.*; |
jjg@1357 | 29 | import java.util.*; |
jjg@1357 | 30 | |
jjg@1412 | 31 | import javax.tools.JavaFileManager; |
jjg@1412 | 32 | |
jjg@1357 | 33 | import com.sun.javadoc.*; |
jjg@1740 | 34 | import com.sun.tools.doclets.formats.html.markup.ContentBuilder; |
duke@1 | 35 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 36 | import com.sun.tools.doclets.internal.toolkit.util.*; |
jjg@1490 | 37 | import com.sun.tools.doclint.DocLint; |
jjg@1412 | 38 | import com.sun.tools.javac.file.JavacFileManager; |
jjg@1412 | 39 | import com.sun.tools.javac.util.Context; |
jjg@1490 | 40 | import com.sun.tools.javadoc.RootDocImpl; |
duke@1 | 41 | |
duke@1 | 42 | /** |
duke@1 | 43 | * Configure the output based on the command line options. |
duke@1 | 44 | * <p> |
duke@1 | 45 | * Also determine the length of the command line option. For example, |
duke@1 | 46 | * for a option "-header" there will be a string argument associated, then the |
duke@1 | 47 | * the length of option "-header" is two. But for option "-nohelp" no argument |
duke@1 | 48 | * is needed so it's length is 1. |
duke@1 | 49 | * </p> |
duke@1 | 50 | * <p> |
duke@1 | 51 | * Also do the error checking on the options used. For example it is illegal to |
duke@1 | 52 | * use "-helpfile" option when already "-nohelp" option is used. |
duke@1 | 53 | * </p> |
duke@1 | 54 | * |
jjg@1383 | 55 | * <p><b>This is NOT part of any supported API. |
jjg@1383 | 56 | * If you write code that depends on this, you do so at your own risk. |
jjg@1383 | 57 | * This code and its internal interfaces are subject to change or |
jjg@1383 | 58 | * deletion without notice.</b> |
jjg@1383 | 59 | * |
duke@1 | 60 | * @author Robert Field. |
duke@1 | 61 | * @author Atul Dambalkar. |
duke@1 | 62 | * @author Jamie Ho |
bpatel@997 | 63 | * @author Bhavesh Patel (Modified) |
duke@1 | 64 | */ |
duke@1 | 65 | public class ConfigurationImpl extends Configuration { |
duke@1 | 66 | |
duke@1 | 67 | /** |
duke@1 | 68 | * The build date. Note: For now, we will use |
duke@1 | 69 | * a version number instead of a date. |
duke@1 | 70 | */ |
duke@1 | 71 | public static final String BUILD_DATE = System.getProperty("java.version"); |
duke@1 | 72 | |
duke@1 | 73 | /** |
duke@1 | 74 | * Argument for command line option "-header". |
duke@1 | 75 | */ |
duke@1 | 76 | public String header = ""; |
duke@1 | 77 | |
duke@1 | 78 | /** |
duke@1 | 79 | * Argument for command line option "-packagesheader". |
duke@1 | 80 | */ |
duke@1 | 81 | public String packagesheader = ""; |
duke@1 | 82 | |
duke@1 | 83 | /** |
duke@1 | 84 | * Argument for command line option "-footer". |
duke@1 | 85 | */ |
duke@1 | 86 | public String footer = ""; |
duke@1 | 87 | |
duke@1 | 88 | /** |
duke@1 | 89 | * Argument for command line option "-doctitle". |
duke@1 | 90 | */ |
duke@1 | 91 | public String doctitle = ""; |
duke@1 | 92 | |
duke@1 | 93 | /** |
duke@1 | 94 | * Argument for command line option "-windowtitle". |
duke@1 | 95 | */ |
duke@1 | 96 | public String windowtitle = ""; |
duke@1 | 97 | |
duke@1 | 98 | /** |
duke@1 | 99 | * Argument for command line option "-top". |
duke@1 | 100 | */ |
duke@1 | 101 | public String top = ""; |
duke@1 | 102 | |
duke@1 | 103 | /** |
duke@1 | 104 | * Argument for command line option "-bottom". |
duke@1 | 105 | */ |
duke@1 | 106 | public String bottom = ""; |
duke@1 | 107 | |
duke@1 | 108 | /** |
duke@1 | 109 | * Argument for command line option "-helpfile". |
duke@1 | 110 | */ |
duke@1 | 111 | public String helpfile = ""; |
duke@1 | 112 | |
duke@1 | 113 | /** |
duke@1 | 114 | * Argument for command line option "-stylesheetfile". |
duke@1 | 115 | */ |
duke@1 | 116 | public String stylesheetfile = ""; |
duke@1 | 117 | |
duke@1 | 118 | /** |
bpatel@997 | 119 | * Argument for command line option "-Xdocrootparent". |
bpatel@997 | 120 | */ |
bpatel@997 | 121 | public String docrootparent = ""; |
bpatel@997 | 122 | |
bpatel@997 | 123 | /** |
duke@1 | 124 | * True if command line option "-nohelp" is used. Default value is false. |
duke@1 | 125 | */ |
duke@1 | 126 | public boolean nohelp = false; |
duke@1 | 127 | |
duke@1 | 128 | /** |
duke@1 | 129 | * True if command line option "-splitindex" is used. Default value is |
duke@1 | 130 | * false. |
duke@1 | 131 | */ |
duke@1 | 132 | public boolean splitindex = false; |
duke@1 | 133 | |
duke@1 | 134 | /** |
duke@1 | 135 | * False if command line option "-noindex" is used. Default value is true. |
duke@1 | 136 | */ |
duke@1 | 137 | public boolean createindex = true; |
duke@1 | 138 | |
duke@1 | 139 | /** |
duke@1 | 140 | * True if command line option "-use" is used. Default value is false. |
duke@1 | 141 | */ |
duke@1 | 142 | public boolean classuse = false; |
duke@1 | 143 | |
duke@1 | 144 | /** |
duke@1 | 145 | * False if command line option "-notree" is used. Default value is true. |
duke@1 | 146 | */ |
duke@1 | 147 | public boolean createtree = true; |
duke@1 | 148 | |
duke@1 | 149 | /** |
duke@1 | 150 | * True if command line option "-nodeprecated" is used. Default value is |
duke@1 | 151 | * false. |
duke@1 | 152 | */ |
duke@1 | 153 | public boolean nodeprecatedlist = false; |
duke@1 | 154 | |
duke@1 | 155 | /** |
duke@1 | 156 | * True if command line option "-nonavbar" is used. Default value is false. |
duke@1 | 157 | */ |
duke@1 | 158 | public boolean nonavbar = false; |
duke@1 | 159 | |
duke@1 | 160 | /** |
duke@1 | 161 | * True if command line option "-nooverview" is used. Default value is |
duke@1 | 162 | * false |
duke@1 | 163 | */ |
duke@1 | 164 | private boolean nooverview = false; |
duke@1 | 165 | |
duke@1 | 166 | /** |
duke@1 | 167 | * True if command line option "-overview" is used. Default value is false. |
duke@1 | 168 | */ |
duke@1 | 169 | public boolean overview = false; |
duke@1 | 170 | |
duke@1 | 171 | /** |
duke@1 | 172 | * This is true if option "-overview" is used or option "-overview" is not |
duke@1 | 173 | * used and number of packages is more than one. |
duke@1 | 174 | */ |
duke@1 | 175 | public boolean createoverview = false; |
duke@1 | 176 | |
duke@1 | 177 | /** |
jjg@1490 | 178 | * Collected set of doclint options |
jjg@1490 | 179 | */ |
jjg@1490 | 180 | public Set<String> doclintOpts = new LinkedHashSet<String>(); |
jjg@1490 | 181 | |
jjg@1490 | 182 | /** |
duke@1 | 183 | * Unique Resource Handler for this package. |
duke@1 | 184 | */ |
duke@1 | 185 | public final MessageRetriever standardmessage; |
duke@1 | 186 | |
duke@1 | 187 | /** |
duke@1 | 188 | * First file to appear in the right-hand frame in the generated |
duke@1 | 189 | * documentation. |
duke@1 | 190 | */ |
jjg@1372 | 191 | public DocPath topFile = DocPath.empty; |
duke@1 | 192 | |
duke@1 | 193 | /** |
duke@1 | 194 | * The classdoc for the class file getting generated. |
duke@1 | 195 | */ |
jjg@1410 | 196 | public ClassDoc currentcd = null; // Set this classdoc in the ClassWriter. |
duke@1 | 197 | |
duke@1 | 198 | /** |
jjg@1358 | 199 | * Constructor. Initializes resource for the |
jjg@1358 | 200 | * {@link com.sun.tools.doclets.internal.toolkit.util.MessageRetriever MessageRetriever}. |
duke@1 | 201 | */ |
jjg@1410 | 202 | public ConfigurationImpl() { |
duke@1 | 203 | standardmessage = new MessageRetriever(this, |
duke@1 | 204 | "com.sun.tools.doclets.formats.html.resources.standard"); |
duke@1 | 205 | } |
duke@1 | 206 | |
kizune@2198 | 207 | private final String versionRBName = "com.sun.tools.javadoc.resources.version"; |
kizune@2198 | 208 | private ResourceBundle versionRB; |
kizune@2198 | 209 | |
jjg@140 | 210 | /** |
duke@1 | 211 | * Return the build date for the doclet. |
duke@1 | 212 | */ |
jjg@1412 | 213 | @Override |
duke@1 | 214 | public String getDocletSpecificBuildDate() { |
kizune@2198 | 215 | if (versionRB == null) { |
kizune@2198 | 216 | try { |
kizune@2198 | 217 | versionRB = ResourceBundle.getBundle(versionRBName); |
kizune@2198 | 218 | } catch (MissingResourceException e) { |
kizune@2198 | 219 | return BUILD_DATE; |
kizune@2198 | 220 | } |
kizune@2198 | 221 | } |
kizune@2198 | 222 | |
kizune@2198 | 223 | try { |
kizune@2198 | 224 | return versionRB.getString("release"); |
kizune@2198 | 225 | } catch (MissingResourceException e) { |
kizune@2198 | 226 | return BUILD_DATE; |
kizune@2198 | 227 | } |
duke@1 | 228 | } |
duke@1 | 229 | |
duke@1 | 230 | /** |
duke@1 | 231 | * Depending upon the command line options provided by the user, set |
duke@1 | 232 | * configure the output generation environment. |
duke@1 | 233 | * |
duke@1 | 234 | * @param options The array of option names and values. |
duke@1 | 235 | */ |
jjg@1412 | 236 | @Override |
duke@1 | 237 | public void setSpecificDocletOptions(String[][] options) { |
duke@1 | 238 | for (int oi = 0; oi < options.length; ++oi) { |
duke@1 | 239 | String[] os = options[oi]; |
duke@1 | 240 | String opt = os[0].toLowerCase(); |
duke@1 | 241 | if (opt.equals("-footer")) { |
bpatel@1324 | 242 | footer = os[1]; |
bpatel@1324 | 243 | } else if (opt.equals("-header")) { |
bpatel@1324 | 244 | header = os[1]; |
bpatel@1324 | 245 | } else if (opt.equals("-packagesheader")) { |
bpatel@1324 | 246 | packagesheader = os[1]; |
bpatel@1324 | 247 | } else if (opt.equals("-doctitle")) { |
bpatel@1324 | 248 | doctitle = os[1]; |
bpatel@1324 | 249 | } else if (opt.equals("-windowtitle")) { |
bpatel@1324 | 250 | windowtitle = os[1]; |
bpatel@1324 | 251 | } else if (opt.equals("-top")) { |
bpatel@1324 | 252 | top = os[1]; |
bpatel@1324 | 253 | } else if (opt.equals("-bottom")) { |
bpatel@1324 | 254 | bottom = os[1]; |
bpatel@1324 | 255 | } else if (opt.equals("-helpfile")) { |
bpatel@1324 | 256 | helpfile = os[1]; |
bpatel@1324 | 257 | } else if (opt.equals("-stylesheetfile")) { |
bpatel@1324 | 258 | stylesheetfile = os[1]; |
bpatel@1324 | 259 | } else if (opt.equals("-charset")) { |
bpatel@1324 | 260 | charset = os[1]; |
bpatel@997 | 261 | } else if (opt.equals("-xdocrootparent")) { |
bpatel@997 | 262 | docrootparent = os[1]; |
bpatel@1324 | 263 | } else if (opt.equals("-nohelp")) { |
duke@1 | 264 | nohelp = true; |
bpatel@1324 | 265 | } else if (opt.equals("-splitindex")) { |
duke@1 | 266 | splitindex = true; |
bpatel@1324 | 267 | } else if (opt.equals("-noindex")) { |
duke@1 | 268 | createindex = false; |
bpatel@1324 | 269 | } else if (opt.equals("-use")) { |
duke@1 | 270 | classuse = true; |
bpatel@1324 | 271 | } else if (opt.equals("-notree")) { |
duke@1 | 272 | createtree = false; |
bpatel@1324 | 273 | } else if (opt.equals("-nodeprecatedlist")) { |
duke@1 | 274 | nodeprecatedlist = true; |
bpatel@1324 | 275 | } else if (opt.equals("-nonavbar")) { |
duke@1 | 276 | nonavbar = true; |
bpatel@1324 | 277 | } else if (opt.equals("-nooverview")) { |
duke@1 | 278 | nooverview = true; |
bpatel@1324 | 279 | } else if (opt.equals("-overview")) { |
duke@1 | 280 | overview = true; |
jjg@1490 | 281 | } else if (opt.equals("-xdoclint")) { |
jjg@1490 | 282 | doclintOpts.add(null); |
jjg@1490 | 283 | } else if (opt.startsWith("-xdoclint:")) { |
jjg@1490 | 284 | doclintOpts.add(opt.substring(opt.indexOf(":") + 1)); |
duke@1 | 285 | } |
duke@1 | 286 | } |
duke@1 | 287 | if (root.specifiedClasses().length > 0) { |
jjg@74 | 288 | Map<String,PackageDoc> map = new HashMap<String,PackageDoc>(); |
duke@1 | 289 | PackageDoc pd; |
duke@1 | 290 | ClassDoc[] classes = root.classes(); |
duke@1 | 291 | for (int i = 0; i < classes.length; i++) { |
duke@1 | 292 | pd = classes[i].containingPackage(); |
duke@1 | 293 | if(! map.containsKey(pd.name())) { |
duke@1 | 294 | map.put(pd.name(), pd); |
duke@1 | 295 | } |
duke@1 | 296 | } |
duke@1 | 297 | } |
duke@1 | 298 | setCreateOverview(); |
duke@1 | 299 | setTopFile(root); |
jjg@1490 | 300 | |
jjg@1490 | 301 | if (root instanceof RootDocImpl) { |
bpatel@2169 | 302 | ((RootDocImpl) root).initDocLint(doclintOpts, tagletManager.getCustomTagNames()); |
jjg@1490 | 303 | } |
duke@1 | 304 | } |
duke@1 | 305 | |
duke@1 | 306 | /** |
duke@1 | 307 | * Returns the "length" of a given option. If an option takes no |
duke@1 | 308 | * arguments, its length is one. If it takes one argument, it's |
duke@1 | 309 | * length is two, and so on. This method is called by JavaDoc to |
duke@1 | 310 | * parse the options it does not recognize. It then calls |
duke@1 | 311 | * {@link #validOptions(String[][], DocErrorReporter)} to |
duke@1 | 312 | * validate them. |
duke@1 | 313 | * <b>Note:</b><br> |
duke@1 | 314 | * The options arrive as case-sensitive strings. For options that |
duke@1 | 315 | * are not case-sensitive, use toLowerCase() on the option string |
duke@1 | 316 | * before comparing it. |
duke@1 | 317 | * </blockquote> |
duke@1 | 318 | * |
duke@1 | 319 | * @return number of arguments + 1 for a option. Zero return means |
duke@1 | 320 | * option not known. Negative value means error occurred. |
duke@1 | 321 | */ |
duke@1 | 322 | public int optionLength(String option) { |
duke@1 | 323 | int result = -1; |
duke@1 | 324 | if ((result = super.optionLength(option)) > 0) { |
duke@1 | 325 | return result; |
duke@1 | 326 | } |
duke@1 | 327 | // otherwise look for the options we have added |
duke@1 | 328 | option = option.toLowerCase(); |
duke@1 | 329 | if (option.equals("-nodeprecatedlist") || |
duke@1 | 330 | option.equals("-noindex") || |
duke@1 | 331 | option.equals("-notree") || |
duke@1 | 332 | option.equals("-nohelp") || |
duke@1 | 333 | option.equals("-splitindex") || |
duke@1 | 334 | option.equals("-serialwarn") || |
duke@1 | 335 | option.equals("-use") || |
duke@1 | 336 | option.equals("-nonavbar") || |
jjg@1490 | 337 | option.equals("-nooverview") || |
jjg@1490 | 338 | option.equals("-xdoclint") || |
jjg@1490 | 339 | option.startsWith("-xdoclint:")) { |
duke@1 | 340 | return 1; |
duke@1 | 341 | } else if (option.equals("-help")) { |
jjg@1797 | 342 | // Uugh: first, this should not be hidden inside optionLength, |
jjg@1797 | 343 | // and second, we should not be writing directly to stdout. |
jjg@1797 | 344 | // But we have no access to a DocErrorReporter, which would |
jjg@1797 | 345 | // allow use of reporter.printNotice |
duke@1 | 346 | System.out.println(getText("doclet.usage")); |
duke@1 | 347 | return 1; |
jjg@1797 | 348 | } else if (option.equals("-x")) { |
jjg@1797 | 349 | // Uugh: first, this should not be hidden inside optionLength, |
jjg@1797 | 350 | // and second, we should not be writing directly to stdout. |
jjg@1797 | 351 | // But we have no access to a DocErrorReporter, which would |
jjg@1797 | 352 | // allow use of reporter.printNotice |
jjg@1797 | 353 | System.out.println(getText("doclet.X.usage")); |
jjg@1797 | 354 | return 1; |
duke@1 | 355 | } else if (option.equals("-footer") || |
duke@1 | 356 | option.equals("-header") || |
duke@1 | 357 | option.equals("-packagesheader") || |
duke@1 | 358 | option.equals("-doctitle") || |
duke@1 | 359 | option.equals("-windowtitle") || |
duke@1 | 360 | option.equals("-top") || |
duke@1 | 361 | option.equals("-bottom") || |
duke@1 | 362 | option.equals("-helpfile") || |
duke@1 | 363 | option.equals("-stylesheetfile") || |
duke@1 | 364 | option.equals("-charset") || |
bpatel@997 | 365 | option.equals("-overview") || |
bpatel@997 | 366 | option.equals("-xdocrootparent")) { |
duke@1 | 367 | return 2; |
duke@1 | 368 | } else { |
duke@1 | 369 | return 0; |
duke@1 | 370 | } |
duke@1 | 371 | } |
duke@1 | 372 | |
duke@1 | 373 | /** |
duke@1 | 374 | * {@inheritDoc} |
duke@1 | 375 | */ |
jjg@1412 | 376 | @Override |
duke@1 | 377 | public boolean validOptions(String options[][], |
duke@1 | 378 | DocErrorReporter reporter) { |
duke@1 | 379 | boolean helpfile = false; |
duke@1 | 380 | boolean nohelp = false; |
duke@1 | 381 | boolean overview = false; |
duke@1 | 382 | boolean nooverview = false; |
duke@1 | 383 | boolean splitindex = false; |
duke@1 | 384 | boolean noindex = false; |
duke@1 | 385 | // check shared options |
duke@1 | 386 | if (!generalValidOptions(options, reporter)) { |
duke@1 | 387 | return false; |
duke@1 | 388 | } |
duke@1 | 389 | // otherwise look at our options |
duke@1 | 390 | for (int oi = 0; oi < options.length; ++oi) { |
duke@1 | 391 | String[] os = options[oi]; |
duke@1 | 392 | String opt = os[0].toLowerCase(); |
duke@1 | 393 | if (opt.equals("-helpfile")) { |
duke@1 | 394 | if (nohelp == true) { |
duke@1 | 395 | reporter.printError(getText("doclet.Option_conflict", |
duke@1 | 396 | "-helpfile", "-nohelp")); |
duke@1 | 397 | return false; |
duke@1 | 398 | } |
duke@1 | 399 | if (helpfile == true) { |
duke@1 | 400 | reporter.printError(getText("doclet.Option_reuse", |
duke@1 | 401 | "-helpfile")); |
duke@1 | 402 | return false; |
duke@1 | 403 | } |
jjg@1383 | 404 | DocFile help = DocFile.createFileForInput(this, os[1]); |
duke@1 | 405 | if (!help.exists()) { |
duke@1 | 406 | reporter.printError(getText("doclet.File_not_found", os[1])); |
duke@1 | 407 | return false; |
duke@1 | 408 | } |
duke@1 | 409 | helpfile = true; |
duke@1 | 410 | } else if (opt.equals("-nohelp")) { |
duke@1 | 411 | if (helpfile == true) { |
duke@1 | 412 | reporter.printError(getText("doclet.Option_conflict", |
duke@1 | 413 | "-nohelp", "-helpfile")); |
duke@1 | 414 | return false; |
duke@1 | 415 | } |
duke@1 | 416 | nohelp = true; |
bpatel@997 | 417 | } else if (opt.equals("-xdocrootparent")) { |
bpatel@997 | 418 | try { |
bpatel@997 | 419 | new URL(os[1]); |
bpatel@997 | 420 | } catch (MalformedURLException e) { |
bpatel@997 | 421 | reporter.printError(getText("doclet.MalformedURL", os[1])); |
bpatel@997 | 422 | return false; |
bpatel@997 | 423 | } |
duke@1 | 424 | } else if (opt.equals("-overview")) { |
duke@1 | 425 | if (nooverview == true) { |
duke@1 | 426 | reporter.printError(getText("doclet.Option_conflict", |
duke@1 | 427 | "-overview", "-nooverview")); |
duke@1 | 428 | return false; |
duke@1 | 429 | } |
duke@1 | 430 | if (overview == true) { |
duke@1 | 431 | reporter.printError(getText("doclet.Option_reuse", |
duke@1 | 432 | "-overview")); |
duke@1 | 433 | return false; |
duke@1 | 434 | } |
duke@1 | 435 | overview = true; |
duke@1 | 436 | } else if (opt.equals("-nooverview")) { |
duke@1 | 437 | if (overview == true) { |
duke@1 | 438 | reporter.printError(getText("doclet.Option_conflict", |
duke@1 | 439 | "-nooverview", "-overview")); |
duke@1 | 440 | return false; |
duke@1 | 441 | } |
duke@1 | 442 | nooverview = true; |
duke@1 | 443 | } else if (opt.equals("-splitindex")) { |
duke@1 | 444 | if (noindex == true) { |
duke@1 | 445 | reporter.printError(getText("doclet.Option_conflict", |
duke@1 | 446 | "-splitindex", "-noindex")); |
duke@1 | 447 | return false; |
duke@1 | 448 | } |
duke@1 | 449 | splitindex = true; |
duke@1 | 450 | } else if (opt.equals("-noindex")) { |
duke@1 | 451 | if (splitindex == true) { |
duke@1 | 452 | reporter.printError(getText("doclet.Option_conflict", |
duke@1 | 453 | "-noindex", "-splitindex")); |
duke@1 | 454 | return false; |
duke@1 | 455 | } |
duke@1 | 456 | noindex = true; |
jjg@1490 | 457 | } else if (opt.startsWith("-xdoclint:")) { |
jjg@1490 | 458 | if (opt.contains("/")) { |
jjg@1490 | 459 | reporter.printError(getText("doclet.Option_doclint_no_qualifiers")); |
jjg@1490 | 460 | return false; |
jjg@1490 | 461 | } |
jjg@1490 | 462 | if (!DocLint.isValidOption( |
jjg@1490 | 463 | opt.replace("-xdoclint:", DocLint.XMSGS_CUSTOM_PREFIX))) { |
jjg@1490 | 464 | reporter.printError(getText("doclet.Option_doclint_invalid_arg")); |
jjg@1490 | 465 | return false; |
jjg@1490 | 466 | } |
duke@1 | 467 | } |
duke@1 | 468 | } |
duke@1 | 469 | return true; |
duke@1 | 470 | } |
duke@1 | 471 | |
duke@1 | 472 | /** |
duke@1 | 473 | * {@inheritDoc} |
duke@1 | 474 | */ |
jjg@1412 | 475 | @Override |
duke@1 | 476 | public MessageRetriever getDocletSpecificMsg() { |
duke@1 | 477 | return standardmessage; |
duke@1 | 478 | } |
duke@1 | 479 | |
duke@1 | 480 | /** |
duke@1 | 481 | * Decide the page which will appear first in the right-hand frame. It will |
duke@1 | 482 | * be "overview-summary.html" if "-overview" option is used or no |
duke@1 | 483 | * "-overview" but the number of packages is more than one. It will be |
duke@1 | 484 | * "package-summary.html" of the respective package if there is only one |
duke@1 | 485 | * package to document. It will be a class page(first in the sorted order), |
duke@1 | 486 | * if only classes are provided on the command line. |
duke@1 | 487 | * |
duke@1 | 488 | * @param root Root of the program structure. |
duke@1 | 489 | */ |
duke@1 | 490 | protected void setTopFile(RootDoc root) { |
duke@1 | 491 | if (!checkForDeprecation(root)) { |
duke@1 | 492 | return; |
duke@1 | 493 | } |
duke@1 | 494 | if (createoverview) { |
jjg@1372 | 495 | topFile = DocPaths.OVERVIEW_SUMMARY; |
duke@1 | 496 | } else { |
duke@1 | 497 | if (packages.length == 1 && packages[0].name().equals("")) { |
duke@1 | 498 | if (root.classes().length > 0) { |
duke@1 | 499 | ClassDoc[] classarr = root.classes(); |
duke@1 | 500 | Arrays.sort(classarr); |
duke@1 | 501 | ClassDoc cd = getValidClass(classarr); |
jjg@1372 | 502 | topFile = DocPath.forClass(cd); |
duke@1 | 503 | } |
duke@1 | 504 | } else { |
jjg@1372 | 505 | topFile = DocPath.forPackage(packages[0]).resolve(DocPaths.PACKAGE_SUMMARY); |
duke@1 | 506 | } |
duke@1 | 507 | } |
duke@1 | 508 | } |
duke@1 | 509 | |
duke@1 | 510 | protected ClassDoc getValidClass(ClassDoc[] classarr) { |
duke@1 | 511 | if (!nodeprecated) { |
duke@1 | 512 | return classarr[0]; |
duke@1 | 513 | } |
duke@1 | 514 | for (int i = 0; i < classarr.length; i++) { |
duke@1 | 515 | if (classarr[i].tags("deprecated").length == 0) { |
duke@1 | 516 | return classarr[i]; |
duke@1 | 517 | } |
duke@1 | 518 | } |
duke@1 | 519 | return null; |
duke@1 | 520 | } |
duke@1 | 521 | |
duke@1 | 522 | protected boolean checkForDeprecation(RootDoc root) { |
duke@1 | 523 | ClassDoc[] classarr = root.classes(); |
duke@1 | 524 | for (int i = 0; i < classarr.length; i++) { |
duke@1 | 525 | if (isGeneratedDoc(classarr[i])) { |
duke@1 | 526 | return true; |
duke@1 | 527 | } |
duke@1 | 528 | } |
duke@1 | 529 | return false; |
duke@1 | 530 | } |
duke@1 | 531 | |
duke@1 | 532 | /** |
duke@1 | 533 | * Generate "overview.html" page if option "-overview" is used or number of |
duke@1 | 534 | * packages is more than one. Sets {@link #createoverview} field to true. |
duke@1 | 535 | */ |
duke@1 | 536 | protected void setCreateOverview() { |
duke@1 | 537 | if ((overview || packages.length > 1) && !nooverview) { |
duke@1 | 538 | createoverview = true; |
duke@1 | 539 | } |
duke@1 | 540 | } |
duke@1 | 541 | |
duke@1 | 542 | /** |
duke@1 | 543 | * {@inheritDoc} |
duke@1 | 544 | */ |
jjg@1412 | 545 | @Override |
duke@1 | 546 | public WriterFactory getWriterFactory() { |
jjg@140 | 547 | return new WriterFactoryImpl(this); |
duke@1 | 548 | } |
duke@1 | 549 | |
duke@1 | 550 | /** |
duke@1 | 551 | * {@inheritDoc} |
duke@1 | 552 | */ |
jjg@1412 | 553 | @Override |
jjg@74 | 554 | public Comparator<ProgramElementDoc> getMemberComparator() { |
duke@1 | 555 | return null; |
duke@1 | 556 | } |
bpatel@191 | 557 | |
bpatel@191 | 558 | /** |
bpatel@191 | 559 | * {@inheritDoc} |
bpatel@191 | 560 | */ |
jjg@1412 | 561 | @Override |
bpatel@191 | 562 | public Locale getLocale() { |
jjg@1490 | 563 | if (root instanceof RootDocImpl) |
jjg@1490 | 564 | return ((RootDocImpl)root).getLocale(); |
bpatel@191 | 565 | else |
bpatel@191 | 566 | return Locale.getDefault(); |
bpatel@191 | 567 | } |
jjg@1412 | 568 | |
jjg@1412 | 569 | /** |
jjg@1412 | 570 | * {@inheritDoc} |
jjg@1412 | 571 | */ |
jjg@1412 | 572 | @Override |
jjg@1412 | 573 | public JavaFileManager getFileManager() { |
jjg@1413 | 574 | if (fileManager == null) { |
jjg@1490 | 575 | if (root instanceof RootDocImpl) |
jjg@1490 | 576 | fileManager = ((RootDocImpl) root).getFileManager(); |
jjg@1413 | 577 | else |
jjg@1413 | 578 | fileManager = new JavacFileManager(new Context(), false, null); |
jjg@1413 | 579 | } |
jjg@1413 | 580 | return fileManager; |
jjg@1412 | 581 | } |
jjg@1413 | 582 | |
jjg@1413 | 583 | private JavaFileManager fileManager; |
jjg@1490 | 584 | |
jjg@1490 | 585 | @Override |
jjg@1490 | 586 | public boolean showMessage(SourcePosition pos, String key) { |
jjg@1490 | 587 | if (root instanceof RootDocImpl) { |
jjg@1490 | 588 | return pos == null || ((RootDocImpl) root).showTagMessages(); |
jjg@1490 | 589 | } |
jjg@1490 | 590 | return true; |
jjg@1490 | 591 | } |
jjg@1740 | 592 | |
jjg@1740 | 593 | @Override |
jjg@1747 | 594 | public Content newContent() { |
jjg@1740 | 595 | return new ContentBuilder(); |
jjg@1740 | 596 | } |
duke@1 | 597 | } |