|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.taglets.demo.inline.SourceCode
public class SourceCode
Demonstration of source code inline tags.
This demo class contains examples for the various preformatted inline tags offered by the default configuration of the Taglets Collection.
The preformatted inline tags are mainly used to include snippets of source code in your JavaDoc comments and come in two flavours:
Note:
As of JSE 5 the standard JavaDoc doclet also offers two inline tags that are handy for describing source code, {@code} and {@literal}. The tags offered by the default configuration of the Taglets Collection are rendered in a framed box and are available starting at J2SE 1.4 JavaDoc.
Constructor Summary | |
---|---|
SourceCode()
|
Method Summary | |
---|---|
void |
annotation()
Demo for the {@annotation} inline tag. |
void |
at()
Demo for the {@at} inline tag. |
void |
example()
Demo for the {@example} inline tag. |
void |
markupExample()
Demo for the {@markupExample} inline tag. |
void |
markupSource()
Demo for the {@markupSource} message tag. |
void |
source()
Demo for the {@source} inline tag. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SourceCode()
Method Detail |
---|
public void example()
The {@example} inline tag denotes literal, preformatted text. Its contents is rendered using the HTML <pre> tag and all HTML markup is properly converted. This makes the tag perfectly suited for code snippets.
The tag syntax is {@example source code} which will yield an example tag with the default title "Example:"
Example:
Simple @{at example} inline tag.
Or if you want a custom title use {@example "title" source code}:
Sample Usage
public void codeSnippet (boolean funny) { if (funny) { System.out.println("Funny!"); } else { System.out.println("Not funny."); } }
public void markupExample()
Markup Example Tag
{@markupExample} inline tag. Similar to the {@example} tag, but is not literal or prettified, i.e. you can use HTML tags inside like <em/>, <strong/>, or colors: Dark red text.
public void source()
The {@source} inline tag denotes literal, preformatted text. Its contents is rendered using the HTML <pre> tag and all HTML markup is properly converted. This makes the tag perfectly suited for code snippets.
The tag syntax is {@source source code} which will yield an source tag without title:
Simple @source inline tag.
Or if you want a title use {@source "title" source code}:
Sample Source
@myAnnotation public void codeSnippet (boolean funny) { if (funny) { System.out.println("Funny}!"); } else { System.out.println("Not funny."); }
To use the '@' sign in the source code either use the inline tag {@annotation} for annotations (the example above uses {@annotation myAnnotation}) or use the inline tag {@at}, they are equivalent (e.g. using {@at} without text will simply produce the '@' sign in the javadoc).
public void markupSource()
Markup Source Tag
{@markupSource} inline tag. Similar to the {@source} tag, but not literal or prettified, i.e. you can use HTML tags inside like <em/>, <strong/>, or colors: Dark red text.
public void at()
Sometimes you might want to include an at sign '@' in an inline tag like {@example}. However you cannot simply write {@example foo @bar quux} since JavaDoc will try to evaluate @bar as tag. Instead write {@example foo {@bar} quux}.
Example:
foo @{at bar} quux
public void annotation()
To include annotations in your source inline tags convert them
using the {@annotation} inline tag. This tag
works just like the at()
inline tag, except that it has
a different name which implies that it's used to mark an annotation.
Sample Source
@myAnnotation public void codeSnippet (boolean funny) { if (funny) { System.out.println("Funny}!"); } else { System.out.println("Not funny."); }
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Taglets Collection 2.0.3 (Build 30)
2008/03/30 15:35:07
Copyright (c) 2002-2008 Bruno Essmann