Exemple #1
0
  private void runCompiler() {
    if (!shouldRunCompiler()) {
      System.exit(-1);
    }

    Instant start = Instant.now();
    config.getOutputStream().println("Generating documentation...");

    int result = 0;
    try {
      result = doRun();
    } catch (FlagUsageException e) {
      System.err.println(e.getMessage());
      System.exit(-1);
    } catch (Throwable t) {
      t.printStackTrace(System.err);
      System.exit(-2);
    }

    if (result != 0) {
      System.exit(result);
    }

    DocWriter writer =
        new DocWriter(
            config.getOutput(),
            Iterables.concat(config.getSources(), config.getModules()),
            config.getSrcPrefix(),
            config.getReadme(),
            config.getCustomPages(),
            typeRegistry,
            config.getTypeFilter(),
            new Linker(
                config.getOutput(),
                config.getSrcPrefix(),
                config.getModulePrefix(),
                config.getTypeFilter(),
                typeRegistry),
            new CommentParser(config.useMarkdown()));
    try {
      writer.generateDocs();
      if (config.isZipOutput()) {
        config.getOutput().getFileSystem().close();
      }
    } catch (IOException e) {
      e.printStackTrace(System.err);
      System.exit(-3);
    }

    Instant stop = Instant.now();
    String output =
        new PeriodFormatterBuilder()
            .appendHours()
            .appendSuffix("h") // I hope not...
            .appendSeparator(" ")
            .appendMinutes()
            .appendSuffix("m")
            .appendSeparator(" ")
            .appendSecondsWithOptionalMillis()
            .appendSuffix("s")
            .toFormatter()
            .print(new Period(start, stop));

    config.getOutputStream().println("Finished in " + output);
  }