diff -r bcbc86cc5b31 -r 90af8d87741f src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java --- a/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Tue Nov 30 09:38:48 2010 -0800 +++ b/src/share/classes/com/sun/tools/doclets/formats/html/HtmlDocletWriter.java Wed Dec 01 11:02:38 2010 -0800 @@ -88,6 +88,11 @@ public ConfigurationImpl configuration; /** + * To check whether annotation heading is printed or not. + */ + protected boolean printedAnnotationHeading = false; + + /** * Constructor to construct the HtmlStandardWriter object. * * @param filename File to be generated. @@ -169,7 +174,7 @@ // Append slash if next character is not a slash if (relativepathNoSlash.length() > 0 && previndex < htmlstr.length() && htmlstr.charAt(previndex) != '/') { - buf.append(DirectoryManager.URL_FILE_SEPERATOR); + buf.append(DirectoryManager.URL_FILE_SEPARATOR); } } return buf.toString(); @@ -192,17 +197,47 @@ println(" "); scriptEnd(); noScript(); - println(" " + getHyperLink(link, where, label, strong, "", "", target)); + println(" " + getHyperLinkString(link, where, label, strong, "", "", target)); noScriptEnd(); println(DocletConstants.NL); } - private void printMethodInfo(MethodDoc method) { + /** + * Get the script to show or hide the All classes link. + * + * @param id id of the element to show or hide + * @return a content tree for the script + */ + public Content getAllClassesLinkScript(String id) { + HtmlTree script = new HtmlTree(HtmlTag.SCRIPT); + script.addAttr(HtmlAttr.TYPE, "text/javascript"); + String scriptCode = "\n"; + Content scriptContent = new RawHtml(scriptCode); + script.addContent(scriptContent); + Content div = HtmlTree.DIV(script); + return div; + } + + /** + * Add method information. + * + * @param method the method to be documented + * @param dl the content tree to which the method information will be added + */ + private void addMethodInfo(MethodDoc method, Content dl) { ClassDoc[] intfacs = method.containingClass().interfaces(); MethodDoc overriddenMethod = method.overriddenMethod(); // Check whether there is any implementation or overridden info to be @@ -211,46 +246,38 @@ if ((intfacs.length > 0 && new ImplementedMethods(method, this.configuration).build().length > 0) || overriddenMethod != null) { - printMemberDetailsListStartTag(); - dd(); - printTagsInfoHeader(); - MethodWriterImpl.printImplementsInfo(this, method); + MethodWriterImpl.addImplementsInfo(this, method, dl); if (overriddenMethod != null) { - MethodWriterImpl.printOverridden(this, - method.overriddenType(), overriddenMethod); + MethodWriterImpl.addOverridden(this, + method.overriddenType(), overriddenMethod, dl); } - printTagsInfoFooter(); - ddEnd(); } } - protected void printTags(Doc doc) { - if(configuration.nocomment){ + /** + * Adds the tags information. + * + * @param doc the doc for which the tags will be generated + * @param htmltree the documentation tree to which the tags will be added + */ + protected void addTagsInfo(Doc doc, Content htmltree) { + if (configuration.nocomment) { return; } + Content dl = new HtmlTree(HtmlTag.DL); if (doc instanceof MethodDoc) { - printMethodInfo((MethodDoc) doc); + addMethodInfo((MethodDoc) doc, dl); } TagletOutputImpl output = new TagletOutputImpl(""); TagletWriter.genTagOuput(configuration.tagletManager, doc, configuration.tagletManager.getCustomTags(doc), getTagletWriterInstance(false), output); String outputString = output.toString().trim(); - // For RootDoc, ClassDoc and PackageDoc, this section is not the - // definition description but the start of definition list. if (!outputString.isEmpty()) { - if (!(doc instanceof RootDoc || doc instanceof ClassDoc || - doc instanceof PackageDoc)) { - printMemberDetailsListStartTag(); - dd(); - } - printTagsInfoHeader(); - print(outputString); - printTagsInfoFooter(); - if (!(doc instanceof RootDoc || doc instanceof ClassDoc || - doc instanceof PackageDoc)) - ddEnd(); + Content resultString = new RawHtml(outputString); + dl.addContent(resultString); } + htmltree.addContent(dl); } /** @@ -286,17 +313,16 @@ } /** - * Print Package link, with target frame. + * Get Package link, with target frame. * - * @param pd The link will be to the "package-summary.html" page for this - * package. - * @param target Name of the target frame. - * @param label Tag for the link. + * @param pd The link will be to the "package-summary.html" page for this package + * @param target name of the target frame + * @param label tag for the link + * @return a content for the target package link */ - public void printTargetPackageLink(PackageDoc pd, String target, - String label) { - print(getHyperLink(pathString(pd, "package-summary.html"), "", label, - false, "", "", target)); + public Content getTargetPackageLink(PackageDoc pd, String target, + Content label) { + return getHyperLink(pathString(pd, "package-summary.html"), "", label, "", target); } /** @@ -360,6 +386,64 @@ } /** + * Generates the HTML document tree and prints it out. + * + * @param metakeywords Array of String keywords for META tag. Each element + * of the array is assigned to a separate META tag. + * Pass in null for no array + * @param includeScript true if printing windowtitle script + * false for files that appear in the left-hand frames + * @param body the body htmltree to be included in the document + */ + public void printHtmlDocument(String[] metakeywords, boolean includeScript, + Content body) { + Content htmlDocType = DocType.Transitional(); + Content htmlComment = new Comment(configuration.getText("doclet.New_Page")); + Content head = new HtmlTree(HtmlTag.HEAD); + if (!configuration.notimestamp) { + Content headComment = new Comment("Generated by javadoc (version " + + ConfigurationImpl.BUILD_DATE + ") on " + today()); + head.addContent(headComment); + } + if (configuration.charset.length() > 0) { + Content meta = HtmlTree.META("Content-Type", "text/html", + configuration.charset); + head.addContent(meta); + } + head.addContent(getTitle()); + if (!configuration.notimestamp) { + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Content meta = HtmlTree.META("date", dateFormat.format(new Date())); + head.addContent(meta); + } + if (metakeywords != null) { + for (int i=0; i < metakeywords.length; i++) { + Content meta = HtmlTree.META("keywords", metakeywords[i]); + head.addContent(meta); + } + } + head.addContent(getStyleSheetProperties()); + Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), + head, body); + Content htmlDocument = new HtmlDocument(htmlDocType, + htmlComment, htmlTree); + print(htmlDocument.toString()); + } + + /** + * Get the window title. + * + * @param title the title string to construct the complete window title + * @return the window title string + */ + public String getWindowTitle(String title) { + if (configuration.windowtitle.length() > 0) { + title += " (" + configuration.windowtitle + ")"; + } + return title; + } + + /** * Print user specified header and the footer. * * @param header if true print the user provided header else print the @@ -380,6 +464,28 @@ } /** + * Get user specified header and the footer. + * + * @param header if true print the user provided header else print the + * user provided footer. + */ + public Content getUserHeaderFooter(boolean header) { + String content; + if (header) { + content = replaceDocRootDir(configuration.header); + } else { + if (configuration.footer.length() != 0) { + content = replaceDocRootDir(configuration.footer); + } else { + content = replaceDocRootDir(configuration.header); + } + } + Content rawContent = new RawHtml(content); + Content em = HtmlTree.EM(rawContent); + return em; + } + + /** * Print the user specified top. */ public void printTop() { @@ -388,6 +494,16 @@ } /** + * Adds the user specified top. + * + * @param body the content tree to which user specified top will be added + */ + public void addTop(Content body) { + Content top = new RawHtml(replaceDocRootDir(configuration.top)); + body.addContent(top); + } + + /** * Print the user specified bottom. */ public void printBottom() { @@ -396,6 +512,18 @@ } /** + * Adds the user specified bottom. + * + * @param body the content tree to which user specified bottom will be added + */ + public void addBottom(Content body) { + Content bottom = new RawHtml(replaceDocRootDir(configuration.bottom)); + Content small = HtmlTree.SMALL(bottom); + Content p = HtmlTree.P(HtmlStyle.legalCopy, small); + body.addContent(p); + } + + /** * Print the navigation bar for the Html page at the top and and the bottom. * * @param header If true print navigation bar at the top of the page else @@ -408,13 +536,13 @@ println(DocletConstants.NL + ""); anchor("navbar_top"); println(); - print(getHyperLink("", "skip-navbar_top", "", false, "", + print(getHyperLinkString("", "skip-navbar_top", "", false, "", configuration.getText("doclet.Skip_navigation_links"), "")); } else { println(DocletConstants.NL + ""); anchor("navbar_bottom"); println(); - print(getHyperLink("", "skip-navbar_bottom", "", false, "", + print(getHyperLinkString("", "skip-navbar_bottom", "", false, "", configuration.getText("doclet.Skip_navigation_links"), "")); } table(0, "100%", 1, 0); @@ -518,6 +646,97 @@ } /** + * Adds the navigation bar for the Html page at the top and and the bottom. + * + * @param header If true print navigation bar at the top of the page else + * @param body the HtmlTree to which the nav links will be added + */ + protected void addNavLinks(boolean header, Content body) { + if (!configuration.nonavbar) { + String allClassesId = "allclasses_"; + HtmlTree navDiv = new HtmlTree(HtmlTag.DIV); + if (header) { + body.addContent(HtmlConstants.START_OF_TOP_NAVBAR); + navDiv.addStyle(HtmlStyle.topNav); + allClassesId += "navbar_top"; + Content a = getMarkerAnchor("navbar_top"); + navDiv.addContent(a); + Content skipLinkContent = getHyperLink("", + "skip-navbar_top", HtmlTree.EMPTY, configuration.getText( + "doclet.Skip_navigation_links"), ""); + navDiv.addContent(skipLinkContent); + } else { + body.addContent(HtmlConstants.START_OF_BOTTOM_NAVBAR); + navDiv.addStyle(HtmlStyle.bottomNav); + allClassesId += "navbar_bottom"; + Content a = getMarkerAnchor("navbar_bottom"); + navDiv.addContent(a); + Content skipLinkContent = getHyperLink("", + "skip-navbar_bottom", HtmlTree.EMPTY, configuration.getText( + "doclet.Skip_navigation_links"), ""); + navDiv.addContent(skipLinkContent); + } + if (header) { + navDiv.addContent(getMarkerAnchor("navbar_top_firstrow")); + } else { + navDiv.addContent(getMarkerAnchor("navbar_bottom_firstrow")); + } + HtmlTree navList = new HtmlTree(HtmlTag.UL); + navList.addStyle(HtmlStyle.navList); + navList.addAttr(HtmlAttr.TITLE, "Navigation"); + if (configuration.createoverview) { + navList.addContent(getNavLinkContents()); + } + if (configuration.packages.length == 1) { + navList.addContent(getNavLinkPackage(configuration.packages[0])); + } else if (configuration.packages.length > 1) { + navList.addContent(getNavLinkPackage()); + } + navList.addContent(getNavLinkClass()); + if(configuration.classuse) { + navList.addContent(getNavLinkClassUse()); + } + if(configuration.createtree) { + navList.addContent(getNavLinkTree()); + } + if(!(configuration.nodeprecated || + configuration.nodeprecatedlist)) { + navList.addContent(getNavLinkDeprecated()); + } + if(configuration.createindex) { + navList.addContent(getNavLinkIndex()); + } + if (!configuration.nohelp) { + navList.addContent(getNavLinkHelp()); + } + navDiv.addContent(navList); + Content aboutDiv = HtmlTree.DIV(HtmlStyle.aboutLanguage, getUserHeaderFooter(header)); + navDiv.addContent(aboutDiv); + body.addContent(navDiv); + Content ulNav = HtmlTree.UL(HtmlStyle.navList, getNavLinkPrevious()); + ulNav.addContent(getNavLinkNext()); + Content subDiv = HtmlTree.DIV(HtmlStyle.subNav, ulNav); + Content ulFrames = HtmlTree.UL(HtmlStyle.navList, getNavShowLists()); + ulFrames.addContent(getNavHideLists(filename)); + subDiv.addContent(ulFrames); + HtmlTree ulAllClasses = HtmlTree.UL(HtmlStyle.navList, getNavLinkClassIndex()); + ulAllClasses.addAttr(HtmlAttr.ID, allClassesId.toString()); + subDiv.addContent(ulAllClasses); + subDiv.addContent(getAllClassesLinkScript(allClassesId.toString())); + addSummaryDetailLinks(subDiv); + if (header) { + subDiv.addContent(getMarkerAnchor("skip-navbar_top")); + body.addContent(subDiv); + body.addContent(HtmlConstants.END_OF_TOP_NAVBAR); + } else { + subDiv.addContent(getMarkerAnchor("skip-navbar_bottom")); + body.addContent(subDiv); + body.addContent(HtmlConstants.END_OF_BOTTOM_NAVBAR); + } + } + } + + /** * Print the word "NEXT" to indicate that no link is available. Override * this method to customize next link. */ @@ -526,6 +745,16 @@ } /** + * Get the word "NEXT" to indicate that no link is available. Override + * this method to customize next link. + * + * @return a content tree for the link + */ + protected Content getNavLinkNext() { + return getNavLinkNext(null); + } + + /** * Print the word "PREV" to indicate that no link is available. Override * this method to customize prev link. */ @@ -534,12 +763,28 @@ } /** + * Get the word "PREV" to indicate that no link is available. Override + * this method to customize prev link. + * + * @return a content tree for the link + */ + protected Content getNavLinkPrevious() { + return getNavLinkPrevious(null); + } + + /** * Do nothing. This is the default method. */ protected void printSummaryDetailLinks() { } /** + * Do nothing. This is the default method. + */ + protected void addSummaryDetailLinks(Content navDiv) { + } + + /** * Print link to the "overview-summary.html" page. */ protected void navLinkContents() { @@ -550,6 +795,18 @@ } /** + * Get link to the "overview-summary.html" page. + * + * @return a content tree for the link + */ + protected Content getNavLinkContents() { + Content linkContent = getHyperLink(relativePath + + "overview-summary.html", "", overviewLabel, "", ""); + Content li = HtmlTree.LI(linkContent); + return li; + } + + /** * Description for a cell in the navigation bar. */ protected void navCellStart() { @@ -590,6 +847,19 @@ } /** + * Get link to the "package-summary.html" page for the package passed. + * + * @param pkg Package to which link will be generated + * @return a content tree for the link + */ + protected Content getNavLinkPackage(PackageDoc pkg) { + Content linkContent = getPackageLink(pkg, + packageLabel); + Content li = HtmlTree.LI(linkContent); + return li; + } + + /** * Print the word "Package" in the navigation bar cell, to indicate that * link is not available here. */ @@ -602,6 +872,16 @@ } /** + * Get the word "Package" , to indicate that link is not available here. + * + * @return a content tree for the link + */ + protected Content getNavLinkPackage() { + Content li = HtmlTree.LI(packageLabel); + return li; + } + + /** * Print the word "Use" in the navigation bar cell, to indicate that link * is not available. */ @@ -614,6 +894,16 @@ } /** + * Get the word "Use", to indicate that link is not available. + * + * @return a content tree for the link + */ + protected Content getNavLinkClassUse() { + Content li = HtmlTree.LI(useLabel); + return li; + } + + /** * Print link for previous file. * * @param prev File name for the prev link. @@ -628,6 +918,22 @@ } /** + * Get link for previous file. + * + * @param prev File name for the prev link + * @return a content tree for the link + */ + public Content getNavLinkPrevious(String prev) { + Content li; + if (prev != null) { + li = HtmlTree.LI(getHyperLink(prev, "", prevLabel, "", "")); + } + else + li = HtmlTree.LI(prevLabel); + return li; + } + + /** * Print link for next file. If next is null, just print the label * without linking it anywhere. * @@ -643,16 +949,46 @@ } /** + * Get link for next file. If next is null, just print the label + * without linking it anywhere. + * + * @param next File name for the next link + * @return a content tree for the link + */ + public Content getNavLinkNext(String next) { + Content li; + if (next != null) { + li = HtmlTree.LI(getHyperLink(next, "", nextLabel, "", "")); + } + else + li = HtmlTree.LI(nextLabel); + return li; + } + + /** * Print "FRAMES" link, to switch to the frame version of the output. * * @param link File to be linked, "index.html". */ protected void navShowLists(String link) { - print(getHyperLink(link + "?" + path + filename, "", + print(getHyperLinkString(link + "?" + path + filename, "", configuration.getText("doclet.FRAMES"), true, "", "", "_top")); } /** + * Get "FRAMES" link, to switch to the frame version of the output. + * + * @param link File to be linked, "index.html" + * @return a content tree for the link + */ + protected Content getNavShowLists(String link) { + Content framesContent = getHyperLink(link + "?" + path + + filename, "", framesLabel, "", "_top"); + Content li = HtmlTree.LI(framesContent); + return li; + } + + /** * Print "FRAMES" link, to switch to the frame version of the output. */ protected void navShowLists() { @@ -660,16 +996,37 @@ } /** + * Get "FRAMES" link, to switch to the frame version of the output. + * + * @return a content tree for the link + */ + protected Content getNavShowLists() { + return getNavShowLists(relativePath + "index.html"); + } + + /** * Print "NO FRAMES" link, to switch to the non-frame version of the output. * * @param link File to be linked. */ protected void navHideLists(String link) { - print(getHyperLink(link, "", configuration.getText("doclet.NO_FRAMES"), + print(getHyperLinkString(link, "", configuration.getText("doclet.NO_FRAMES"), true, "", "", "_top")); } /** + * Get "NO FRAMES" link, to switch to the non-frame version of the output. + * + * @param link File to be linked + * @return a content tree for the link + */ + protected Content getNavHideLists(String link) { + Content noFramesContent = getHyperLink(link, "", noframesLabel, "", "_top"); + Content li = HtmlTree.LI(noFramesContent); + return li; + } + + /** * Print "Tree" link in the navigation bar. If there is only one package * specified on the command line, then the "Tree" link will be to the * only "package-tree.html" file otherwise it will be to the @@ -689,10 +1046,39 @@ } /** - * Print "Tree" link to the "overview-tree.html" file. + * Get "Tree" link in the navigation bar. If there is only one package + * specified on the command line, then the "Tree" link will be to the + * only "package-tree.html" file otherwise it will be to the + * "overview-tree.html" file. + * + * @return a content tree for the link */ - protected void navLinkMainTree(String label) { - printHyperLink(relativePath + "overview-tree.html", label); + protected Content getNavLinkTree() { + Content treeLinkContent; + PackageDoc[] packages = configuration.root.specifiedPackages(); + if (packages.length == 1 && configuration.root.specifiedClasses().length == 0) { + treeLinkContent = getHyperLink(pathString(packages[0], + "package-tree.html"), "", treeLabel, + "", ""); + } else { + treeLinkContent = getHyperLink(relativePath + "overview-tree.html", + "", treeLabel, "", ""); + } + Content li = HtmlTree.LI(treeLinkContent); + return li; + } + + /** + * Get the overview tree link for the main tree. + * + * @param label the label for the link + * @return a content tree for the link + */ + protected Content getNavLinkMainTree(String label) { + Content mainTreeContent = getHyperLink(relativePath + "overview-tree.html", + new StringContent(label)); + Content li = HtmlTree.LI(mainTreeContent); + return li; } /** @@ -708,6 +1094,16 @@ } /** + * Get the word "Class", to indicate that class link is not available. + * + * @return a content tree for the link + */ + protected Content getNavLinkClass() { + Content li = HtmlTree.LI(classLabel); + return li; + } + + /** * Print "Deprecated" API link in the navigation bar. */ protected void navLinkDeprecated() { @@ -718,6 +1114,18 @@ } /** + * Get "Deprecated" API link in the navigation bar. + * + * @return a content tree for the link + */ + protected Content getNavLinkDeprecated() { + Content linkContent = getHyperLink(relativePath + + "deprecated-list.html", "", deprecatedLabel, "", ""); + Content li = HtmlTree.LI(linkContent); + return li; + } + + /** * Print link for generated index. If the user has used "-splitindex" * command line option, then link to file "index-files/index-1.html" is * generated otherwise link to file "index-all.html" is generated. @@ -727,6 +1135,21 @@ AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "", "", configuration.getText("doclet.All_Classes"), true); } + + /** + * Get link for generated index. If the user has used "-splitindex" + * command line option, then link to file "index-files/index-1.html" is + * generated otherwise link to file "index-all.html" is generated. + * + * @return a content tree for the link + */ + protected Content getNavLinkClassIndex() { + Content allClassesContent = getHyperLink(relativePath + + AllClassesFrameWriter.OUTPUT_FILE_NAME_NOFRAMES, "", + allclassesLabel, "", ""); + Content li = HtmlTree.LI(allClassesContent); + return li; + } /** * Print link for generated class index. */ @@ -743,6 +1166,20 @@ } /** + * Get link for generated class index. + * + * @return a content tree for the link + */ + protected Content getNavLinkIndex() { + Content linkContent = getHyperLink(relativePath +(configuration.splitindex? + DirectoryManager.getPath("index-files") + fileseparator: "") + + (configuration.splitindex?"index-1.html" : "index-all.html"), "", + indexLabel, "", ""); + Content li = HtmlTree.LI(linkContent); + return li; + } + + /** * Print help file link. If user has provided a help file, then generate a * link to the user given file, which is already copied to current or * destination directory. @@ -764,6 +1201,29 @@ } /** + * Get help file link. If user has provided a help file, then generate a + * link to the user given file, which is already copied to current or + * destination directory. + * + * @return a content tree for the link + */ + protected Content getNavLinkHelp() { + String helpfilenm = configuration.helpfile; + if (helpfilenm.equals("")) { + helpfilenm = "help-doc.html"; + } else { + int lastsep; + if ((lastsep = helpfilenm.lastIndexOf(File.separatorChar)) != -1) { + helpfilenm = helpfilenm.substring(lastsep + 1); + } + } + Content linkContent = getHyperLink(relativePath + helpfilenm, "", + helpLabel, "", ""); + Content li = HtmlTree.LI(linkContent); + return li; + } + + /** * Print the word "Detail" in the navigation bar. No link is available. */ protected void navDetail() { @@ -845,6 +1305,96 @@ } /** + * Get summary table header. + * + * @param header the header for the table + * @param scope the scope of the headers + * @return a content tree for the header + */ + public Content getSummaryTableHeader(String[] header, String scope) { + Content tr = new HtmlTree(HtmlTag.TR); + int size = header.length; + Content tableHeader; + if (size == 1) { + tableHeader = new StringContent(header[0]); + tr.addContent(HtmlTree.TH(HtmlStyle.colOne, scope, tableHeader)); + return tr; + } + for (int i = 0; i < size; i++) { + tableHeader = new StringContent(header[i]); + if(i == 0) + tr.addContent(HtmlTree.TH(HtmlStyle.colFirst, scope, tableHeader)); + else if(i == (size - 1)) + tr.addContent(HtmlTree.TH(HtmlStyle.colLast, scope, tableHeader)); + else + tr.addContent(HtmlTree.TH(scope, tableHeader)); + } + return tr; + } + + /** + * Get table caption. + * + * @param rawText the caption for the table which could be raw Html + * @return a content tree for the caption + */ + public Content getTableCaption(String rawText) { + Content title = new RawHtml(rawText); + Content captionSpan = HtmlTree.SPAN(title); + Content space = getSpace(); + Content tabSpan = HtmlTree.SPAN(HtmlStyle.tabEnd, space); + Content caption = HtmlTree.CAPTION(captionSpan); + caption.addContent(tabSpan); + return caption; + } + + /** + * Get the marker anchor which will be added to the documentation tree. + * + * @param anchorName the anchor name attribute + * @return a content tree for the marker anchor + */ + public Content getMarkerAnchor(String anchorName) { + return getMarkerAnchor(anchorName, null); + } + + /** + * Get the marker anchor which will be added to the documentation tree. + * + * @param anchorName the anchor name attribute + * @param anchorContent the content that should be added to the anchor + * @return a content tree for the marker anchor + */ + public Content getMarkerAnchor(String anchorName, Content anchorContent) { + if (anchorContent == null) + anchorContent = new Comment(" "); + Content markerAnchor = HtmlTree.A_NAME(anchorName, anchorContent); + return markerAnchor; + } + + /** + * Returns a packagename content. + * + * @param packageDoc the package to check + * @return package name content + */ + public Content getPackageName(PackageDoc packageDoc) { + return packageDoc == null || packageDoc.name().length() == 0 ? + defaultPackageLabel : + getPackageLabel(packageDoc.name()); + } + + /** + * Returns a package name label. + * + * @param parsedName the package name + * @return the package name content + */ + public Content getPackageLabel(String packageName) { + return new StringContent(packageName); + } + + /** * Prine table header information about color, column span and the font. * * @param color Background color. @@ -1028,7 +1578,7 @@ * @param isStrong true if the label should be strong. */ public void printPackageLink(PackageDoc pkg, String label, boolean isStrong) { - print(getPackageLink(pkg, label, isStrong)); + print(getPackageLinkString(pkg, label, isStrong)); } /** @@ -1041,7 +1591,7 @@ */ public void printPackageLink(PackageDoc pkg, String label, boolean isStrong, String style) { - print(getPackageLink(pkg, label, isStrong, style)); + print(getPackageLinkString(pkg, label, isStrong, style)); } /** @@ -1052,9 +1602,9 @@ * @param isStrong true if the label should be strong. * @return the link to the given package. */ - public String getPackageLink(PackageDoc pkg, String label, + public String getPackageLinkString(PackageDoc pkg, String label, boolean isStrong) { - return getPackageLink(pkg, label, isStrong, ""); + return getPackageLinkString(pkg, label, isStrong, ""); } /** @@ -1066,7 +1616,7 @@ * @param style the font of the package link label. * @return the link to the given package. */ - public String getPackageLink(PackageDoc pkg, String label, boolean isStrong, + public String getPackageLinkString(PackageDoc pkg, String label, boolean isStrong, String style) { boolean included = pkg != null && pkg.isIncluded(); if (! included) { @@ -1079,12 +1629,43 @@ } } if (included || pkg == null) { - return getHyperLink(pathString(pkg, "package-summary.html"), + return getHyperLinkString(pathString(pkg, "package-summary.html"), "", label, isStrong, style); } else { String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); if (crossPkgLink != null) { - return getHyperLink(crossPkgLink, "", label, isStrong, style); + return getHyperLinkString(crossPkgLink, "", label, isStrong, style); + } else { + return label; + } + } + } + + /** + * Return the link to the given package. + * + * @param pkg the package to link to. + * @param label the label for the link. + * @return a content tree for the package link. + */ + public Content getPackageLink(PackageDoc pkg, Content label) { + boolean included = pkg != null && pkg.isIncluded(); + if (! included) { + PackageDoc[] packages = configuration.packages; + for (int i = 0; i < packages.length; i++) { + if (packages[i].equals(pkg)) { + included = true; + break; + } + } + } + if (included || pkg == null) { + return getHyperLink(pathString(pkg, "package-summary.html"), + "", label); + } else { + String crossPkgLink = getCrossPackageLink(Util.getPackageName(pkg)); + if (crossPkgLink != null) { + return getHyperLink(crossPkgLink, "", label); } else { return label; } @@ -1112,6 +1693,29 @@ } /** + * Add the link to the content tree. + * + * @param doc program element doc for which the link will be added + * @param label label for the link + * @param htmltree the content tree to which the link will be added + */ + public void addSrcLink(ProgramElementDoc doc, Content label, Content htmltree) { + if (doc == null) { + return; + } + ClassDoc cd = doc.containingClass(); + if (cd == null) { + //d must be a class doc since in has no containing class. + cd = (ClassDoc) doc; + } + String href = relativePath + DocletConstants.SOURCE_OUTPUT_DIR_NAME + + DirectoryManager.getDirectoryPath(cd.containingPackage()) + + cd.name() + ".html#" + SourceToHTMLConverter.getAnchorName(doc); + Content linkContent = getHyperLink(href, "", label, "", ""); + htmltree.addContent(linkContent); + } + + /** * Return the link to the given class. * * @param linkInfo the information about the link. @@ -1175,7 +1779,7 @@ //the -link option. There are ways to determine if an external package //exists, but no way to determine if the external class exists. We just //have to assume that it does. - return getHyperLink( + return getHyperLinkString( configuration.extern.getExternalLink(packageName, relativePath, className + ".html?is-external=true"), refMemName == null ? "" : refMemName, @@ -1200,17 +1804,27 @@ "package-summary.html?is-external=true"); } - public void printQualifiedClassLink(int context, ClassDoc cd) { - printLink(new LinkInfoImpl(context, cd, - configuration.getClassName(cd), "")); + /** + * Get the class link. + * + * @param context the id of the context where the link will be added + * @param cd the class doc to link to + * @return a content tree for the link + */ + public Content getQualifiedClassLink(int context, ClassDoc cd) { + return new RawHtml(getLink(new LinkInfoImpl(context, cd, + configuration.getClassName(cd), ""))); } /** - * Print Class link, with only class name as the link and prefixing - * plain package name. + * Add the class link. + * + * @param context the id of the context where the link will be added + * @param cd the class doc to link to + * @param contentTree the content tree to which the link will be added */ - public void printPreQualifiedClassLink(int context, ClassDoc cd) { - print(getPreQualifiedClassLink(context, cd, false)); + public void addPreQualifiedClassLink(int context, ClassDoc cd, Content contentTree) { + addPreQualifiedClassLink(context, cd, false, contentTree); } /** @@ -1233,13 +1847,36 @@ return classlink; } + /** + * Add the class link with the package portion of the label in + * plain text. If the qualifier is excluded, it will not be included in the + * link label. + * + * @param context the id of the context where the link will be added + * @param cd the class to link to + * @param isStrong true if the link should be strong + * @param contentTree the content tree to which the link with be added + */ + public void addPreQualifiedClassLink(int context, + ClassDoc cd, boolean isStrong, Content contentTree) { + PackageDoc pd = cd.containingPackage(); + if(pd != null && ! configuration.shouldExcludeQualifier(pd.name())) { + contentTree.addContent(getPkgName(cd)); + } + contentTree.addContent(new RawHtml(getLink(new LinkInfoImpl( + context, cd, cd.name(), isStrong)))); + } /** - * Print Class link, with only class name as the strong link and prefixing + * Add the class link, with only class name as the strong link and prefixing * plain package name. + * + * @param context the id of the context where the link will be added + * @param cd the class to link to + * @param contentTree the content tree to which the link with be added */ - public void printPreQualifiedStrongClassLink(int context, ClassDoc cd) { - print(getPreQualifiedClassLink(context, cd, true)); + public void addPreQualifiedStrongClassLink(int context, ClassDoc cd, Content contentTree) { + addPreQualifiedClassLink(context, cd, true, contentTree); } public void printText(String key) { @@ -1267,16 +1904,15 @@ } /** - * Print the link for the given member. + * Get the link for the given member. * - * @param context the id of the context where the link will be printed. - * @param doc the member being linked to. - * @param label the label for the link. - * @param strong true if the link should be strong. + * @param context the id of the context where the link will be added + * @param doc the member being linked to + * @param label the label for the link + * @return a content tree for the doc link */ - public void printDocLink(int context, MemberDoc doc, String label, - boolean strong) { - print(getDocLink(context, doc, label, strong)); + public Content getDocLink(int context, MemberDoc doc, String label) { + return getDocLink(context, doc.containingClass(), doc, label); } /** @@ -1338,6 +1974,34 @@ } } + /** + * Return the link for the given member. + * + * @param context the id of the context where the link will be added + * @param classDoc the classDoc that we should link to. This is not + * necessarily equal to doc.containingClass(). We may be + * inheriting comments + * @param doc the member being linked to + * @param label the label for the link + * @return the link for the given member + */ + public Content getDocLink(int context, ClassDoc classDoc, MemberDoc doc, + String label) { + if (! (doc.isIncluded() || + Util.isLinkable(classDoc, configuration()))) { + return new StringContent(label); + } else if (doc instanceof ExecutableMemberDoc) { + ExecutableMemberDoc emd = (ExecutableMemberDoc)doc; + return new RawHtml(getLink(new LinkInfoImpl(context, classDoc, + getAnchor(emd), label, false))); + } else if (doc instanceof MemberDoc) { + return new RawHtml(getLink(new LinkInfoImpl(context, classDoc, + doc.name(), label, false))); + } else { + return new StringContent(label); + } + } + public void anchor(ExecutableMemberDoc emd) { anchor(getAnchor(emd)); } @@ -1392,14 +2056,14 @@ //@see is referencing an included package String packageName = isplaintext ? refPackage.name() : getCode() + refPackage.name() + getCodeEnd(); - result.append(getPackageLink(refPackage, + result.append(getPackageLinkString(refPackage, label.length() == 0 ? packageName : label, false)); } else { //@see is not referencing an included class or package. Check for cross links. String classCrossLink, packageCrossLink = getCrossPackageLink(refClassName); if (packageCrossLink != null) { //Package cross link found - result.append(getHyperLink(packageCrossLink, "", + result.append(getHyperLinkString(packageCrossLink, "", (label.length() == 0)? text : label, false)); } else if ((classCrossLink = getCrossClassLink(refClassName, refMemName, label, false, "", ! isplaintext)) != null) { @@ -1468,18 +2132,61 @@ printCommentTags(doc, tag.inlineTags(), false, false); } + /** + * Add the inline comment. + * + * @param doc the doc for which the inline comment will be added + * @param tag the inline tag to be added + * @param htmltree the content tree to which the comment will be added + */ + public void addInlineComment(Doc doc, Tag tag, Content htmltree) { + addCommentTags(doc, tag.inlineTags(), false, false, htmltree); + } + public void printInlineDeprecatedComment(Doc doc, Tag tag) { printCommentTags(doc, tag.inlineTags(), true, false); } + /** + * Add the inline deprecated comment. + * + * @param doc the doc for which the inline deprecated comment will be added + * @param tag the inline tag to be added + * @param htmltree the content tree to which the comment will be added + */ + public void addInlineDeprecatedComment(Doc doc, Tag tag, Content htmltree) { + addCommentTags(doc, tag.inlineTags(), true, false, htmltree); + } + public void printSummaryComment(Doc doc) { printSummaryComment(doc, doc.firstSentenceTags()); } + /** + * Adds the summary content. + * + * @param doc the doc for which the summary will be generated + * @param htmltree the documentation tree to which the summary will be added + */ + public void addSummaryComment(Doc doc, Content htmltree) { + addSummaryComment(doc, doc.firstSentenceTags(), htmltree); + } + public void printSummaryComment(Doc doc, Tag[] firstSentenceTags) { printCommentTags(doc, firstSentenceTags, false, true); } + /** + * Adds the summary content. + * + * @param doc the doc for which the summary will be generated + * @param firstSentenceTags the first sentence tags for the doc + * @param htmltree the documentation tree to which the summary will be added + */ + public void addSummaryComment(Doc doc, Tag[] firstSentenceTags, Content htmltree) { + addCommentTags(doc, firstSentenceTags, false, true, htmltree); + } + public void printSummaryDeprecatedComment(Doc doc) { printCommentTags(doc, doc.firstSentenceTags(), true, true); } @@ -1488,11 +2195,25 @@ printCommentTags(doc, tag.firstSentenceTags(), true, true); } + public void addSummaryDeprecatedComment(Doc doc, Tag tag, Content htmltree) { + addCommentTags(doc, tag.firstSentenceTags(), true, true, htmltree); + } + public void printInlineComment(Doc doc) { printCommentTags(doc, doc.inlineTags(), false, false); p(); } + /** + * Adds the inline comment. + * + * @param doc the doc for which the inline comments will be generated + * @param htmltree the documentation tree to which the inline comments will be added + */ + public void addInlineComment(Doc doc, Content htmltree) { + addCommentTags(doc, doc.inlineTags(), false, false, htmltree); + } + public void printInlineDeprecatedComment(Doc doc) { printCommentTags(doc, doc.inlineTags(), true, false); } @@ -1515,6 +2236,36 @@ } /** + * Adds the comment tags. + * + * @param doc the doc for which the comment tags will be generated + * @param tags the first sentence tags for the doc + * @param depr true if it is deprecated + * @param first true if the first sentenge tags should be added + * @param htmltree the documentation tree to which the comment tags will be added + */ + private void addCommentTags(Doc doc, Tag[] tags, boolean depr, + boolean first, Content htmltree) { + if(configuration.nocomment){ + return; + } + Content div; + Content result = new RawHtml(commentTagsToString(null, doc, tags, first)); + if (depr) { + Content italic = HtmlTree.I(result); + div = HtmlTree.DIV(HtmlStyle.block, italic); + htmltree.addContent(div); + } + else { + div = HtmlTree.DIV(HtmlStyle.block, result); + htmltree.addContent(div); + } + if (tags.length == 0) { + htmltree.addContent(getSpace()); + } + } + + /** * Converts inline tags and text to text strings, expanding the * inline tags along the way. Called wherever text can contain * an inline tag, such as in comments or in free-form text arguments @@ -1624,8 +2375,8 @@ return text; } - if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPERATOR)) { - redirectPathFromRoot += DirectoryManager.URL_FILE_SEPERATOR; + if (! redirectPathFromRoot.endsWith(DirectoryManager.URL_FILE_SEPARATOR)) { + redirectPathFromRoot += DirectoryManager.URL_FILE_SEPARATOR; } //Redirect all relative links. @@ -1751,6 +2502,27 @@ } /** + * Returns a link to the stylesheet file. + * + * @return an HtmlTree for the lINK tag which provides the stylesheet location + */ + public HtmlTree getStyleSheetProperties() { + String filename = configuration.stylesheetfile; + if (filename.length() > 0) { + File stylefile = new File(filename); + String parent = stylefile.getParent(); + filename = (parent == null)? + filename: + filename.substring(parent.length() + 1); + } else { + filename = "stylesheet.css"; + } + filename = relativePath + filename; + HtmlTree link = HtmlTree.LINK("stylesheet", "text/css", filename, "Style"); + return link; + } + + /** * According to the Java Language Specifications, all the outer classes * and static nested classes are core classes. */ @@ -1768,6 +2540,17 @@ } /** + * Adds the annotatation types for the given packageDoc. + * + * @param packageDoc the package to write annotations for. + * @param htmltree the documentation tree to which the annotation info will be + * added + */ + public void addAnnotationInfo(PackageDoc packageDoc, Content htmltree) { + addAnnotationInfo(packageDoc, packageDoc.annotations(), htmltree); + } + + /** * Write the annotatation types for the given doc. * * @param doc the doc to write annotations for. @@ -1777,6 +2560,16 @@ } /** + * Adds the annotatation types for the given doc. + * + * @param packageDoc the package to write annotations for + * @param htmltree the content tree to which the annotation types will be added + */ + public void addAnnotationInfo(ProgramElementDoc doc, Content htmltree) { + addAnnotationInfo(doc, doc.annotations(), htmltree); + } + + /** * Write the annotatation types for the given doc and parameter. * * @param indent the number of spaced to indent the parameters. @@ -1788,6 +2581,19 @@ } /** + * Add the annotatation types for the given doc and parameter. + * + * @param indent the number of spaces to indent the parameters. + * @param doc the doc to write annotations for. + * @param param the parameter to write annotations for. + * @param tree the content tree to which the annotation types will be added + */ + public boolean addAnnotationInfo(int indent, Doc doc, Parameter param, + Content tree) { + return addAnnotationInfo(indent, doc, param.annotations(), false, tree); + } + + /** * Write the annotatation types for the given doc. * * @param doc the doc to write annotations for. @@ -1798,6 +2604,19 @@ } /** + * Adds the annotatation types for the given doc. + * + * @param doc the doc to write annotations for. + * @param descList the array of {@link AnnotationDesc}. + * @param htmltree the documentation tree to which the annotation info will be + * added + */ + private void addAnnotationInfo(Doc doc, AnnotationDesc[] descList, + Content htmltree) { + addAnnotationInfo(0, doc, descList, true, htmltree); + } + + /** * Write the annotatation types for the given doc. * * @param indent the number of extra spaces to indent the annotations. @@ -1818,6 +2637,29 @@ } /** + * Adds the annotatation types for the given doc. + * + * @param indent the number of extra spaces to indent the annotations. + * @param doc the doc to write annotations for. + * @param descList the array of {@link AnnotationDesc}. + * @param htmltree the documentation tree to which the annotation info will be + * added + */ + private boolean addAnnotationInfo(int indent, Doc doc, + AnnotationDesc[] descList, boolean lineBreak, Content htmltree) { + List annotations = getAnnotations(indent, descList, lineBreak); + if (annotations.size() == 0) { + return false; + } + Content annotationContent; + for (Iterator iter = annotations.iterator(); iter.hasNext();) { + annotationContent = new RawHtml(iter.next()); + htmltree.addContent(annotationContent); + } + return true; + } + + /** * Return the string representations of the annotation types for * the given doc. *