Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

syntax highlighting for javadoc?

Currently I format code examples in my javadoc using the PRE tag e.g.:

/**
 * Example javadoc
 * 
<pre>
String foo = "bar";
</pre>
 *
 * @return   true if the operation completed
 */

But this turns out rather monotone and boring in the resulting javadoc, I'd much rather have some syntax highlighting similar to SyntaxHighlighter.

How can this be done?

like image 854
Supertux Avatar asked Sep 08 '09 02:09

Supertux


People also ask

What is the syntax for a Javadoc documentation?

In general, Javadoc comments are any multi-line comments (" /** ... */ ") that are placed before class, field, or method declarations. They must begin with a slash and two stars, and they can include special tags to describe characteristics like method parameters or return values.

What should be included in a Javadoc?

Before using JavaDoc tool, you must include JavaDoc comments /**……………….. */ providing information about classes, methods, and constructors, etc. For creating a good and understandable document API for any java file you must write better comments for every class, method, constructor.

What is Javadoc give example?

Javadoc is a tool which comes with JDK and it is used for generating Java code documentation in HTML format from Java source code, which requires documentation in a predefined format. Following is a simple example where the lines inside /*…. */ are Java multi-line comments.

What symbols mark the beginning and end of Javadoc comments?

The single line comment is //. Everything from the // to the end of the line is a comment. To mark an entire region as a comment, use /* to start the comment and */ to end the comment.


2 Answers

You can use jQuery to get it done using the beautyOfCode plugin. I'm not sure if there's an easy way to hook into the javadoc generation, but after-the-fact you can just do the following in your header:

$(function(){  
    $("pre").beautifyCode('java');  
});

and all text inside PRE tags will be highlighted as java. Check out the links above for more info.

like image 163
Mike Trpcic Avatar answered Oct 03 '22 20:10

Mike Trpcic


Another option is to use pegdown-doclet, which lets you use Github-style fenced code blocks.

```java
public static class Example {}
```
like image 25
Ned Twigg Avatar answered Oct 03 '22 20:10

Ned Twigg