001/* 002 * Copyright (c) 2012-2018 Institut National des Sciences Appliquées de Lyon (INSA Lyon) and others 003 * 004 * This program and the accompanying materials are made available under the 005 * terms of the Eclipse Public License 2.0 which is available at 006 * http://www.eclipse.org/legal/epl-2.0. 007 * 008 * SPDX-License-Identifier: EPL-2.0 009 */ 010 011package org.eclipse.golo.doc; 012 013import gololang.FunctionReference; 014import gololang.IO; 015 016import java.nio.file.Path; 017import java.util.Collection; 018 019public class MarkdownProcessor extends AbstractProcessor { 020 021 @Override 022 protected String fileExtension() { 023 return "markdown"; 024 } 025 026 @Override 027 public String render(ModuleDocumentation documentation) throws Throwable { 028 FunctionReference template = template("template", fileExtension()); 029 addModule(documentation); 030 return (String) template.invoke(documentation); 031 } 032 033 @Override 034 public void process(Collection<ModuleDocumentation> modules, Path targetFolder) throws Throwable { 035 setTargetFolder(targetFolder); 036 for (ModuleDocumentation doc : modules) { 037 IO.textToFile(render(doc), outputFile(doc.moduleName())); 038 } 039 renderIndex("index"); 040 } 041}