Including images in javadocs

后端 未结 7 1929
北海茫月
北海茫月 2020-12-14 16:26

I work with a lot of sample test cases that are visual. Is there any convenient way to include them in my Java source and link them in Javadocs, so my IDE can automatically

7条回答
  •  囚心锁ツ
    2020-12-14 16:57

    To expand a little on Paŭlo's answer assuming a maven build here is what worked for me with JDK-8 (stricter HTML validation), with the stipulation that you're willing to run the javadoc tool.

    Unfortunately with Netbeans I cannot see the image in the IDE's javadoc popup, I just opened this netbeans bug.

    Assume this is part of the javadoc for com.foo.File.java (notice no img end tag, which is the right way per w3schools):

    Foo
    

    In the maven directory structure you'll find the image here: src/main/javadoc/com/foo/doc-files/foo.png

    And last, in the pom.xml (notice docfilessubdirs is set to true):

    
        
            
                org.apache.maven.plugins
                maven-javadoc-plugin
                2.10.3
                
                    true
                
            
            ...
    

提交回复
热议问题