All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.exadatum.xsuite.xmaven.bash.doc.HtmlDocPageGenerator Maven / Gradle / Ivy

Go to download

Bash Maven Plugin is used to generate documentation as well as to run unit test for bash scripts.

The newest version!
package com.exadatum.xsuite.xmaven.bash.doc;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

/*-
 * #%L
 * Bash Plugin
 * %%
 * Copyright (C) 2016 - 2018 Exadatum Software Services Pvt. Ltd.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import htmlflow.HtmlView;
import htmlflow.elements.HtmlTable;
import htmlflow.elements.HtmlTr;

/**
 * Report generator using htmlflow.
 */
public class HtmlDocPageGenerator implements DocGenerator {

  /**
   * Extension for the html files.
   */
  private static final String HTML_EXTENSION = ".html";

  /**
   *
   * @param context
   *          {@link DocGeneratorContext} contains information about the
   *          template file, output file and the parsed document block objects
   *          to be used in generation.
   * @throws IOException
   */
  @Override
  public void generate(final DocGeneratorContext context) throws IOException {
    HtmlView> docListView = getDocListView();
    try (PrintStream out = new PrintStream(new FileOutputStream(
        context.getOutputPage().getAbsolutePath().concat(HTML_EXTENSION)))) {
      docListView.setPrintStream(out).write(context.getDocBlocks());
    }
  }

  /**
   * Generates the html body view for document.
   *
   * @return docListView
   */
  private HtmlView> getDocListView() {
    HtmlView> docListView = new HtmlView>();
    docListView.head().title("Bash Functions")
        .linkCss("https://maxcdn.bootstrapcdn.com/bootstrap/"
            + "3.3.6/css/bootstrap.min.css");

    HtmlTable> table = docListView.body()
        .classAttr("container").heading(1, "Bash Functions").div().table()
        .classAttr("table");
    HtmlTr> headerRow = table.tr();

    headerRow.th().text("Function/Constant");
    headerRow.th().text("Description");
    headerRow.th().text("Annotations");
    table.trFromIterable(DocBlock::getTarget, DocBlock::getDescription,
        DocBlock::getAnnotations);
    return docListView;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy