net.sourceforge.taglets.demo.inline
Class SourceCode

java.lang.Object
  extended by net.sourceforge.taglets.demo.inline.SourceCode

public class SourceCode
extends Object

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:

Markup style
Preformatted text where HTML markup is left to the user. Also HTML markup has to be escaped by the user, i.e. you have to use &lt; in the JavaDoc comment to get a '<'.
Prettified style
Preformatted, literal text. HTML markup is escaped automatically and source code is formatted using a handy browser-side prettifier called Google Code Prettify.

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.

Version:
1.4 (2008/03/30 12:43:17)
Maintainer:
Bruno Essmann <essmann@sourceforge.net>
Since:
1.9.2

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

SourceCode

public SourceCode()
Method Detail

example

public void example()
Demo for the {@example} inline tag.

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.");
  }
}

Since:
1.8.2

markupExample

public void markupExample()
Demo for the {@markupExample} inline tag.

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.

Since:
1.9.2

source

public void source()
Demo for the {@source} inline tag.

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).

Since:
1.8.2

markupSource

public void markupSource()
Demo for the {@markupSource} message tag.

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.

Since:
1.9.2

at

public void at()
Demo for the {@at} inline tag.

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

Since:
2.0.3

annotation

public void annotation()
Demo for the {@annotation} inline tag.

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.");
  }
}

Since:
2.0.3


Taglets Collection 2.0.3 (Build 30)
2008/03/30 15:35:07
Copyright (c) 2002-2008 Bruno Essmann