< prev index next >

src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlConfiguration.java

Print this page




 193 
 194     /**
 195      * This is true if option "-overview" is used or option "-overview" is not
 196      * used and number of packages is more than one.
 197      */
 198     public boolean createoverview = false;
 199 
 200     /**
 201      * Specifies whether or not frames should be generated.
 202      * Defaults to true; can be set by --frames; can be set to false by --no-frames; last one wins.
 203      */
 204     public boolean frames = true;
 205 
 206     /**
 207      * This is the HTML version of the generated pages.
 208      * The default value is determined later.
 209      */
 210     public HtmlVersion htmlVersion = null;
 211 
 212     /**






 213      * Collected set of doclint options
 214      */
 215     public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
 216 
 217     public final Resources resources;
 218 
 219     /**
 220      * First file to appear in the right-hand frame in the generated
 221      * documentation.
 222      */
 223     public DocPath topFile = DocPath.empty;
 224 
 225     /**
 226      * The TypeElement for the class file getting generated.
 227      */
 228     public TypeElement currentTypeElement = null;  // Set this TypeElement in the ClassWriter.
 229 
 230     protected List<SearchIndexItem> memberSearchIndex = new ArrayList<>();
 231 
 232     protected List<SearchIndexItem> moduleSearchIndex = new ArrayList<>();
 233 
 234     protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>();
 235 
 236     protected SortedSet<SearchIndexItem> tagSearchIndex = new TreeSet<>(makeSearchTagComparator());
 237 
 238     protected List<SearchIndexItem> typeSearchIndex = new ArrayList<>();
 239 
 240     protected Map<Character,List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>();
 241 
 242     protected Set<Character> tagSearchIndexKeys;
 243 
 244     protected final Contents contents;
 245 
 246     protected final Messages messages;
 247 


 248     /**
 249      * Creates an object to hold the configuration for a doclet.
 250      *
 251      * @param doclet the doclet
 252      */
 253     public HtmlConfiguration(Doclet doclet) {
 254         super(doclet);
 255         resources = new Resources(this,
 256                 BaseConfiguration.sharedResourceBundleName,
 257                 "jdk.javadoc.internal.doclets.formats.html.resources.standard");
 258 
 259         messages = new Messages(this);
 260         contents = new Contents(this);
 261 
 262         String v;
 263         try {
 264             ResourceBundle rb = ResourceBundle.getBundle(versionBundleName, getLocale());
 265             try {
 266                 v = rb.getString("release");
 267             } catch (MissingResourceException e) {


 340 
 341         return true;
 342     }
 343 
 344 
 345     @Override
 346     public boolean finishOptionSettings() {
 347         if (!validateOptions()) {
 348             return false;
 349         }
 350         if (!getSpecifiedTypeElements().isEmpty()) {
 351             Map<String, PackageElement> map = new HashMap<>();
 352             PackageElement pkg;
 353             for (TypeElement aClass : getIncludedTypeElements()) {
 354                 pkg = utils.containingPackage(aClass);
 355                 if (!map.containsKey(utils.getPackageName(pkg))) {
 356                     map.put(utils.getPackageName(pkg), pkg);
 357                 }
 358             }
 359         }

 360         setCreateOverview();
 361         setTopFile(docEnv);
 362         workArounds.initDocLint(doclintOpts.values(), tagletManager.getCustomTagNames(),
 363                 Utils.toLowerCase(htmlVersion.name()));
 364         return true;
 365     }
 366 
 367     /**
 368      * Return true if the generated output is HTML5.
 369      */
 370     public boolean isOutputHtml5() {
 371         return htmlVersion == HtmlVersion.HTML5;
 372     }
 373 
 374     /**
 375      * Return true if the tag is allowed for this specific version of HTML.
 376      */
 377     public boolean allowTag(HtmlTag htmlTag) {
 378         return htmlTag.allowTag(this.htmlVersion);
 379     }


 389     }
 390 
 391     /**
 392      * Decide the page which will appear first in the right-hand frame. It will
 393      * be "overview-summary.html" if "-overview" option is used or no
 394      * "-overview" but the number of packages is more than one. It will be
 395      * "package-summary.html" of the respective package if there is only one
 396      * package to document. It will be a class page(first in the sorted order),
 397      * if only classes are provided on the command line.
 398      *
 399      * @param docEnv the doclet environment
 400      */
 401     protected void setTopFile(DocletEnvironment docEnv) {
 402         if (!checkForDeprecation(docEnv)) {
 403             return;
 404         }
 405         if (createoverview) {
 406             topFile = DocPaths.overviewSummary(frames);
 407         } else {
 408             if (showModules) {
 409                 topFile = DocPath.empty.resolve(DocPaths.moduleSummary(modules.first()));
 410             } else if (packages.size() == 1 && packages.first().isUnnamed()) {
 411                 List<TypeElement> classes = new ArrayList<>(getIncludedTypeElements());
 412                 if (!classes.isEmpty()) {
 413                     TypeElement te = getValidClass(classes);
 414                     topFile = DocPath.forClass(utils, te);
 415                 }
 416             } else if (!packages.isEmpty()) {
 417                 topFile = DocPath.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
 418             }
 419         }
 420     }
 421 
 422     protected TypeElement getValidClass(List<TypeElement> classes) {
 423         if (!nodeprecated) {
 424             return classes.get(0);
 425         }
 426         for (TypeElement te : classes) {
 427             if (!utils.isDeprecated(te)) {
 428                 return te;
 429             }
 430         }
 431         return null;
 432     }
 433 
 434     protected boolean checkForDeprecation(DocletEnvironment docEnv) {
 435         for (TypeElement te : getIncludedTypeElements()) {
 436             if (isGeneratedDoc(te)) {
 437                 return true;


 818                     if (dopt.contains("/")) {
 819                         reporter.print(ERROR, getText("doclet.Option_doclint_no_qualifiers"));
 820                         return false;
 821                     }
 822                     if (!DocLint.isValidOption(dopt)) {
 823                         reporter.print(ERROR, getText("doclet.Option_doclint_invalid_arg"));
 824                         return false;
 825                     }
 826                     return true;
 827                 }
 828             },
 829             new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) {
 830                 @Override
 831                 public boolean process(String opt,  List<String> args) {
 832                     String dopt = opt.replace("-Xdoclint/package:", DocLint.XCHECK_PACKAGE);
 833                     doclintOpts.put(this, dopt);
 834                     if (!DocLint.isValidOption(dopt)) {
 835                         reporter.print(ERROR, getText("doclet.Option_doclint_package_invalid_arg"));
 836                         return false;
 837                     }







 838                     return true;
 839                 }
 840             }
 841         };
 842         Set<Doclet.Option> oset = new TreeSet<>();
 843         oset.addAll(Arrays.asList(options));
 844         oset.addAll(super.getSupportedOptions());
 845         return oset;
 846     }
 847 
 848     @Override
 849     protected boolean finishOptionSettings0() throws DocletException {
 850         if (docencoding == null) {
 851             if (charset == null) {
 852                 docencoding = charset = (encoding == null) ? HtmlConstants.HTML_DEFAULT_CHARSET : encoding;
 853             } else {
 854                 docencoding = charset;
 855             }
 856         } else {
 857             if (charset == null) {


 193 
 194     /**
 195      * This is true if option "-overview" is used or option "-overview" is not
 196      * used and number of packages is more than one.
 197      */
 198     public boolean createoverview = false;
 199 
 200     /**
 201      * Specifies whether or not frames should be generated.
 202      * Defaults to true; can be set by --frames; can be set to false by --no-frames; last one wins.
 203      */
 204     public boolean frames = true;
 205 
 206     /**
 207      * This is the HTML version of the generated pages.
 208      * The default value is determined later.
 209      */
 210     public HtmlVersion htmlVersion = null;
 211 
 212     /**
 213      * Flag to enable/disable use of module directories when generating docs for modules
 214      * Default: on (module directories are enabled).
 215      */
 216     public boolean useModuleDirectories = true;
 217 
 218     /**
 219      * Collected set of doclint options
 220      */
 221     public Map<Doclet.Option, String> doclintOpts = new LinkedHashMap<>();
 222 
 223     public final Resources resources;
 224 
 225     /**
 226      * First file to appear in the right-hand frame in the generated
 227      * documentation.
 228      */
 229     public DocPath topFile = DocPath.empty;
 230 
 231     /**
 232      * The TypeElement for the class file getting generated.
 233      */
 234     public TypeElement currentTypeElement = null;  // Set this TypeElement in the ClassWriter.
 235 
 236     protected List<SearchIndexItem> memberSearchIndex = new ArrayList<>();
 237 
 238     protected List<SearchIndexItem> moduleSearchIndex = new ArrayList<>();
 239 
 240     protected List<SearchIndexItem> packageSearchIndex = new ArrayList<>();
 241 
 242     protected SortedSet<SearchIndexItem> tagSearchIndex = new TreeSet<>(makeSearchTagComparator());
 243 
 244     protected List<SearchIndexItem> typeSearchIndex = new ArrayList<>();
 245 
 246     protected Map<Character,List<SearchIndexItem>> tagSearchIndexMap = new HashMap<>();
 247 
 248     protected Set<Character> tagSearchIndexKeys;
 249 
 250     protected final Contents contents;
 251 
 252     protected final Messages messages;
 253 
 254     protected DocPaths docPaths;
 255 
 256     /**
 257      * Creates an object to hold the configuration for a doclet.
 258      *
 259      * @param doclet the doclet
 260      */
 261     public HtmlConfiguration(Doclet doclet) {
 262         super(doclet);
 263         resources = new Resources(this,
 264                 BaseConfiguration.sharedResourceBundleName,
 265                 "jdk.javadoc.internal.doclets.formats.html.resources.standard");
 266 
 267         messages = new Messages(this);
 268         contents = new Contents(this);
 269 
 270         String v;
 271         try {
 272             ResourceBundle rb = ResourceBundle.getBundle(versionBundleName, getLocale());
 273             try {
 274                 v = rb.getString("release");
 275             } catch (MissingResourceException e) {


 348 
 349         return true;
 350     }
 351 
 352 
 353     @Override
 354     public boolean finishOptionSettings() {
 355         if (!validateOptions()) {
 356             return false;
 357         }
 358         if (!getSpecifiedTypeElements().isEmpty()) {
 359             Map<String, PackageElement> map = new HashMap<>();
 360             PackageElement pkg;
 361             for (TypeElement aClass : getIncludedTypeElements()) {
 362                 pkg = utils.containingPackage(aClass);
 363                 if (!map.containsKey(utils.getPackageName(pkg))) {
 364                     map.put(utils.getPackageName(pkg), pkg);
 365                 }
 366             }
 367         }
 368         docPaths = new DocPaths(utils, useModuleDirectories);
 369         setCreateOverview();
 370         setTopFile(docEnv);
 371         workArounds.initDocLint(doclintOpts.values(), tagletManager.getCustomTagNames(),
 372                 Utils.toLowerCase(htmlVersion.name()));
 373         return true;
 374     }
 375 
 376     /**
 377      * Return true if the generated output is HTML5.
 378      */
 379     public boolean isOutputHtml5() {
 380         return htmlVersion == HtmlVersion.HTML5;
 381     }
 382 
 383     /**
 384      * Return true if the tag is allowed for this specific version of HTML.
 385      */
 386     public boolean allowTag(HtmlTag htmlTag) {
 387         return htmlTag.allowTag(this.htmlVersion);
 388     }


 398     }
 399 
 400     /**
 401      * Decide the page which will appear first in the right-hand frame. It will
 402      * be "overview-summary.html" if "-overview" option is used or no
 403      * "-overview" but the number of packages is more than one. It will be
 404      * "package-summary.html" of the respective package if there is only one
 405      * package to document. It will be a class page(first in the sorted order),
 406      * if only classes are provided on the command line.
 407      *
 408      * @param docEnv the doclet environment
 409      */
 410     protected void setTopFile(DocletEnvironment docEnv) {
 411         if (!checkForDeprecation(docEnv)) {
 412             return;
 413         }
 414         if (createoverview) {
 415             topFile = DocPaths.overviewSummary(frames);
 416         } else {
 417             if (showModules) {
 418                 topFile = DocPath.empty.resolve(docPaths.moduleSummary(modules.first()));
 419             } else if (packages.size() == 1 && packages.first().isUnnamed()) {
 420                 List<TypeElement> classes = new ArrayList<>(getIncludedTypeElements());
 421                 if (!classes.isEmpty()) {
 422                     TypeElement te = getValidClass(classes);
 423                     topFile = docPaths.forClass(te);
 424                 }
 425             } else if (!packages.isEmpty()) {
 426                 topFile = docPaths.forPackage(packages.first()).resolve(DocPaths.PACKAGE_SUMMARY);
 427             }
 428         }
 429     }
 430 
 431     protected TypeElement getValidClass(List<TypeElement> classes) {
 432         if (!nodeprecated) {
 433             return classes.get(0);
 434         }
 435         for (TypeElement te : classes) {
 436             if (!utils.isDeprecated(te)) {
 437                 return te;
 438             }
 439         }
 440         return null;
 441     }
 442 
 443     protected boolean checkForDeprecation(DocletEnvironment docEnv) {
 444         for (TypeElement te : getIncludedTypeElements()) {
 445             if (isGeneratedDoc(te)) {
 446                 return true;


 827                     if (dopt.contains("/")) {
 828                         reporter.print(ERROR, getText("doclet.Option_doclint_no_qualifiers"));
 829                         return false;
 830                     }
 831                     if (!DocLint.isValidOption(dopt)) {
 832                         reporter.print(ERROR, getText("doclet.Option_doclint_invalid_arg"));
 833                         return false;
 834                     }
 835                     return true;
 836                 }
 837             },
 838             new XOption(resources, "doclet.usage.xdoclint-package", "-Xdoclint/package:", 0) {
 839                 @Override
 840                 public boolean process(String opt,  List<String> args) {
 841                     String dopt = opt.replace("-Xdoclint/package:", DocLint.XCHECK_PACKAGE);
 842                     doclintOpts.put(this, dopt);
 843                     if (!DocLint.isValidOption(dopt)) {
 844                         reporter.print(ERROR, getText("doclet.Option_doclint_package_invalid_arg"));
 845                         return false;
 846                     }
 847                     return true;
 848                 }
 849             },
 850             new XOption(resources, "--no-module-directories") {
 851                 @Override
 852                 public boolean process(String option, List<String> args) {
 853                     useModuleDirectories = false;
 854                     return true;
 855                 }
 856             }
 857         };
 858         Set<Doclet.Option> oset = new TreeSet<>();
 859         oset.addAll(Arrays.asList(options));
 860         oset.addAll(super.getSupportedOptions());
 861         return oset;
 862     }
 863 
 864     @Override
 865     protected boolean finishOptionSettings0() throws DocletException {
 866         if (docencoding == null) {
 867             if (charset == null) {
 868                 docencoding = charset = (encoding == null) ? HtmlConstants.HTML_DEFAULT_CHARSET : encoding;
 869             } else {
 870                 docencoding = charset;
 871             }
 872         } else {
 873             if (charset == null) {
< prev index next >