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 org.jdrupes.mdoclet.MDoclet; 022 023import com.sun.javadoc.Tag; 024 025 026/** 027 * An abstraction for rendering tags. 028 */ 029public interface TagRenderer<T extends Tag> { 030 031 /** 032 * A do-nothing renderer. It just renders the tag without any processing. 033 */ 034 TagRenderer<Tag> VERBATIM = new TagRenderer<Tag>() { 035 @Override 036 public void render(Tag tag, StringBuilder target, MDoclet doclet) { 037 target.append(tag.name()).append(" ").append(tag.text()); 038 } 039 }; 040 /** 041 * A renderer that completely elides the tag. 042 */ 043 TagRenderer<Tag> ELIDE = new TagRenderer<Tag>() { 044 @Override 045 public void render(Tag tag, StringBuilder target, MDoclet doclet) { 046 // do nothing 047 } 048 }; 049 050 /** 051 * Render the tag to the given target {@link StringBuilder}. 052 * 053 * @param tag The tag to render. 054 * @param target The target {@link StringBuilder}. 055 * @param doclet The doclet. 056 */ 057 void render(T tag, StringBuilder target, MDoclet doclet); 058 059}