Adding images into source code

时间秒杀一切 提交于 2019-12-18 05:50:38

问题


Is there a way (or an editor) that allows me to link an image/files/http links from within a source file (*.java for instance), sort of like a rich text document?

This way, while reading the code I can quickly look at the appended image (augmenting the comments), instead of opening the browser etc.


回答1:


Javadocs are HTML, so you can just embed images there:

/**
 * This class does some funky stuff (see diagram).
 * <img src="relative/path/to/your/image.png" />
 * 
 */
 public class FunkyClass{
 }

Eclipse will happily show you the images in the javadoc view or on hovering over the comment. Other IDEs might or might not do the same.

Obviously you have to make sure somehow that the images are deployed with the javadocs...




回答2:


You can add <img src=""> and <a href=""> in the javadoc of your classes.

You probably have tools and plug-ins that allow easily to see the Javadoc of your file.

One good example of mixing images and links in Javadoc is JRootPane




回答3:


As many says you can use but for example in Eclipse you encouter error if you don't declare "alt" and if you use "selfclosing" tag like

<img alt="image desc" src="path/img.jpg">

seems not givin error =)




回答4:


By industry standard, source code is almost always text-only (be it encoded in ASCII or unicode). You can always draw an ASCII art. ;-)



来源:https://stackoverflow.com/questions/2903042/adding-images-into-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!