/** * Add the modifier and type for the member in the member summary. * * @param member the member to add the type for * @param type the type to add * @param tdSummaryType the content tree to which the modified and type will be added */ protected void addModifierAndType(ProgramElementDoc member, Type type, Content tdSummaryType) { HtmlTree code = new HtmlTree(HtmlTag.CODE); addModifier(member, code); if (type == null) { if (member.isClass()) { code.addContent("class"); } else { code.addContent("interface"); } code.addContent(writer.getSpace()); } else { if (member instanceof ExecutableMemberDoc && ((ExecutableMemberDoc) member).typeParameters().length > 0) { Content typeParameters = ((AbstractExecutableMemberWriter) this).getTypeParameters((ExecutableMemberDoc) member); code.addContent(typeParameters); // Code to avoid ugly wrapping in member summary table. if (typeParameters.charCount() > 10) { code.addContent(new HtmlTree(HtmlTag.BR)); } else { code.addContent(writer.getSpace()); } code.addContent( writer.getLink( new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))); } else { code.addContent( writer.getLink( new LinkInfoImpl(configuration, LinkInfoImpl.Kind.SUMMARY_RETURN_TYPE, type))); } } tdSummaryType.addContent(code); }
/** * Generate the deprecated API list. * * @param deprapi list of deprecated API built already. */ protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi) throws IOException { Content body = getHeader(); body.addContent(getContentsList(deprapi)); String memberTableSummary; String[] memberTableHeader = new String[1]; HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.contentContainer); for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { if (deprapi.hasDocumentation(i)) { addAnchor(deprapi, i, div); memberTableSummary = configuration.getText( "doclet.Member_Table_Summary", configuration.getText(HEADING_KEYS[i]), configuration.getText(SUMMARY_KEYS[i])); memberTableHeader[0] = configuration.getText( "doclet.0_and_1", configuration.getText(HEADER_KEYS[i]), configuration.getText("doclet.Description")); writers[i].addDeprecatedAPI( deprapi.getList(i), HEADING_KEYS[i], memberTableSummary, memberTableHeader, div); } } body.addContent(div); addNavLinks(false, body); addBottom(body); printHtmlDocument(null, true, body); }
/** * Build the summaries for the methods that belong to the given class. * * @param node the XML element that specifies which components to document * @param classContentTree content tree to which the documentation will be added */ public void buildSerializableMethods(XMLNode node, Content classContentTree) { Content serializableMethodTree = methodWriter.getSerializableMethodsHeader(); MemberDoc[] members = currentClass.serializationMethods(); int membersLength = members.length; if (membersLength > 0) { for (int i = 0; i < membersLength; i++) { currentMember = members[i]; Content methodsContentTree = methodWriter.getMethodsContentHeader((i == membersLength - 1)); buildChildren(node, methodsContentTree); serializableMethodTree.addContent(methodsContentTree); } } if (currentClass.serializationMethods().length > 0) { classContentTree.addContent( methodWriter.getSerializableMethods( configuration.getText("doclet.Serialized_Form_methods"), serializableMethodTree)); if (currentClass.isSerializable() && !currentClass.isExternalizable()) { if (currentClass.serializationMethods().length == 0) { Content noCustomizationMsg = methodWriter.getNoCustomizationMsg( configuration.getText("doclet.Serializable_no_customization")); classContentTree.addContent( methodWriter.getSerializableMethods( configuration.getText("doclet.Serialized_Form_methods"), noCustomizationMsg)); } } } }
/** {@inheritDoc} */ public Content getConstructorDetailsTreeHeader(ClassDoc classDoc, Content memberDetailsTree) { memberDetailsTree.addContent(HtmlConstants.START_OF_CONSTRUCTOR_DETAILS); Content constructorDetailsTree = writer.getMemberTreeHeader(); constructorDetailsTree.addContent(writer.getMarkerAnchor(SectionName.CONSTRUCTOR_DETAIL)); Content heading = HtmlTree.HEADING(HtmlConstants.DETAILS_HEADING, writer.constructorDetailsLabel); constructorDetailsTree.addContent(heading); return constructorDetailsTree; }
/** {@inheritDoc} */ protected void addNavDetailLink(boolean link, Content liNav) { if (link) { liNav.addContent( writer.getHyperLink( SectionName.CONSTRUCTOR_DETAIL, writer.getResource("doclet.navConstructor"))); } else { liNav.addContent(writer.getResource("doclet.navConstructor")); } }
/** * Add the deprecated information for the given member. * * @param member the member being documented. * @param contentTree the content tree to which the deprecated information will be added. */ protected void addDeprecatedInfo(ProgramElementDoc member, Content contentTree) { Content output = (new DeprecatedTaglet()).getTagletOutput(member, writer.getTagletWriterInstance(false)); if (!output.isEmpty()) { Content deprecatedContent = output; Content div = HtmlTree.DIV(HtmlStyle.block, deprecatedContent); contentTree.addContent(div); } }
/** * Build the member details contents of the page. * * @param node the XML element that specifies which components to document * @param annotationContentTree the content tree to which the documentation will be added */ public void buildAnnotationTypeMemberDetails(XMLNode node, Content annotationContentTree) { Content memberDetailsTree = writer.getMemberTreeHeader(); buildChildren(node, memberDetailsTree); if (memberDetailsTree.isValid()) { Content memberDetails = writer.getMemberTreeHeader(); writer.addAnnotationDetailsMarker(memberDetails); memberDetails.addContent(writer.getMemberTree(memberDetailsTree)); annotationContentTree.addContent(writer.getMemberDetailsTree(memberDetails)); } }
/** * Add a line from source to the HTML file that is generated. * * @param pre the content tree to which the line will be added. * @param line the string to format. * @param currentLineNo the current number. */ private void addLine(Content pre, String line, int currentLineNo) { if (line != null) { Content anchor = HtmlTree.A( configuration.htmlVersion, "line." + Integer.toString(currentLineNo), new StringContent(utils.replaceTabs(configuration, line))); pre.addContent(anchor); pre.addContent(NEW_LINE); } }
/** * Add the package use information. * * @param pkg the package that uses the given class * @param contentTree the content tree to which the package use information will be added */ protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException { Content tdFirst = HtmlTree.TD( HtmlStyle.colFirst, getHyperLink(pkg.name(), new StringContent(Util.getPackageName(pkg)))); contentTree.addContent(tdFirst); HtmlTree tdLast = new HtmlTree(HtmlTag.TD); tdLast.addStyle(HtmlStyle.colLast); addSummaryComment(pkg, tdLast); contentTree.addContent(tdLast); }
/** * Write the output to the file. * * @param body the documentation content to be written to the file. * @param path the path for the file. */ private void writeToFile(Content body, DocPath path) throws IOException { Content htmlDocType = configuration.isOutputHtml5() ? DocType.HTML5 : DocType.TRANSITIONAL; Content head = new HtmlTree(HtmlTag.HEAD); head.addContent( HtmlTree.TITLE(new StringContent(configuration.getText("doclet.Window_Source_title")))); head.addContent(getStyleSheetProperties()); Content htmlTree = HtmlTree.HTML(configuration.getLocale().getLanguage(), head, body); Content htmlDocument = new HtmlDocument(htmlDocType, htmlTree); configuration.message.notice("doclet.Generating_0", path.getPath()); DocFile df = DocFile.createFileForOutput(configuration, path); try (Writer w = df.openWriter()) { htmlDocument.write(w, true); } }
/** Generate the package use list. */ protected void generatePackageUseFile() throws IOException { Content body = getPackageUseHeader(); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.contentContainer); if (usingPackageToUsedClasses.isEmpty()) { div.addContent(getResource("doclet.ClassUse_No.usage.of.0", pkgdoc.name())); } else { addPackageUse(div); } body.addContent(div); addNavLinks(false, body); addBottom(body); printHtmlDocument(null, true, body); }
/** Generate the class use list. */ protected void generateClassUseFile() throws IOException { Content body = getClassUseHeader(); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.classUseContainer); if (pkgSet.size() > 0) { addClassUse(div); } else { div.addContent(getResource("doclet.ClassUse_No.usage.of.0", classdoc.qualifiedName())); } body.addContent(div); addNavLinks(false, body); addBottom(body); printHtmlDocument(null, true, body); }
/** * Get the contents list. * * @param deprapi the deprecated list builder * @return a content tree for the contents list */ public Content getContentsList(DeprecatedAPIListBuilder deprapi) { Content headContent = getResource("doclet.Deprecated_API"); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); Content headingContent = getResource("doclet.Contents"); div.addContent(HtmlTree.HEADING(HtmlConstants.CONTENT_HEADING, true, headingContent)); Content ul = new HtmlTree(HtmlTag.UL); for (int i = 0; i < DeprecatedAPIListBuilder.NUM_TYPES; i++) { addIndexLink(deprapi, i, ul); } div.addContent(ul); return div; }
/** {@inheritDoc} */ public Content getSignature(ConstructorDoc constructor) { Content pre = new HtmlTree(HtmlTag.PRE); writer.addAnnotationInfo(constructor, pre); addModifiers(constructor, pre); if (configuration.linksource) { Content constructorName = new StringContent(constructor.name()); writer.addSrcLink(constructor, constructorName, pre); } else { addName(constructor.name(), pre); } int indent = pre.charCount(); addParameters(constructor, pre, indent); addExceptions(constructor, pre, indent); return pre; }
/** * Add the package use information. * * @param pkg the package that used the given package * @param contentTree the content tree to which the information will be added */ protected void addPackageUse(PackageDoc pkg, Content contentTree) throws IOException { Content tdFirst = HtmlTree.TD( HtmlStyle.colFirst, getHyperLink(Util.getPackageName(pkg), new StringContent(Util.getPackageName(pkg)))); contentTree.addContent(tdFirst); HtmlTree tdLast = new HtmlTree(HtmlTag.TD); tdLast.addStyle(HtmlStyle.colLast); if (pkg != null && pkg.name().length() != 0) { addSummaryComment(pkg, tdLast); } else { tdLast.addContent(getSpace()); } contentTree.addContent(tdLast); }
/** * Build the member summary contents of the page. * * @param node the XML element that specifies which components to document * @param annotationContentTree the content tree to which the documentation will be added */ public void buildMemberSummary(XMLNode node, Content annotationContentTree) throws Exception { Content memberSummaryTree = writer.getMemberTreeHeader(); configuration .getBuilderFactory() .getMemberSummaryBuilder(writer) .buildChildren(node, memberSummaryTree); annotationContentTree.addContent(writer.getMemberSummaryTree(memberSummaryTree)); }
/** * Get the header for the package use listing. * * @return a content tree representing the package use header */ protected Content getPackageUseHeader() { String packageText = configuration.getText("doclet.Package"); String name = pkgdoc.name(); String title = configuration.getText("doclet.Window_ClassUse_Header", packageText, name); Content bodyTree = getBody(true, getWindowTitle(title)); addTop(bodyTree); addNavLinks(true, bodyTree); ContentBuilder headContent = new ContentBuilder(); headContent.addContent(getResource("doclet.ClassUse_Title", packageText)); headContent.addContent(new HtmlTree(HtmlTag.BR)); headContent.addContent(name); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); bodyTree.addContent(div); return bodyTree; }
/** * Add the navigation summary link. * * @param members members to be linked * @param visibleMemberMap the visible inherited members map * @param liNav the content tree to which the navigation summary link will be added */ protected void addNavSummaryLink( List<?> members, VisibleMemberMap visibleMemberMap, Content liNav) { if (members.size() > 0) { liNav.addContent(getNavSummaryLink(null, true)); return; } ClassDoc icd = classdoc.superclass(); while (icd != null) { List<?> inhmembers = visibleMemberMap.getMembersFor(icd); if (inhmembers.size() > 0) { liNav.addContent(getNavSummaryLink(icd, true)); return; } icd = icd.superclass(); } liNav.addContent(getNavSummaryLink(null, false)); }
/** * Add the modifier for the member. * * @param member the member to add the type for * @param code the content tree to which the modified will be added */ private void addModifier(ProgramElementDoc member, Content code) { if (member.isProtected()) { code.addContent("protected "); } else if (member.isPrivate()) { code.addContent("private "); } else if (!member.isPublic()) { // Package private code.addContent(configuration.getText("doclet.Package_private")); code.addContent(" "); } if (member.isMethod()) { if (!(member.containingClass().isInterface()) && ((MethodDoc) member).isAbstract()) { code.addContent("abstract "); } // This check for isDefault() and the default modifier needs to be // added for it to appear on the "Modifier and Type" column in the // method summary section. Once the default modifier is added // to the Modifier list on DocEnv and once it is updated to use the // javax.lang.model.element.Modifier, we will need to remove this. if (((MethodDoc) member).isDefault()) { code.addContent("default "); } } if (member.isStatic()) { code.addContent("static "); } }
/** * Build the serialized form summaries. * * @param node the XML element that specifies which components to document * @param serializedTree content tree to which the documentation will be added */ public void buildSerializedFormSummaries(XMLNode node, Content serializedTree) { Content serializedSummariesTree = writer.getSerializedSummariesHeader(); PackageDoc[] packages = configuration.packages; for (int i = 0; i < packages.length; i++) { currentPackage = packages[i]; buildChildren(node, serializedSummariesTree); } serializedTree.addContent(writer.getSerializedContent(serializedSummariesTree)); }
/** * Build the field documentation. * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added */ public void buildFieldDoc(XMLNode node, Content memberDetailsTree) { if (writer == null) { return; } int size = fields.size(); if (size > 0) { Content fieldDetailsTree = writer.getFieldDetailsTreeHeader(classDoc, memberDetailsTree); for (currentFieldIndex = 0; currentFieldIndex < size; currentFieldIndex++) { Content fieldDocTree = writer.getFieldDocTreeHeader( (FieldDoc) fields.get(currentFieldIndex), fieldDetailsTree); buildChildren(node, fieldDocTree); fieldDetailsTree.addContent( writer.getFieldDoc(fieldDocTree, (currentFieldIndex == size - 1))); } memberDetailsTree.addContent(writer.getFieldDetails(fieldDetailsTree)); } }
/** * Add the package use information. * * @param contentTree the content tree to which the package use information will be added */ protected void addPackageUse(Content contentTree) throws IOException { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.blockList); if (configuration.packages.length > 1) { addPackageList(ul); } addClassList(ul); contentTree.addContent(ul); }
/** * Build the method documentation. * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added */ public void buildMethodDoc(XMLNode node, Content memberDetailsTree) { if (writer == null) { return; } int size = methods.size(); if (size > 0) { Content methodDetailsTree = writer.getMethodDetailsTreeHeader(classDoc, memberDetailsTree); for (currentMethodIndex = 0; currentMethodIndex < size; currentMethodIndex++) { Content methodDocTree = writer.getMethodDocTreeHeader( (MethodDoc) methods.get(currentMethodIndex), methodDetailsTree); buildChildren(node, methodDocTree); methodDetailsTree.addContent( writer.getMethodDoc(methodDocTree, (currentMethodIndex == size - 1))); } memberDetailsTree.addContent(writer.getMethodDetails(methodDetailsTree)); } }
/** * Get the header for the class use Listing. * * @return a content tree representing the class use header */ protected Content getClassUseHeader() { String cltype = configuration.getText(classdoc.isInterface() ? "doclet.Interface" : "doclet.Class"); String clname = classdoc.qualifiedName(); String title = configuration.getText("doclet.Window_ClassUse_Header", cltype, clname); Content bodyTree = getBody(true, getWindowTitle(title)); addTop(bodyTree); addNavLinks(true, bodyTree); ContentBuilder headContent = new ContentBuilder(); headContent.addContent(getResource("doclet.ClassUse_Title", cltype)); headContent.addContent(new HtmlTree(HtmlTag.BR)); headContent.addContent(clname); Content heading = HtmlTree.HEADING(HtmlConstants.CLASS_PAGE_HEADING, true, HtmlStyle.title, headContent); Content div = HtmlTree.DIV(HtmlStyle.header, heading); bodyTree.addContent(div); return bodyTree; }
/** * Add a row for the class that uses the given package. * * @param usedClass the class that uses the given package * @param packageName the name of the package to which the class belongs * @param contentTree the content tree to which the row will be added */ protected void addClassRow(ClassDoc usedClass, String packageName, Content contentTree) { DocPath dp = pathString(usedClass, DocPaths.CLASS_USE.resolve(DocPath.forName(usedClass))); Content td = HtmlTree.TD( HtmlStyle.colOne, getHyperLink(dp.fragment(packageName), new StringContent(usedClass.name()))); addIndexComment(usedClass, td); contentTree.addContent(td); }
/** * Build the class serialized form. * * @param node the XML element that specifies which components to document * @param packageSerializedTree content tree to which the documentation will be added */ public void buildClassSerializedForm(XMLNode node, Content packageSerializedTree) { Content classSerializedTree = writer.getClassSerializedHeader(); ClassDoc[] classes = currentPackage.allClasses(false); Arrays.sort(classes); for (int j = 0; j < classes.length; j++) { currentClass = classes[j]; fieldWriter = writer.getSerialFieldWriter(currentClass); methodWriter = writer.getSerialMethodWriter(currentClass); if (currentClass.isClass() && currentClass.isSerializable()) { if (!serialClassInclude(currentClass)) { continue; } Content classTree = writer.getClassHeader(currentClass); buildChildren(node, classTree); classSerializedTree.addContent(classTree); } } packageSerializedTree.addContent(classSerializedTree); }
/** * Add the class list that use the given class. * * @param contentTree the content tree to which the class list will be added */ protected void addClassList(Content contentTree) throws IOException { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.blockList); for (PackageDoc pkg : pkgSet) { Content li = HtmlTree.LI(HtmlStyle.blockList, getMarkerAnchor(pkg.name())); Content link = getResource( "doclet.ClassUse_Uses.of.0.in.1", getLink( new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, classdoc)), getPackageLink(pkg, Util.getPackageName(pkg))); Content heading = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, link); li.addContent(heading); addClassUse(pkg, li); ul.addContent(li); } Content li = HtmlTree.LI(HtmlStyle.blockList, ul); contentTree.addContent(li); }
/** * Build the serialization overview for the given class. * * @param classDoc the class to print the overview for. * @param classContentTree content tree to which the documentation will be added */ public void buildFieldSerializationOverview(ClassDoc classDoc, Content classContentTree) { if (classDoc.definesSerializableFields()) { FieldDoc serialPersistentField = classDoc.serializableFields()[0]; // Check to see if there are inline comments, tags or deprecation // information to be printed. if (fieldWriter.shouldPrintOverview(serialPersistentField)) { Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader(); Content fieldsOverviewContentTree = fieldWriter.getFieldsContentHeader(true); fieldWriter.addMemberDeprecatedInfo(serialPersistentField, fieldsOverviewContentTree); if (!configuration.nocomment) { fieldWriter.addMemberDescription(serialPersistentField, fieldsOverviewContentTree); fieldWriter.addMemberTags(serialPersistentField, fieldsOverviewContentTree); } serializableFieldsTree.addContent(fieldsOverviewContentTree); classContentTree.addContent( fieldWriter.getSerializableFields( configuration.getText("doclet.Serialized_Form_class"), serializableFieldsTree)); } } }
/** * Build the summaries for the fields that belong to the given class. * * @param node the XML element that specifies which components to document * @param classContentTree content tree to which the documentation will be added */ public void buildSerializableFields(XMLNode node, Content classContentTree) { MemberDoc[] members = currentClass.serializableFields(); int membersLength = members.length; if (membersLength > 0) { Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader(); for (int i = 0; i < membersLength; i++) { currentMember = members[i]; if (!currentClass.definesSerializableFields()) { Content fieldsContentTree = fieldWriter.getFieldsContentHeader((i == membersLength - 1)); buildChildren(node, fieldsContentTree); serializableFieldsTree.addContent(fieldsContentTree); } else { buildSerialFieldTagsInfo(serializableFieldsTree); } } classContentTree.addContent( fieldWriter.getSerializableFields( configuration.getText("doclet.Serialized_Form_fields"), serializableFieldsTree)); } }
/** * Build the annotation type documentation. * * @param node the XML element that specifies which components to document * @param contentTree the content tree to which the documentation will be added */ public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws Exception { contentTree = writer.getHeader( configuration.getText("doclet.AnnotationType") + " " + annotationTypeDoc.name()); Content annotationContentTree = writer.getAnnotationContentHeader(); buildChildren(node, annotationContentTree); contentTree.addContent(annotationContentTree); writer.addFooter(contentTree); writer.printDocument(contentTree); writer.close(); copyDocFiles(); }