Example #1
0
 /**
  * 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);
 }
 /**
  * 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);
   }
 }
Example #3
0
 /**
  * Get the header for the deprecated API Listing.
  *
  * @return a content tree for the header
  */
 public Content getHeader() {
   String title = configuration.getText("doclet.Window_Deprecated_List");
   Content bodyTree = getBody(true, getWindowTitle(title));
   addTop(bodyTree);
   addNavLinks(true, bodyTree);
   return bodyTree;
 }
 /**
  * Convert the given Class to an HTML.
  *
  * @param cd the class to convert.
  * @param outputdir the name of the directory to output to.
  */
 public void convertClass(ClassDoc cd, DocPath outputdir) {
   if (cd == null) {
     return;
   }
   try {
     SourcePosition sp = cd.position();
     if (sp == null) return;
     Reader r;
     // temp hack until we can update SourcePosition API.
     if (sp instanceof SourcePositionImpl) {
       FileObject fo = ((SourcePositionImpl) sp).fileObject();
       if (fo == null) return;
       r = fo.openReader(true);
     } else {
       File file = sp.file();
       if (file == null) return;
       r = new FileReader(file);
     }
     int lineno = 1;
     String line;
     relativePath = DocPaths.SOURCE_OUTPUT.resolve(DocPath.forPackage(cd)).invert();
     Content body = getHeader();
     Content pre = new HtmlTree(HtmlTag.PRE);
     try (LineNumberReader reader = new LineNumberReader(r)) {
       while ((line = reader.readLine()) != null) {
         addLineNo(pre, lineno);
         addLine(pre, line, lineno);
         lineno++;
       }
     }
     addBlankLines(pre);
     Content div = HtmlTree.DIV(HtmlStyle.sourceContainer, pre);
     body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(div) : div);
     writeToFile(body, outputdir.resolve(DocPath.forClass(cd)));
   } catch (IOException e) {
     e.printStackTrace();
   }
 }