public static boolean validOptions(String[][] options, DocErrorReporter docErrorReporter) { for (int i = 0; i < options.length; i++) { for (int j = 0; j < options[i].length; j++) { docErrorReporter.printWarning("options[" + i + "][" + j + "] = " + options[i][j]); } } return true; }
public void fatalError(SAXParseException e) throws SAXException { ERROR_REPORTER.printWarning(e.getMessage()); ERROR_REPORTER.printWarning("Line: " + e.getLineNumber() + ", Column: " + e.getColumnNumber()); ret.set(false); } });
String selectStylesheet(String javaVersion) { if (javaVersion.matches("^1\\.[56]\\D.*")) { return JAVA6_STYLESHEET; } if (javaVersion.matches("^1\\.[78]\\D.*")) { return JAVA8_STYLESHEET; } if (javaVersion.matches("^(9|10)(\\.)?.*")) { return JAVA9_STYLESHEET; } errorReporter.printWarning("Unrecognized Java version " + javaVersion + ", using Java 9 stylesheet"); // TODO: review this when Java 11 becomes available and/or make more configurable! return JAVA9_STYLESHEET; } }
private static File prepareTemplateDir(DocErrorReporter errorReporter) { // copy our template resources to the templateDir so Asciidoctor can use them. File templateDir = Files.createTempDir(); try { for (String templateName : TEMPLATE_NAMES) { prepareTemplate(templateDir, templateName); } return templateDir; } catch (IOException e) { errorReporter.printWarning("Failed to prepare templates: " + e.getLocalizedMessage()); return null; } }
public static boolean validOptions(String[][] options, DocErrorReporter errorReporter, StandardAdapter standardDoclet) { DocletOptions docletOptions = new DocletOptions(options); if (!docletOptions.baseDir().isPresent()) { errorReporter.printWarning(BASEDIR + " must be present for includes or file reference features to work properly."); } Optional<File> attrsFile = docletOptions.attributesFile(); if (attrsFile.isPresent() && !attrsFile.get().canRead()) { errorReporter.printWarning("Cannot read attributes file " + attrsFile.get()); } return standardDoclet.validOptions(options, errorReporter); }
/** * Build the extern package list from given URL or the directory path. * Flag error if the "-link" or "-linkoffline" option is already used. * * @param url URL or Directory path. * @param pkglisturl This can be another URL for "package-list" or ordinary * file. * @param reporter The <code>DocErrorReporter</code> used to report errors. * @param linkoffline True if -linkoffline isused and false if -link is used. */ public boolean url(String url, String pkglisturl, DocErrorReporter reporter, boolean linkoffline) { this.linkoffline = linkoffline; String errMsg = composeExternPackageList(url, pkglisturl); if (errMsg != null) { reporter.printWarning(errMsg); return false; } else { return true; } }
private Map<String, Object> parseAttributesFile(Optional<File> attrsFile, Map<String, Object> cmdlineAttrs) { if (attrsFile.isPresent()) { try { return parseAttributes(Files.newReader(attrsFile.get(), docletOptions.encoding()), cmdlineAttrs); } catch (Exception e) { errorReporter.printWarning("Cannot read attributes file: " + e); } } return cmdlineAttrs; }
/** * Prints comment tags. * * @param pw the writer to print the comment tags to * @param memberDoc the member to print the comment tags for * @param commentTags the comment tags to print */ private static void printComment(PrintWriter pw, ProgramElementDoc memberDoc, Tag[] commentTags) { StringBuilder ft = new StringBuilder(); for (Tag tag : commentTags) { ft.append(tag.text()); } boolean isValid = OUTPUT_HTML && validateXml(ft.toString().toLowerCase()); if (OUTPUT_HTML && !isValid) { ERROR_REPORTER.printWarning(" >> Malformed XML detected, tags will be ignored for: " + memberDoc.name()); } for (Tag tag : commentTags) { if (tag instanceof SeeTag) { SeeTag seeTag = (SeeTag) tag; printSeeTag(pw, memberDoc, seeTag, false); } else { String text = tag.text(); printText(pw, memberDoc, text, isValid); } } }
/** * Prints the return documentation. * * @param pw the writer to print the return documentation to * @param memberDoc the member to document the return for */ private static void printReturnTag(PrintWriter pw, ExecutableMemberDoc memberDoc) { Tag[] returnDoc = memberDoc.tags("@return"); if (returnDoc.length == 1) { printIndent(pw, 3); pw.print("<returns>"); printComment(pw, memberDoc, returnDoc[0].inlineTags()); pw.println("</returns>"); } else if (returnDoc.length > 1) { ERROR_REPORTER.printWarning("More than one return tag specified for '" + memberDoc.qualifiedName() + "'"); } }
ERROR_REPORTER.printWarning("Invalid anchor '" + text + "' for '" + memberDoc.qualifiedName() + "'"); ERROR_REPORTER.printWarning("Unable to locate reference '" + text + "' for '" + memberDoc.qualifiedName() + "'");
/** * Prints the exception documentation. * * @param pw the writer to print the exception documentation to * @param memberDoc the member to document the exceptions for */ private static void printThrowsTags(PrintWriter pw, ExecutableMemberDoc memberDoc) { ThrowsTag[] throwsTags = memberDoc.throwsTags(); for (ThrowsTag throwsTag : throwsTags) { ClassDoc exceptionDoc = throwsTag.exception(); if (exceptionDoc == null) { ERROR_REPORTER.printWarning("Unable to locate class '" + throwsTag.exceptionName() + "' for '" + memberDoc.qualifiedName() + "'"); continue; } printIndent(pw, 3); pw.print("<exception cref=\""); printReference(pw, exceptionDoc, true); pw.print("\">"); printComment(pw, memberDoc, throwsTag.inlineTags()); pw.println("</exception>"); } }
/** * Build the extern package list from given URL or the directory path. * Flag error if the "-link" or "-linkoffline" option is already used. * * @param url URL or Directory path. * @param pkglisturl This can be another URL for "package-list" or ordinary * file. * @param reporter The <code>DocErrorReporter</code> used to report errors. * @param linkoffline True if -linkoffline is used and false if -link is used. */ public boolean link(String url, String pkglisturl, DocErrorReporter reporter, boolean linkoffline) { this.linkoffline = linkoffline; try { url = adjustEndFileSeparator(url); if (isUrl(pkglisturl)) { readPackageListFromURL(url, toURL(adjustEndFileSeparator(pkglisturl))); } else { readPackageListFromFile(url, DocFile.createFileForInput(configuration, pkglisturl)); } return true; } catch (Fault f) { reporter.printWarning(f.getMessage()); return false; } }