Search in sources :

Example 6 with NamespaceMetaData

use of org.wso2.siddhi.doc.gen.commons.metadata.NamespaceMetaData in project siddhi by wso2.

the class DocumentationUtils method updateHeadingsInMarkdownFile.

/**
 * Update the documentation home page
 *
 * @param inputFile                  The path to the input file
 * @param outputFile                 The path to the output file
 * @param extensionRepositoryName    The name of  the extension repository
 * @param latestDocumentationVersion The version of the latest documentation generated
 * @param namespaceMetaDataList      Metadata in this repository
 * @throws MojoFailureException if the Mojo fails to find template file or create new documentation file
 */
public static void updateHeadingsInMarkdownFile(File inputFile, File outputFile, String extensionRepositoryName, String latestDocumentationVersion, List<NamespaceMetaData> namespaceMetaDataList) throws MojoFailureException {
    // Retrieving the content of the README.md file
    List<String> inputFileLines = new ArrayList<>();
    try {
        inputFileLines = Files.readLines(inputFile, Constants.DEFAULT_CHARSET);
    } catch (IOException ignored) {
    }
    // Generating data model
    Map<String, Object> rootDataModel = new HashMap<>();
    rootDataModel.put("inputFileLines", inputFileLines);
    rootDataModel.put("extensionRepositoryName", extensionRepositoryName);
    rootDataModel.put("latestDocumentationVersion", latestDocumentationVersion);
    rootDataModel.put("metaData", namespaceMetaDataList);
    rootDataModel.put("formatDescription", new FormatDescriptionMethod());
    generateFileFromTemplate(Constants.MARKDOWN_HEADINGS_UPDATE_TEMPLATE + Constants.MARKDOWN_FILE_EXTENSION + Constants.FREEMARKER_TEMPLATE_FILE_EXTENSION, rootDataModel, outputFile.getParent(), outputFile.getName());
}
Also used : HashMap(java.util.HashMap) FormatDescriptionMethod(org.wso2.siddhi.doc.gen.core.freemarker.FormatDescriptionMethod) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Aggregations

File (java.io.File)4 NamespaceMetaData (org.wso2.siddhi.doc.gen.commons.metadata.NamespaceMetaData)4 HashMap (java.util.HashMap)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)2 MavenProject (org.apache.maven.project.MavenProject)2 ExtensionMetaData (org.wso2.siddhi.doc.gen.commons.metadata.ExtensionMetaData)2 FormatDescriptionMethod (org.wso2.siddhi.doc.gen.core.freemarker.FormatDescriptionMethod)2 FileNotFoundException (java.io.FileNotFoundException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 Scm (org.apache.maven.model.Scm)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 Example (org.wso2.siddhi.annotation.Example)1 Extension (org.wso2.siddhi.annotation.Extension)1