Sun, 24 Feb 2013 11:36:58 -0800
7112427: The doclet needs to be able to generate JavaFX documentation.
Reviewed-by: jjg
Contributed-by: jan.valenta@oracle.com
duke@1 | 1 | /* |
jjg@1606 | 2 | * Copyright (c) 2003, 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.internal.toolkit.builders; |
duke@1 | 27 | |
bpatel@766 | 28 | import java.io.*; |
jjg@1357 | 29 | |
bpatel@766 | 30 | import com.sun.javadoc.*; |
jjg@1357 | 31 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 32 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 33 | |
duke@1 | 34 | /** |
duke@1 | 35 | * Builds the summary for a given package. |
duke@1 | 36 | * |
jjg@1359 | 37 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 38 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 39 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 40 | * deletion without notice.</b> |
duke@1 | 41 | * |
duke@1 | 42 | * @author Jamie Ho |
bpatel@243 | 43 | * @author Bhavesh Patel (Modified) |
duke@1 | 44 | * @since 1.5 |
duke@1 | 45 | */ |
duke@1 | 46 | public class PackageSummaryBuilder extends AbstractBuilder { |
bpatel@766 | 47 | /** |
bpatel@766 | 48 | * The root element of the package summary XML is {@value}. |
bpatel@766 | 49 | */ |
bpatel@766 | 50 | public static final String ROOT = "PackageDoc"; |
duke@1 | 51 | |
bpatel@766 | 52 | /** |
bpatel@766 | 53 | * The package being documented. |
bpatel@766 | 54 | */ |
jjg@1410 | 55 | private final PackageDoc packageDoc; |
duke@1 | 56 | |
bpatel@766 | 57 | /** |
bpatel@766 | 58 | * The doclet specific writer that will output the result. |
bpatel@766 | 59 | */ |
jjg@1410 | 60 | private final PackageSummaryWriter packageWriter; |
duke@1 | 61 | |
bpatel@766 | 62 | /** |
bpatel@766 | 63 | * The content that will be added to the package summary documentation tree. |
bpatel@766 | 64 | */ |
bpatel@766 | 65 | private Content contentTree; |
duke@1 | 66 | |
jjg@1410 | 67 | /** |
jjg@1410 | 68 | * Construct a new PackageSummaryBuilder. |
jjg@1410 | 69 | * |
jjg@1410 | 70 | * @param context the build context. |
jjg@1410 | 71 | * @param pkg the package being documented. |
jjg@1410 | 72 | * @param packageWriter the doclet specific writer that will output the |
jjg@1410 | 73 | * result. |
jjg@1410 | 74 | */ |
jjg@1410 | 75 | private PackageSummaryBuilder(Context context, |
jjg@1410 | 76 | PackageDoc pkg, |
jjg@1410 | 77 | PackageSummaryWriter packageWriter) { |
jjg@1410 | 78 | super(context); |
jjg@1410 | 79 | this.packageDoc = pkg; |
jjg@1410 | 80 | this.packageWriter = packageWriter; |
bpatel@766 | 81 | } |
bpatel@766 | 82 | |
bpatel@766 | 83 | /** |
bpatel@766 | 84 | * Construct a new PackageSummaryBuilder. |
jjg@1410 | 85 | * |
jjg@1410 | 86 | * @param context the build context. |
bpatel@766 | 87 | * @param pkg the package being documented. |
bpatel@766 | 88 | * @param packageWriter the doclet specific writer that will output the |
bpatel@766 | 89 | * result. |
bpatel@766 | 90 | * |
bpatel@766 | 91 | * @return an instance of a PackageSummaryBuilder. |
bpatel@766 | 92 | */ |
jjg@1410 | 93 | public static PackageSummaryBuilder getInstance(Context context, |
jjg@1410 | 94 | PackageDoc pkg, PackageSummaryWriter packageWriter) { |
jjg@1410 | 95 | return new PackageSummaryBuilder(context, pkg, packageWriter); |
bpatel@766 | 96 | } |
bpatel@766 | 97 | |
bpatel@766 | 98 | /** |
bpatel@766 | 99 | * Build the package summary. |
bpatel@766 | 100 | */ |
bpatel@766 | 101 | public void build() throws IOException { |
bpatel@766 | 102 | if (packageWriter == null) { |
bpatel@766 | 103 | //Doclet does not support this output. |
bpatel@766 | 104 | return; |
duke@1 | 105 | } |
jjg@1410 | 106 | build(layoutParser.parseXML(ROOT), contentTree); |
bpatel@766 | 107 | } |
duke@1 | 108 | |
bpatel@766 | 109 | /** |
bpatel@766 | 110 | * {@inheritDoc} |
bpatel@766 | 111 | */ |
bpatel@766 | 112 | public String getName() { |
bpatel@766 | 113 | return ROOT; |
bpatel@766 | 114 | } |
bpatel@766 | 115 | |
bpatel@766 | 116 | /** |
bpatel@766 | 117 | * Build the package documentation. |
bpatel@766 | 118 | * |
bpatel@766 | 119 | * @param node the XML element that specifies which components to document |
bpatel@766 | 120 | * @param contentTree the content tree to which the documentation will be added |
bpatel@766 | 121 | */ |
bpatel@766 | 122 | public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception { |
bpatel@766 | 123 | contentTree = packageWriter.getPackageHeader( |
bpatel@766 | 124 | Util.getPackageName(packageDoc)); |
bpatel@766 | 125 | buildChildren(node, contentTree); |
bpatel@766 | 126 | packageWriter.addPackageFooter(contentTree); |
bpatel@766 | 127 | packageWriter.printDocument(contentTree); |
bpatel@766 | 128 | packageWriter.close(); |
jjg@1383 | 129 | Util.copyDocFiles(configuration, packageDoc); |
bpatel@766 | 130 | } |
bpatel@766 | 131 | |
bpatel@766 | 132 | /** |
bpatel@766 | 133 | * Build the content for the package doc. |
bpatel@766 | 134 | * |
bpatel@766 | 135 | * @param node the XML element that specifies which components to document |
bpatel@766 | 136 | * @param contentTree the content tree to which the package contents |
bpatel@766 | 137 | * will be added |
bpatel@766 | 138 | */ |
bpatel@766 | 139 | public void buildContent(XMLNode node, Content contentTree) { |
bpatel@766 | 140 | Content packageContentTree = packageWriter.getContentHeader(); |
bpatel@766 | 141 | buildChildren(node, packageContentTree); |
bpatel@766 | 142 | contentTree.addContent(packageContentTree); |
bpatel@766 | 143 | } |
bpatel@766 | 144 | |
bpatel@766 | 145 | /** |
bpatel@766 | 146 | * Build the package summary. |
bpatel@766 | 147 | * |
bpatel@766 | 148 | * @param node the XML element that specifies which components to document |
bpatel@766 | 149 | * @param packageContentTree the package content tree to which the summaries will |
bpatel@766 | 150 | * be added |
bpatel@766 | 151 | */ |
bpatel@766 | 152 | public void buildSummary(XMLNode node, Content packageContentTree) { |
bpatel@766 | 153 | Content summaryContentTree = packageWriter.getSummaryHeader(); |
bpatel@766 | 154 | buildChildren(node, summaryContentTree); |
bpatel@766 | 155 | packageContentTree.addContent(summaryContentTree); |
bpatel@766 | 156 | } |
bpatel@766 | 157 | |
bpatel@766 | 158 | /** |
bpatel@766 | 159 | * Build the summary for the interfaces in this package. |
bpatel@766 | 160 | * |
bpatel@766 | 161 | * @param node the XML element that specifies which components to document |
bpatel@766 | 162 | * @param summaryContentTree the summary tree to which the interface summary |
bpatel@766 | 163 | * will be added |
bpatel@766 | 164 | */ |
bpatel@766 | 165 | public void buildInterfaceSummary(XMLNode node, Content summaryContentTree) { |
bpatel@766 | 166 | String interfaceTableSummary = |
bpatel@766 | 167 | configuration.getText("doclet.Member_Table_Summary", |
bpatel@766 | 168 | configuration.getText("doclet.Interface_Summary"), |
bpatel@766 | 169 | configuration.getText("doclet.interfaces")); |
bpatel@766 | 170 | String[] interfaceTableHeader = new String[] { |
bpatel@766 | 171 | configuration.getText("doclet.Interface"), |
bpatel@766 | 172 | configuration.getText("doclet.Description") |
bpatel@766 | 173 | }; |
bpatel@766 | 174 | ClassDoc[] interfaces = |
bpatel@766 | 175 | packageDoc.isIncluded() |
bpatel@766 | 176 | ? packageDoc.interfaces() |
bpatel@766 | 177 | : configuration.classDocCatalog.interfaces( |
bpatel@766 | 178 | Util.getPackageName(packageDoc)); |
jjg@1606 | 179 | interfaces = Util.filterOutPrivateClasses(interfaces, configuration.javafx); |
bpatel@766 | 180 | if (interfaces.length > 0) { |
bpatel@766 | 181 | packageWriter.addClassesSummary( |
bpatel@766 | 182 | interfaces, |
bpatel@766 | 183 | configuration.getText("doclet.Interface_Summary"), |
bpatel@766 | 184 | interfaceTableSummary, interfaceTableHeader, summaryContentTree); |
duke@1 | 185 | } |
bpatel@766 | 186 | } |
duke@1 | 187 | |
bpatel@766 | 188 | /** |
bpatel@766 | 189 | * Build the summary for the classes in this package. |
bpatel@766 | 190 | * |
bpatel@766 | 191 | * @param node the XML element that specifies which components to document |
bpatel@766 | 192 | * @param summaryContentTree the summary tree to which the class summary will |
bpatel@766 | 193 | * be added |
bpatel@766 | 194 | */ |
bpatel@766 | 195 | public void buildClassSummary(XMLNode node, Content summaryContentTree) { |
bpatel@766 | 196 | String classTableSummary = |
bpatel@766 | 197 | configuration.getText("doclet.Member_Table_Summary", |
bpatel@766 | 198 | configuration.getText("doclet.Class_Summary"), |
bpatel@766 | 199 | configuration.getText("doclet.classes")); |
bpatel@766 | 200 | String[] classTableHeader = new String[] { |
bpatel@766 | 201 | configuration.getText("doclet.Class"), |
bpatel@766 | 202 | configuration.getText("doclet.Description") |
bpatel@766 | 203 | }; |
bpatel@766 | 204 | ClassDoc[] classes = |
bpatel@766 | 205 | packageDoc.isIncluded() |
bpatel@766 | 206 | ? packageDoc.ordinaryClasses() |
bpatel@766 | 207 | : configuration.classDocCatalog.ordinaryClasses( |
bpatel@766 | 208 | Util.getPackageName(packageDoc)); |
jjg@1606 | 209 | classes = Util.filterOutPrivateClasses(classes, configuration.javafx); |
bpatel@766 | 210 | if (classes.length > 0) { |
bpatel@766 | 211 | packageWriter.addClassesSummary( |
bpatel@766 | 212 | classes, |
bpatel@766 | 213 | configuration.getText("doclet.Class_Summary"), |
bpatel@766 | 214 | classTableSummary, classTableHeader, summaryContentTree); |
duke@1 | 215 | } |
bpatel@766 | 216 | } |
duke@1 | 217 | |
bpatel@766 | 218 | /** |
bpatel@766 | 219 | * Build the summary for the enums in this package. |
bpatel@766 | 220 | * |
bpatel@766 | 221 | * @param node the XML element that specifies which components to document |
bpatel@766 | 222 | * @param summaryContentTree the summary tree to which the enum summary will |
bpatel@766 | 223 | * be added |
bpatel@766 | 224 | */ |
bpatel@766 | 225 | public void buildEnumSummary(XMLNode node, Content summaryContentTree) { |
bpatel@766 | 226 | String enumTableSummary = |
bpatel@766 | 227 | configuration.getText("doclet.Member_Table_Summary", |
bpatel@766 | 228 | configuration.getText("doclet.Enum_Summary"), |
bpatel@766 | 229 | configuration.getText("doclet.enums")); |
bpatel@766 | 230 | String[] enumTableHeader = new String[] { |
bpatel@766 | 231 | configuration.getText("doclet.Enum"), |
bpatel@766 | 232 | configuration.getText("doclet.Description") |
bpatel@766 | 233 | }; |
bpatel@766 | 234 | ClassDoc[] enums = |
bpatel@766 | 235 | packageDoc.isIncluded() |
bpatel@766 | 236 | ? packageDoc.enums() |
bpatel@766 | 237 | : configuration.classDocCatalog.enums( |
bpatel@766 | 238 | Util.getPackageName(packageDoc)); |
jjg@1606 | 239 | enums = Util.filterOutPrivateClasses(enums, configuration.javafx); |
bpatel@766 | 240 | if (enums.length > 0) { |
bpatel@766 | 241 | packageWriter.addClassesSummary( |
bpatel@766 | 242 | enums, |
bpatel@766 | 243 | configuration.getText("doclet.Enum_Summary"), |
bpatel@766 | 244 | enumTableSummary, enumTableHeader, summaryContentTree); |
duke@1 | 245 | } |
bpatel@766 | 246 | } |
duke@1 | 247 | |
bpatel@766 | 248 | /** |
bpatel@766 | 249 | * Build the summary for the exceptions in this package. |
bpatel@766 | 250 | * |
bpatel@766 | 251 | * @param node the XML element that specifies which components to document |
bpatel@766 | 252 | * @param summaryContentTree the summary tree to which the exception summary will |
bpatel@766 | 253 | * be added |
bpatel@766 | 254 | */ |
bpatel@766 | 255 | public void buildExceptionSummary(XMLNode node, Content summaryContentTree) { |
bpatel@766 | 256 | String exceptionTableSummary = |
bpatel@766 | 257 | configuration.getText("doclet.Member_Table_Summary", |
bpatel@766 | 258 | configuration.getText("doclet.Exception_Summary"), |
bpatel@766 | 259 | configuration.getText("doclet.exceptions")); |
bpatel@766 | 260 | String[] exceptionTableHeader = new String[] { |
bpatel@766 | 261 | configuration.getText("doclet.Exception"), |
bpatel@766 | 262 | configuration.getText("doclet.Description") |
bpatel@766 | 263 | }; |
bpatel@766 | 264 | ClassDoc[] exceptions = |
bpatel@766 | 265 | packageDoc.isIncluded() |
bpatel@766 | 266 | ? packageDoc.exceptions() |
bpatel@766 | 267 | : configuration.classDocCatalog.exceptions( |
bpatel@766 | 268 | Util.getPackageName(packageDoc)); |
jjg@1606 | 269 | exceptions = Util.filterOutPrivateClasses(exceptions, configuration.javafx); |
bpatel@766 | 270 | if (exceptions.length > 0) { |
bpatel@766 | 271 | packageWriter.addClassesSummary( |
bpatel@766 | 272 | exceptions, |
bpatel@766 | 273 | configuration.getText("doclet.Exception_Summary"), |
bpatel@766 | 274 | exceptionTableSummary, exceptionTableHeader, summaryContentTree); |
duke@1 | 275 | } |
bpatel@766 | 276 | } |
duke@1 | 277 | |
bpatel@766 | 278 | /** |
bpatel@766 | 279 | * Build the summary for the errors in this package. |
bpatel@766 | 280 | * |
bpatel@766 | 281 | * @param node the XML element that specifies which components to document |
bpatel@766 | 282 | * @param summaryContentTree the summary tree to which the error summary will |
bpatel@766 | 283 | * be added |
bpatel@766 | 284 | */ |
bpatel@766 | 285 | public void buildErrorSummary(XMLNode node, Content summaryContentTree) { |
bpatel@766 | 286 | String errorTableSummary = |
bpatel@766 | 287 | configuration.getText("doclet.Member_Table_Summary", |
bpatel@766 | 288 | configuration.getText("doclet.Error_Summary"), |
bpatel@766 | 289 | configuration.getText("doclet.errors")); |
bpatel@766 | 290 | String[] errorTableHeader = new String[] { |
bpatel@766 | 291 | configuration.getText("doclet.Error"), |
bpatel@766 | 292 | configuration.getText("doclet.Description") |
bpatel@766 | 293 | }; |
bpatel@766 | 294 | ClassDoc[] errors = |
bpatel@766 | 295 | packageDoc.isIncluded() |
bpatel@766 | 296 | ? packageDoc.errors() |
bpatel@766 | 297 | : configuration.classDocCatalog.errors( |
bpatel@766 | 298 | Util.getPackageName(packageDoc)); |
jjg@1606 | 299 | errors = Util.filterOutPrivateClasses(errors, configuration.javafx); |
bpatel@766 | 300 | if (errors.length > 0) { |
bpatel@766 | 301 | packageWriter.addClassesSummary( |
bpatel@766 | 302 | errors, |
bpatel@766 | 303 | configuration.getText("doclet.Error_Summary"), |
bpatel@766 | 304 | errorTableSummary, errorTableHeader, summaryContentTree); |
duke@1 | 305 | } |
bpatel@766 | 306 | } |
duke@1 | 307 | |
bpatel@766 | 308 | /** |
bpatel@766 | 309 | * Build the summary for the annotation type in this package. |
bpatel@766 | 310 | * |
bpatel@766 | 311 | * @param node the XML element that specifies which components to document |
bpatel@766 | 312 | * @param summaryContentTree the summary tree to which the annotation type |
bpatel@766 | 313 | * summary will be added |
bpatel@766 | 314 | */ |
bpatel@766 | 315 | public void buildAnnotationTypeSummary(XMLNode node, Content summaryContentTree) { |
bpatel@766 | 316 | String annotationtypeTableSummary = |
bpatel@766 | 317 | configuration.getText("doclet.Member_Table_Summary", |
bpatel@766 | 318 | configuration.getText("doclet.Annotation_Types_Summary"), |
bpatel@766 | 319 | configuration.getText("doclet.annotationtypes")); |
bpatel@766 | 320 | String[] annotationtypeTableHeader = new String[] { |
bpatel@766 | 321 | configuration.getText("doclet.AnnotationType"), |
bpatel@766 | 322 | configuration.getText("doclet.Description") |
bpatel@766 | 323 | }; |
bpatel@766 | 324 | ClassDoc[] annotationTypes = |
bpatel@766 | 325 | packageDoc.isIncluded() |
bpatel@766 | 326 | ? packageDoc.annotationTypes() |
bpatel@766 | 327 | : configuration.classDocCatalog.annotationTypes( |
bpatel@766 | 328 | Util.getPackageName(packageDoc)); |
jjg@1606 | 329 | annotationTypes = Util.filterOutPrivateClasses(annotationTypes, configuration.javafx); |
bpatel@766 | 330 | if (annotationTypes.length > 0) { |
bpatel@766 | 331 | packageWriter.addClassesSummary( |
bpatel@766 | 332 | annotationTypes, |
bpatel@766 | 333 | configuration.getText("doclet.Annotation_Types_Summary"), |
bpatel@766 | 334 | annotationtypeTableSummary, annotationtypeTableHeader, |
bpatel@766 | 335 | summaryContentTree); |
duke@1 | 336 | } |
bpatel@766 | 337 | } |
duke@1 | 338 | |
bpatel@766 | 339 | /** |
bpatel@766 | 340 | * Build the description of the summary. |
bpatel@766 | 341 | * |
bpatel@766 | 342 | * @param node the XML element that specifies which components to document |
bpatel@766 | 343 | * @param packageContentTree the tree to which the package description will |
bpatel@766 | 344 | * be added |
bpatel@766 | 345 | */ |
bpatel@766 | 346 | public void buildPackageDescription(XMLNode node, Content packageContentTree) { |
bpatel@766 | 347 | if (configuration.nocomment) { |
bpatel@766 | 348 | return; |
duke@1 | 349 | } |
bpatel@766 | 350 | packageWriter.addPackageDescription(packageContentTree); |
bpatel@766 | 351 | } |
duke@1 | 352 | |
bpatel@766 | 353 | /** |
bpatel@766 | 354 | * Build the tags of the summary. |
bpatel@766 | 355 | * |
bpatel@766 | 356 | * @param node the XML element that specifies which components to document |
bpatel@766 | 357 | * @param packageContentTree the tree to which the package tags will be added |
bpatel@766 | 358 | */ |
bpatel@766 | 359 | public void buildPackageTags(XMLNode node, Content packageContentTree) { |
bpatel@766 | 360 | if (configuration.nocomment) { |
bpatel@766 | 361 | return; |
duke@1 | 362 | } |
bpatel@766 | 363 | packageWriter.addPackageTags(packageContentTree); |
bpatel@766 | 364 | } |
duke@1 | 365 | } |