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

info.bliki.wiki.template.extension.Allmacros Maven / Gradle / Ivy

The newest version!
package info.bliki.wiki.template.extension;

import info.bliki.wiki.model.IWikiModel;
import info.bliki.wiki.template.AbstractTemplateFunction;
import info.bliki.wiki.template.ITemplateFunction;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * A template parser function for {{ #all_macros: ... }} syntax.
 * The function lists all available template functions documentation. To show
 * the documentation of a function, the ITemplateFunction#getFunctionDoc() must
 * be implemented.
 *
 * This function isn't included in the default parser functions map. Use
 * Configuration.addTemplateFunction("#all_macros", Allmacros.CONST)
 * to add the template to your configuration.
 */
public class Allmacros extends AbstractTemplateFunction {
    public final static ITemplateFunction CONST = new Allmacros();

    public Allmacros() {

    }

    @Override
    public String getFunctionDoc() {
        return "Returns all macros";
    }

    @Override
    public String parseFunction(List parts, IWikiModel model, char[] src, int beginIndex, int endIndex, boolean isSubst) throws IOException {
        Map t = model.getTemplateMap();
        StringBuilder sb = new StringBuilder(16);
        String doc;
        sb.append("");
        for (Map.Entry e : t.entrySet()) {
            sb.append("");
        }
        sb.append("
Template nameImplemented in classDescription
"); sb.append(e.getKey()); sb.append(""); ITemplateFunction tf = e.getValue(); Class cl1 = tf.getClass().getEnclosingClass(); if (cl1 == null) cl1 = tf.getClass(); String s1 = cl1.getCanonicalName(); sb.append(s1); sb.append(""); doc = tf.getFunctionDoc(); if (doc == null) { sb.append("No documentation available"); } else { sb.append(doc); } sb.append("
"); return sb.toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy