use of org.wso2.siddhi.doc.gen.core.freemarker.FormatDescriptionMethod in project siddhi by wso2.
the class DocumentationUtils method generateDocumentation.
/**
* Generate documentation related files using metadata
*
* @param namespaceMetaDataList Metadata in this repository
* @param documentationBaseDirectory The path of the directory in which the documentation will be generated
* @param documentationVersion The version of the documentation being generated
* @param logger The logger to log errors
* @throws MojoFailureException if the Mojo fails to find template file or create new documentation file
*/
public static void generateDocumentation(List<NamespaceMetaData> namespaceMetaDataList, String documentationBaseDirectory, String documentationVersion, Log logger) throws MojoFailureException {
// Generating data model
Map<String, Object> rootDataModel = new HashMap<>();
rootDataModel.put("metaData", namespaceMetaDataList);
rootDataModel.put("formatDescription", new FormatDescriptionMethod());
rootDataModel.put("latestDocumentationVersion", documentationVersion);
String outputFileRelativePath = Constants.API_SUB_DIRECTORY + File.separator + documentationVersion + Constants.MARKDOWN_FILE_EXTENSION;
generateFileFromTemplate(Constants.MARKDOWN_DOCUMENTATION_TEMPLATE + Constants.MARKDOWN_FILE_EXTENSION + Constants.FREEMARKER_TEMPLATE_FILE_EXTENSION, rootDataModel, documentationBaseDirectory, outputFileRelativePath);
File newVersionFile = new File(documentationBaseDirectory + File.separator + outputFileRelativePath);
File latestLabelFile = new File(documentationBaseDirectory + File.separator + Constants.API_SUB_DIRECTORY + File.separator + Constants.LATEST_FILE_NAME + Constants.MARKDOWN_FILE_EXTENSION);
try {
Files.copy(newVersionFile, latestLabelFile);
} catch (IOException e) {
logger.warn("Failed to generate latest.md file", e);
}
}
use of org.wso2.siddhi.doc.gen.core.freemarker.FormatDescriptionMethod 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());
}
Aggregations