24

Is there a way to embed images into my JavaDoc? Basically i want to include some UML diagrams explaining the hierarchy of my classes in some of the documentation.

Thanks!

naXa stands with Ukraine
  • 35,493
  • 19
  • 190
  • 259
Mo .
  • 661
  • 2
  • 9
  • 17

7 Answers7

24

Check out this section of the Javadoc documentation, which explains how to embed images in your Javadoc.

Also, here is an article describing how to reverse engineer UML diagrams and embed them in your Javadoc using UMLGraph.

Invitor
  • 125
  • 1
  • 9
Adamski
  • 54,009
  • 15
  • 113
  • 152
8

Yes.

The documentation explains how to embed arbitrary images to javadoc documentation.

If you want to generate UML class diagrams from your Java source, have a look at the UMLGraph doclet.

Steve Siebert
  • 1,874
  • 12
  • 18
laalto
  • 150,114
  • 66
  • 286
  • 303
  • Also this article on using UML Graph http://java.dzone.com/articles/reverse-engineer-source-code-u – pjp Sep 11 '09 at 14:35
5

This article shows how to use UMLGraph with Maven Javadoc plugin.

In short:

  1. Install GraphViz.

    Ubuntu: apt-get install graphviz4.
    Windows: download.

  2. Update pom.xml.

        <plugin>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <aggregate>true</aggregate>
                <show>private</show>
                <doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
                <docletArtifact>
                    <groupId>org.umlgraph</groupId>
                    <artifactId>doclet</artifactId>
                    <version>5.1</version>
                </docletArtifact>
                <additionalparam>
                    -inferrel -attributes -types -visibility -inferdep -quiet -hide java.* -collpackages java.util.* -qualify -postfixpackage
                    -nodefontsize 9
                    -nodefontpackagesize 7
                </additionalparam>
            </configuration>
        </plugin>
    
  3. Run mvn javadoc:javadoc.

Ondra Žižka
  • 43,948
  • 41
  • 217
  • 277
  • 1
    Clearly the easiest approach! Should add a profile for building these so you don't break other ppl's builds that don't have GraphViz in the path. – Joseph Lust Aug 16 '13 at 17:49
3

ApiViz is a nice doclet too.

elhoim
  • 6,705
  • 2
  • 23
  • 29
3

Simple Answer:

/**
 * This class does some stuff (see diagram).
 * <img src="relative/path/to/image.png" />
 * 
 */
 public class SomeClass{
 }
Sileria
  • 15,223
  • 4
  • 49
  • 28
2

yDoc is an option

yegor256
  • 102,010
  • 123
  • 446
  • 597
0

This article explains how it can be done by placing your images in a folder accessible to the javadoc tool.

Steve Siebert
  • 1,874
  • 12
  • 18
Vincent Ramdhanie
  • 102,349
  • 23
  • 137
  • 192