001/*
002 * JDrupes MDoclet
003 * Copyright 2013 Raffael Herzog
004 * Copyright (C) 2017 Michael N. Lipp
005 * 
006 * This program is free software; you can redistribute it and/or modify it 
007 * under the terms of the GNU General Public License as published by 
008 * the Free Software Foundation; either version 3 of the License, or 
009 * (at your option) any later version.
010 * 
011 * This program is distributed in the hope that it will be useful, but 
012 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
013 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
014 * for more details.
015 * 
016 * You should have received a copy of the GNU General Public License along 
017 * with this program; if not, see <http://www.gnu.org/licenses/>.
018 */
019package org.jdrupes.mdoclet.renderers;
020
021import static org.jdrupes.mdoclet.renderers.TagRendering.*;
022
023import org.jdrupes.mdoclet.MDoclet;
024
025import com.sun.javadoc.ParamTag;
026
027
028/**
029 * Renderer for `@param` tags.
030 */
031public class ParamTagRenderer implements TagRenderer<ParamTag> {
032
033    public static final ParamTagRenderer INSTANCE = new ParamTagRenderer();
034
035    @Override
036    public void render(ParamTag tag, StringBuilder target, MDoclet doclet) {
037        target.append(tag.name())
038                .append(' ').append(renderParameterName(tag))
039                .append(' ').append(simplifySingleParagraph(doclet.toHtml(tag.parameterComment())));
040    }
041
042    private static String renderParameterName(ParamTag tag) {
043        if (!tag.isTypeParameter()) {
044            return tag.parameterName();
045        }
046        else {
047            return '<' + tag.parameterName() + '>';
048        }
049    }
050}