private static boolean validOption(final String optionName, final String reportOptionName, final String[][] options, final DocErrorReporter reporter) { final String option = getOptionArg(options, optionName); final boolean foundOption = option != null && !option.trim().isEmpty(); if (!foundOption) { reporter.printError(optionName + " " + reportOptionName + " must be specified."); } return foundOption; }
if (!destDir.exists()) { reporter.printNotice(getText("doclet.dest_dir_create", destdirname)); (new File(destdirname)).mkdirs(); } else if (!destDir.isDirectory()) { reporter.printError(getText( "doclet.destination_directory_not_directory_0", destDir.getPath())); return false; } else if (!destDir.canWrite()) { reporter.printError(getText( "doclet.destination_directory_not_writable_0", destDir.getPath()));
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); } });
public static boolean validOptions(String[][] options, DocErrorReporter reporter) { boolean sawOutput = false; for (int i = 0; i < options.length; i++) { String[] option = options[i]; if (option[0].equals("-output")) { File output = new File(option[1]); if (output.exists() && output.isDirectory()) { reporter.printError("Output file " + output + " is a directory"); return false; } else { sawOutput = true; } } } if (!sawOutput) { reporter.printError("Missing -output"); return false; } return true; }
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; } }
public static boolean validOptions(String[][] options, DocErrorReporter reporter) { boolean foundTagOption = false; for (int i = 0; i < options.length; i++) { String[] opt = options[i]; if ("-dumpJavaDocFile".equals(opt[0])) { if (foundTagOption) { reporter.printError("Only one -dumpJavaDocFile option allowed."); return false; } foundTagOption = true; } } if (!foundTagOption) { reporter.printError("Usage: -dumpJavaDocFile theFileToDumpJavaDocForLatarUse..."); } return foundTagOption; } }
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 reporter) { boolean foundTagOption = false; for (int i = 0; i < options.length; i++) { String[] opt = options[i]; if ("-dumpJavaDocFile".equals(opt[0])) { if (foundTagOption) { reporter.printError("Only one -dumpJavaDocFile option allowed."); return false; } foundTagOption = true; } } if (!foundTagOption) { reporter.printError("Usage: -dumpJavaDocFile theFileToDumpJavaDocForLatarUse..."); } return foundTagOption; } }
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); }
public static boolean validOptions(String options[][], DocErrorReporter reporter) { boolean foundFileNameOption = false; for (String[] opt : options) { if (opt[0].equals("-filename")) { if (foundFileNameOption) { reporter.printError("Only one -tag option allowed."); return false; } else { foundFileNameOption = true; } } } if (!foundFileNameOption) { reporter.printError("Usage: javadoc -filename file -artifactId bla -groupId de -version blabla-0.1 -classdir dir..."); } return foundFileNameOption; }
/** * 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; } }
public void fatalError(SAXParseException e) throws SAXException { ERROR_REPORTER.printError(e.getMessage()); ERROR_REPORTER.printError("Line: " + e.getLineNumber() + ", Column: " + e.getColumnNumber()); throw e; } });
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; }
public static boolean validOptions(String options[][], DocErrorReporter reporter) { boolean hasOut = false; for (String[] option : options) { String opt = option[0]; if (opt.equals("-out")) { hasOut = true; } } if (!hasOut) { reporter.printError("No output file specified: -out <output file>"); return false; } else { return true; } } }
/** * 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() + "'"); } }
public static boolean validOptions(String options[][], DocErrorReporter reporter) { boolean hasOut = false; for (String[] option : options) { String opt = option[0]; if (opt.equals("-out")) { hasOut = true; } } if (!hasOut) { reporter.printError("No output file specified: -out <output file>"); return false; } else { return true; } } }
/** * 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); } } }
public static boolean validOptions(String options[][], DocErrorReporter reporter) { boolean hasOut = false; for (String[] option : options) { String opt = option[0]; if (opt.equals("-out")) { hasOut = true; } } if (!hasOut) { reporter.printError("No output file specified: -out <output file>"); return false; } else { return true; } } }
ERROR_REPORTER.printWarning("Invalid anchor '" + text + "' for '" + memberDoc.qualifiedName() + "'"); ERROR_REPORTER.printWarning("Unable to locate reference '" + text + "' for '" + memberDoc.qualifiedName() + "'");