2

Is there a way to include an image in the class javadoc that is local in an Android project using Android Studio?

I would like to add a diagram to clarify the workings of a class. My structure is as follows:

src/main/com.exampe.project/Class.java
docs/images/Diagram.png

Now I would like to add javadoc to the class, linking to Diagram.png.

My code now looks something like this:

/**
 * <img src="docs/images/Diagram.png">
 */
public class Class {

However, the javadoc linking does not work. Is there any way to show the image in the javadoc?

Update:

Apparently, you can use the docroot attribute, but this does not work for the current version of Android Studio. When I change the javadoc to

/**
 * <a href="{@docRoot}docs/images/Diagram.png">link</a>
 */
public class Class {

and click on the link, it can not find the file, because it points to /Applications/Android Studio.app/bin/../../../../docs/images/Diagram.png. It appears Android Studio searches for the image in the install directory of the program, instead of the root of the project. (this is on a mac)

MIJkema
  • 41
  • 5
  • 1
    This should help you : http://stackoverflow.com/questions/2903042/adding-images-into-source-code – Arnaud Denoyelle Jul 09 '14 at 15:15
  • possible duplicate of [Images in Javadoc with IntelliJ Idea](http://stackoverflow.com/questions/25382586/images-in-javadoc-with-intellij-idea) – Suma Jul 21 '15 at 06:54

1 Answers1

1

with comment as:

/**
 * <img src="../../../images/Diagram.png"/>
 */

In the case of source with CLASSPATH=src/main/ and code in:
src/main/com/exampe/project/Class.java (java class after 3 directories)

and Java documentation in doc/
docs/images/Diagram.png

Then the output of java doc is here: docs/com/example/project/Class.html

Kevin Nagurski
  • 1,889
  • 11
  • 24
Trucomanx
  • 11
  • 2