如何自定义生成的javadoc存根? [英] How to customize generated javadoc stubs?

查看:103
本文介绍了如何自定义生成的javadoc存根?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Netbeans中,当您在方法上方键入/**时,它将生成一个Javadoc存根:

In Netbeans when you type /** above a method it generates a javadoc stub:

/**
 * 
 * @param 
 * @return 
 */

如何自定义生成的文本?我想要一个自定义的javadoc存根,例如:

How do you customize the generated text? I would like a custom javadoc stub like:

/**  Author = {author}
 *  
 * My custom text  
 * 
 * @param 
 * @return 
 */

注意:这是在方法上,而不是在使用类模板的类上.

Note: this is on a method, not the class which uses the class templates.

搜索字词: netbeans javadoc模板存根自定义自动完成

search terms: netbeans javadoc template stub custom autocomplete

推荐答案

这不会替代/**的功能,但可以为您提供替代选择.

This won't replace the functioning of /** but it'll allow you an alternative.

  • 进入Tools, Options
  • 点击Edit, Code Templates标签,
  • 从语言下拉菜单中,确保选择了 Java
  • 点击New
  • 键入您选择的缩写(我将<​​c5>用于javadoc模板)
  • 点击OK
  • 在展开的文本下,以所需的方式键入javadoc注释.注意:一个令人讨厌的事情是,您必须在带有单词的行的末尾添加一个额外的输入,否则它将不会将下一个单词向下移动到下一行.
  • Go into Tools, Options,
  • Click on Edit, Code Templates tab,
  • From the language pull-down, make sure Java is selected,
  • Click New,
  • Type in an abbreviation of your choice (I used jdt for javadoc template),
  • Click OK,
  • Under expanded text, type in the javadoc comment how you want it. Note: one annoying thing is, you have to have an extra enter at the end of lines with words, or else it won't move the next word down to the next line.

例如,如果您输入以下内容:

For example, if you put in this:

/**
 * @author
 * 
 * @param
 * @return
 */

它将输出:

/**
 * @author
 * 
 * @param @return
 */

但是,如果您输入以下内容:

But if you input this:

/**
 * @author
 * 
 * @param
 *
 * @return
 */

它将输出:

/**
 * @author
 * 
 * @param
 *
 * @return
 */

有点奇怪.无论如何,一旦您输入了该内容,请查看以下位置的扩展模板"按钮,然后查看是否在选项卡"上设置了该模板或输入了它或进行了其他操作.那部分是您的选择.但是,您想激活模板.点击OK.

Kind of weird. Anyway, once you've typed that in, look at the Expand Template on: button and see if it is set on tab or enter or whatever. That part is your choice. However you want to activate the template. Click OK.

在文档中,转到要插入预格式化注释的位置,而不是在jdt中键入/**,然后执行扩展模板"操作(制表符,回车等),然后将显示注释

In your document, go to where you want to insert your preformatted comment, and instead of typing /** type in jdt then do whatever the Expand template action was (tab, enter, etc) and your comment will appear.

这篇关于如何自定义生成的javadoc存根?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆