Custom Style for Javadocs in Eclipse

I found that I can add CSS styles to Javadocs in Eclipse to create nice effects for inline code.

Javadoc example:

/** * <p>This is a general description of the class.<p> * * <p>Here is a useful direct quote:</p> * * <div style="background-color:white; border: 1px solid gray; margin: 1em 2.5em; padding: 0em 0.5em"> * <p>This quote has a list:</p> * <ul> * <li>Item 1</li> * <li>Item 2</li> * </ul> * </div> * */ public class SSCCE { } 

Example result: Javadoc hover example

I would like to take advantage of this more in my code, but it would be much better if I could use something like <div class="box"> instead of setting the style attribute manually for the following reasons:

  • If later I decide to change the style, I may have to change hundreds of Javadoc comments.
  • At the moment, I only care about appearance in Eclipse. However, if I ever export Javadocs to HTML, I may need the HTML version to have a different style than the Eclipse version.

Is it possible to do this in Eclipse, possibly with a plugin?

+4
source share
2 answers

Through an experiment, I discovered that I could reference a stylesheet using the <link> with href relative to the location of the .java file. This relates to question No. 1, mentioned in the question, but personally I think that it is too bulky and probably will not use it. He also does not solve problem No. 2 (if anything, this makes it worse).

I am still open to suggestions for the best solutions! I suspect that the full implementation of what I really want to do will require the Eclipse plugin.

[project root] /src/org/foobar/Foo.java:

 package org.foobar; /** * <link rel="stylesheet" type="text/css" href="../../../javadoc.css"/> * * <p class="orange">Foo doc, in orange</p> */ public class Foo { } 

[root project] /javadoc.css

 p.orange { color: orange; } 
+2
source

I think that when you get to the JavaDoc-style export part, you can use this Java tool. Also check out this book , which can help in defining style sheets for javadoc in Eclipse. And maybe you can also create your own doc generation plugin.

+1
source

All Articles