Javadoc 模板生成器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29689/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 07:21:16  来源:igfitidea点击:

Javadoc template generator

javadocumentationjavadoc

提问by Alotor

I have a large codebase without Javadoc, and I want to run a program to write a skeleton with the basic Javadoc information (e.g., for each method's parameter write @param...), so I just have to fill the gaps left.

我有一个没有 Javadoc 的大型代码库,我想运行一个程序来编写一个包含基本 Javadoc 信息的框架(例如,为每个方法的参数写入 @param...),所以我只需要填补剩下的空白。

Anyone know a good solution for this?

有谁知道一个好的解决方案?

Edit:

编辑:

JAutodoc is what I was looking for. It has Ant tasks, an Eclipse plugin, and uses Velocity for the template definition.

JAutodoc 是我一直在寻找的。它有 Ant 任务、一个 Eclipse 插件,并使用 Velocity 作为模板定义。

采纳答案by Laurent K

The JAutodocplugin for eclipse does exactly what you need, but with a package granularity :

JAutodoc的Eclipse插件不正是你所需要的,但有一个包的粒度:

right click on a package, select "Add javadoc for members..." and the skeleton will be added.

右键单击一个包,选择“为成员添加 javadoc...”,将添加骨架。

There are numerous interesting options : templates for javadoc, adding a TODO in the header of every file saying : "template javadoc, must be filled...", etc.

有许多有趣的选项:javadoc 模板,在每个文件的标题中添加一个 TODO 说:“模板 javadoc,必须填写...”等。

回答by Silas Snider

If you right-click in the source of a file in Eclipse, it has a Javadoc generation option under the source menu.

如果在 Eclipse 中右键单击文件的源代码,它会在源代码菜单下有一个 Javadoc 生成选项。

回答by izb

You can configure eclipse to show warnings for things that lack javadoc, or have javadoc that does not have all the information, or has wrong information. It can also insert templates for you to fill out.

您可以配置 eclipse 以显示缺少 javadoc 的内容的警告,或者具有不包含所有信息的 javadoc 或包含错误信息的内容。它还可以插入模板供您填写。

Not quite the tool you asked for, but probably better because you won't end up with empty skeletons on methods that you missed.

不完全是您要求的工具,但可能更好,因为您最终不会在您错过的方法上留下空的骨架。

You can achieve this by investigating and editing the preference page beyond the path Window > Preferences > Java > Compiler > Javadoc for your workspace. The screenshot of that preference page is below:

您可以通过调查和编辑工作区路径 Window > Preferences > Java > Compiler > Javadoc 之外的首选项页面来实现此目的。该首选项页面的屏幕截图如下:

The so-called Javadoc preference page

所谓的 Javadoc 偏好页面

For further information about the items in this screen please follow the link below:

有关此屏幕中项目的更多信息,请访问以下链接:

Java Compiler Javadoc Preferences Help

Java 编译器 Javadoc 首选项帮助

回答by davetron5000

I think auto-generating empty Javadoc is an anti-pattern and should be discouraged; it gives code the appearance of being documented, but just adds noise to the codebase.

我认为自动生成空的 Javadoc 是一种反模式,应该被劝阻;它使代码看起来像是被记录在案,但只会给代码库增加噪音。

I would recommend instead that you configure your code editor to assist on a per-method and per-class basis to use when you actually write the javadoc (one commenter pointed to Eclipse's feature that does this).

相反,我建议您配置代码编辑器,以便在您实际编写 javadoc 时根据每个方法和每个类来协助使用(一位评论者指出 Eclipse 的功能就是这样做的)。

回答by Booger

You can also place your cursor on the line above a method you would like to JavaDoc, then type:

您也可以将光标放在您想要 JavaDoc 的方法上方的行上,然后键入:

/**

and press Enter. This will generate your JavaDoc stub.

并按 Enter。这将生成您的 JavaDoc 存根。

回答by Jorgesys

Select the methodthat you want add Javadoc and alt+Shift+j, creates automatically the javadoc comment.

选择方法要添加Javadoc和alt+ Shift+ j,自动生成javadoc注释。

EXAMPLE:

例子:

/**
     * @param currDate
     * @param index
     * @return
     */
    public static String getAtoBinary(String currDate, int index){  
        String HourA = "0";
        try{
            String[] mydate = currDate.split("/");
            HourA = mydate[index].substring(1, 2);
        }catch(Exception e){
            Log.e(TAG, e.getMessage());
        }
        return HourA;
    }