Beispiel #1
0
  /**
   * Print warning message, increment warning count. Part of DocErrorReporter.
   *
   * @param pos the position where the error occurs
   * @param msg message to print
   */
  public void printWarning(SourcePosition pos, String msg) {
    if (diagListener != null) {
      report(DiagnosticType.WARNING, pos, msg);
      return;
    }

    if (nwarnings < MaxWarnings) {
      String prefix = (pos == null) ? programName : pos.toString();
      warnWriter.println(prefix + ": " + getText("javadoc.warning") + " - " + msg);
      warnWriter.flush();
      nwarnings++;
    }
  }
 /**
  * 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();
   }
 }
Beispiel #3
0
  /**
   * Print error message, increment error count. Part of DocErrorReporter.
   *
   * @param pos the position where the error occurs
   * @param msg message to print
   */
  public void printError(SourcePosition pos, String msg) {
    if (diagListener != null) {
      report(DiagnosticType.ERROR, pos, msg);
      return;
    }

    if (nerrors < MaxErrors) {
      String prefix = (pos == null) ? programName : pos.toString();
      errWriter.println(prefix + ": " + getText("javadoc.error") + " - " + msg);
      errWriter.flush();
      prompt();
      nerrors++;
    }
  }