5

So I have a javadoc that looks like this (censored for the public of course):

/**
 * Description of my method
 * <p>
 * <b>Example:</b>
 * </p>
 * <pre>
 * {@code
 * /**
 *  * Sample Javadoc
 *  *&#47;
 *  public final void testMyMethod()
 *  &#123;
 *      // some logic
 * &#125;}
 * </pre>
 * @return Description of my return value.
 */

So the reason for this is that doing */ in my example will end the javadoc. Having the braces confuses the @code tag.

The problem is that the generated javadoc shows the HTML entities codes instead of the actual character that I want to display to the consumers of my javadoc. Any ideas on how I can get around this?

Jason Thompson
  • 4,643
  • 5
  • 50
  • 74
  • 1
    @RC. Disagree entirely - that question is easily resolved using HTML escape characters, this is an entirely different problem that *cannot* be resolved in that way (because of the nature of the `{@code` tag. – Michael Berry Feb 28 '14 at 18:22

1 Answers1

3

There's no real way to do this unfortunately (at least not that I know of.) I've been stung by this in the past and it's really rather annoying!

The two workarounds (neither is great) that sort-of get the right approach are:

  • Closing and reopening the code tag to exclude the annoying characters (so doing }&#47;{@code)

  • Ditching {@code altogether and just using the old fashioned <code> tags.

Personally I'd favour the last approach because it's a bit neater and (presumably) easier to convert later if a fix ever arrives - but it's not ideal.

Michael Berry
  • 70,193
  • 21
  • 157
  • 216