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; }
public static boolean validOptions(String[][] options, DocErrorReporter reporter) { for (int i = 0 ; i < options.length; i++) { String opt = options[i][0].trim(); switch (opt) { case "-genErrors": genErrors = true; genWarnings = false; break; case "-genWarnings": genErrors = false; genWarnings = true; break; } } return true; }
/** * Checks that only valid options was specified. * @param options all parsed options * @param reporter the reporter to report errors. * @return true if only valid options was specified */ public static boolean checkOptions(String[][] options, DocErrorReporter reporter) { boolean foundDestFileOption = false; boolean onlyOneDestFileOption = true; for (final String[] opt : options) { if (DEST_FILE_OPT.equals(opt[0])) { if (foundDestFileOption) { reporter.printError("Only one -destfile option allowed."); onlyOneDestFileOption = false; break; } foundDestFileOption = true; } } if (!foundDestFileOption) { reporter.printError("Usage: javadoc -destfile file -doclet TokenTypesDoclet ..."); } return onlyOneDestFileOption && foundDestFileOption; }
/** Specified for the Doclet API */ public static boolean validOptions( String[][] options, DocErrorReporter reporter) { ImmutableList.Builder<String[]> optionsForStandardDoclet = ImmutableList.builder(); boolean ok = true; for (String[] optionArr : options) { OptionName on = OPTION_NAMES.get(optionArr[0]); if (on == null) { optionsForStandardDoclet.add(optionArr); } else { ok &= on.isValid(optionArr, reporter); } } ok &= Standard.validOptions( optionsForStandardDoclet.build().toArray(new String[0][]), reporter); return ok; }
public static boolean validOptions(String options[][], DocErrorReporter reporter) { boolean foundOutput = false; boolean foundTemplate = false; for (int i = 0; i < options.length; i++) { String[] opt = options[i]; if (opt[0].equals("-o")) { foundOutput = true; output = opt[1]; } else if (opt[0].equals("-ft")) { foundTemplate = true; template = new FileTemplateOption(opt[1]); } else if (opt[0].equals("-ct")) { foundTemplate = true; template = new ClasspathTemplateOption(opt[1]); } } if (!foundOutput || !foundTemplate) { reporter.printError("Usage: javadoc -o OUTPUT_FILE -t TEMPLATE_FILE ..."); return false; } return true; }
private Options buildOptions(DocletOptions docletOptions, DocErrorReporter errorReporter) { OptionsBuilder opts = defaultOptions(); if (docletOptions.baseDir().isPresent()) { opts.baseDir(docletOptions.baseDir().get()); } if (templates.isPresent()) { opts.templateDir(templates.get().templateDir()); } opts.attributes(buildAttributes(docletOptions, errorReporter)); if (docletOptions.requires().size() > 0) { for (String require : docletOptions.requires()) { asciidoctor.rubyExtensionRegistry().requireLibrary(require); } } return opts.get(); }
public static void validOptions(String[][] options, DocErrorReporter reporter) { for (int i = 0; i < options.length; i++) { String opt = options[i][0].toLowerCase(Locale.ENGLISH); if (opt.equals(UNSTABLE_OPTION)) { RootDocProcessor.stability = UNSTABLE_OPTION; } else if (opt.equals(EVOLVING_OPTION)) { RootDocProcessor.stability = EVOLVING_OPTION; } else if (opt.equals(STABLE_OPTION)) { RootDocProcessor.stability = STABLE_OPTION; } } }
public static void validOptions(String[][] options, DocErrorReporter reporter) { for (int i = 0; i < options.length; i++) { String opt = options[i][0].toLowerCase(); if (opt.equals(UNSTABLE_OPTION)) { RootDocProcessor.stability = UNSTABLE_OPTION; } else if (opt.equals(EVOLVING_OPTION)) { RootDocProcessor.stability = EVOLVING_OPTION; } else if (opt.equals(STABLE_OPTION)) { RootDocProcessor.stability = STABLE_OPTION; } } }
public static boolean validOptions(final String[][] options, final DocErrorReporter reporter) { System.out.println("VALIDATING OPTIONS"); final Options opt = new Options(options); if ((opt.factoryNames.size() == 0) || (opt.outputPath == null)) { reporter.printError("Usage: -factory com.example.MyClass -destDir <outputFolder> [ -json ] [ -nohtml ]"); return false; } return true; }
/** * Valid options boolean. * * @param options the options * @param reporter the reporter * @return the boolean */ public static boolean validOptions(final String[][] options, final DocErrorReporter reporter) { try { Options.validate(options); } catch (IllegalStateException e) { log.debug(e.getMessage(), e); reporter.printError(e.getMessage()); return false; } return true; }
@Before public void setUp() { mockReporter = Mockito.mock(DocErrorReporter.class); UMLDocletConfig config = new UMLDocletConfig(new String[0][], mockReporter); renderer = new YabadabadooRenderer(new DiagramRenderer(config)); }
@Test public void testSplitDefaultValue() { UMLDocletConfig config = new UMLDocletConfig(new String[0][], mock(DocErrorReporter.class)); assertThat(config.excludedReferences(), is(equalTo((Collection<String>) asList( Object.class.getName(), Enum.class.getName(), Annotation.class.getName() )))); }
@Test public void testSplitMultipleOccurrances() { UMLDocletConfig config = new UMLDocletConfig(new String[][]{ {"-umlExcludedReferences", Object.class.getName()}, {"-umlExcludedReferences", Enum.class.getName()} }, mock(DocErrorReporter.class)); assertThat(config.excludedReferences(), is(equalTo((Collection<String>) asList( Object.class.getName(), Enum.class.getName() )))); }
@Test public void testIssue37_packagePrivateClassesDefaultValue() { UMLDocletConfig config = new UMLDocletConfig(new String[0][], mock(DocErrorReporter.class)); ClassDoc packagePrivateClassDoc = mock(ClassDoc.class); when(packagePrivateClassDoc.isPackagePrivate()).thenReturn(true); when(packagePrivateClassDoc.tags(anyString())).thenReturn(new Tag[0]); when(packagePrivateClassDoc.annotations()).thenReturn(new AnnotationDesc[0]); assertThat(config.includeClass(packagePrivateClassDoc), is(false)); }
public static boolean validOptions(String options[][], DocErrorReporter reporter) throws IOException { for (int i = 0; i < options.length; i++) { String[] opt = options[i]; if (opt[0].equals("-template")) { out = new PrintStream(opt[1]); } } return true; }
public HtmlRepairer(DocErrorReporter warningReporter, boolean noWarn, boolean noEmailWarn, ClassDoc contextClass, MemberDoc contextMember, boolean throwAwayLeadingPara) { this.warningReporter = warningReporter; this.noWarn = noWarn; this.noEmailWarn = noEmailWarn; this.contextClass = contextClass; this.contextMember = contextMember; this.throwAwayLeadingPara = throwAwayLeadingPara; }
public static boolean validOptions(java.lang.String[][] options, DocErrorReporter rep) { assert options != null; assert rep != null; for (int i = 0; i < options.length; ++i) { if (options[i][0].equalsIgnoreCase(OPT_SOURCE_ROOT)) { if (s_TargetRootDirectory == null) s_TargetRootDirectory = options[i][1]; else s_Logger.warn("Ignoring additional definition of '" + options[i][0] + "' with argument '" + options[i][1] + "'"); } } if (s_TargetRootDirectory == null) { s_Logger.fatal("Source root directory required (-evf_sourceroot <dir>)"); return false; } else { return true; } }
public static boolean validOptions(String[][] options, DocErrorReporter reporter) { final Set<String> supportedOptions = new HashSet<>(asList(OPTION_OUTPUT, OPTION_PROPERTIES, OPTION_TITLE)); final Set<String> optionsFound = new HashSet<>(); boolean valid = true; for (String[] option : options) { final String name = option[0]; if (supportedOptions.contains(name)) { if (optionsFound.contains(name)) { reporter.printError("Only one " + name + " option allowed."); valid = false; } optionsFound.add(name); final String value = option[1]; if (name.equals(OPTION_OUTPUT)) { valid = valid && verifyOutputFile(value, reporter); } else if (name.equals(OPTION_PROPERTIES)) { valid = valid && verifyPropertiesFile(value, reporter); } else if (name.equals(OPTION_TITLE)) { valid = valid && verifyTitle(value); } } } if (!optionsFound.contains(OPTION_OUTPUT)) { reporter.printError("Missing required property -output"); return false; } return valid; }
private static boolean verifyOutputFile(String filename, DocErrorReporter reporter) { final File file = new File(filename); if (file.exists() && file.isDirectory()) { reporter.printError("Output file " + filename + " is a directory."); return false; } if (file.exists() && !file.canWrite()) { reporter.printError("Output file " + filename + " exists and cannot be overwritten."); return false; } outputFile = file; return true; }
private static boolean verifyPropertiesFile(String propertiesFile, DocErrorReporter reporter) { try (FileReader fileReader = new FileReader(propertiesFile); BufferedReader reader = new BufferedReader(fileReader)) { properties = new Properties(); properties.load(reader); } catch (IOException e) { reporter.printError("Couldn't load properties from " + propertiesFile); return false; } return true; }
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; } }
/** * Parse command line options. * * @param options command line options to parse * @param reporter error reporter * @return true if options are valid. */ public boolean parseOptions(String[][] options, DocErrorReporter reporter) { boolean valid = true; for (String[] option : options) { switch (option[0].toLowerCase()) { case "-t" : valid = setTitle(option[1], reporter); break; case "-d": valid = setOutputDir(option[1], reporter); break; case "-docsourcepath": valid = setDocSourcePaths(option[1], reporter); break; case "-includepath": valid = setIncludeCodePaths(option[1], reporter); break; case "-link": valid = addLinkProvider(option[1], reporter); break; case "-linkoffline": valid = addLinkProvider(option[1], option[2], reporter); break; } if (!valid) { return false; } } if (outputDir == null) { reporter.printError("Output directory not defined."); return false; } if (projectDocSrcDirs == null) { reporter.printError("Project documentation source directories not defined."); return false; } return true; }
private boolean setOutputDir(String outputDirName, DocErrorReporter reporter) { outputDir = Paths.get(outputDirName); if (Files.exists(outputDir)) { return Files.isDirectory(outputDir); } else { try { Files.createDirectories(outputDir); } catch (IOException e) { reporter.printError("Error creating output directory " + outputDirName + ". " + e.getMessage()); return false; } } return true; }
private boolean setDocSourcePaths(String paths, DocErrorReporter reporter) { projectDocSrcDirs = new ArrayList<>(); for (String path : paths.split(File.pathSeparator)) { projectDocSrcDirs.add(Paths.get(path)); } return projectDocSrcDirs.size() > 0; }
private boolean setIncludeCodePaths(String paths, DocErrorReporter reporter) { includeCodeDirs = new ArrayList<>(); for (String path : paths.split(File.pathSeparator)) { includeCodeDirs.add(Paths.get(paths)); } return includeCodeDirs.size() > 0; }
private boolean addLinkProvider(String url, DocErrorReporter reporter) { try { externalRefProviders.add(new ExternalRefProvider(url)); return true; } catch (IOException e) { reporter.printWarning("Unable to load link for " + url + ". " + e.getMessage()); return false; } }
private boolean addLinkProvider(String url, String packageListUrl, DocErrorReporter reporter) { try { externalRefProviders.add(new ExternalRefProvider(url, packageListUrl)); return true; } catch (IOException e) { reporter.printWarning("Unable to load linksoffline for " + packageListUrl + ". " + e.getMessage()); return false; } }
public static boolean validOptions(String[][] options, DocErrorReporter r) { for (String[] a : options) { if (a[0].equals("-error") || a[0].equals("-warning") || a[0].equals("-hide")) { try { Integer.parseInt(a[1]); } catch (NumberFormatException e) { r.printError("bad -" + a[0] + " value must be a number: " + a[1]); return false; } } } return true; }