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