Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to color Javadoc comments

I'm starting to get quite a bit of code in my project, which is in Android Studio, and I'm trying to make sure that it's all very easy to understand. I'm leaving lots of Javadoc comments, but the thing is, they all look the same! It's always black text, or the occasional blue for a TODO or bold for a param, but the designer in me wants to be able to color the text to add that extra dimension of information. I'd love to be able to see a block of green and know right away that any code right below that has to do with the UI for instance, without having to read.

I couldn't find anything about Javadoc colors in any of the resources online, and I tried messing with the Android Studio preferences, but I could only change the color of ALL the Javadoc body text, not anything more specific.

like image 754
JCLaHoot Avatar asked Mar 19 '16 03:03

JCLaHoot


Video Answer


1 Answers

In Javadoc comments you can use a subset of the HTML tags, such as <b></b>, <i></i>, etc... In particular you can use the <font> tag and its color attribute to set the color in which your Javadoc text will be rendered. For instance:

/**
 * Some UI doc:
 * <p><font color="green">
 *   UI documentation and more ...
 *   <br>more ui ...
 * </font>
 * <p>And now some tech doc:
 * <p><font color="blue">
 *   Technical documentation this way ...
 *   <br>more tech ...
 * </font>
 */
public class Test {
  ...
}

will render like this in Android Studio:

enter image description here

like image 178
Lolo Avatar answered Oct 25 '22 22:10

Lolo