在 Eclipse 中更改 doxygen 注释样式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4403192/
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-09-10 19:48:29  来源:igfitidea点击:

Change doxygen comment style in Eclipse

eclipsedoxygeneclipse-cdt

提问by deuberger

Does anyone know how to edit the style used for Doxygen comments in Eclipse CDT?

有谁知道如何在 Eclipse CDT 中编辑用于 Doxygen 注释的样式?

In other words type /** and pressing enteron a line before a function currently gives me something like:

换句话说,输入 /** 并enter在当前函数之前按一行会给我类似的东西:

/**
 * 
 * @param one
 * @param two
 * @return
 */
Foo(int one, int two);

and I want it to give me something like:

我希望它给我类似的东西:

/**********************************************************************/
///
/// \param one
/// \param two
/// \return
/***********************************************************************/
Foo(int one, int two);

Also, plus one if anyone knows how to bind this to a keyboard shortcut (like alt-shift-jfor Eclipse JDT).

另外,如果有人知道如何将其绑定到键盘快捷键(例如alt- shift-j用于 Eclipse JDT),请加一个。

Also, FYI, the fact that Eclipse CDT supports Doxygen now seems to be a little known fact based on Google. See herefor details. Doxygen can be enabled under the project properties by selecting "Enable project specific settings" in the "C/C++ General" tab and selecting "Doxygen". My CDT version is 7.0.1, but I think this became available in 5.0.

另外,仅供参考,Eclipse CDT 支持 Doxygen 的事实现在似乎是基于 Google 的一个鲜为人知的事实。有关详细信息,请参见此处。通过在“C/C++ 常规”选项卡中选择“启用项目特定设置”并选择“Doxygen”,可以在项目属性下启用 Doxygen。我的 CDT 版本是 7.0.1,但我认为它在 5.0 中可用。

Lastly, the comments section under code templates in preferences doesn't accomplish this based on my testing.

最后,根据我的测试,首选项中代码模板下的注释部分没有实现这一点。

EDIT:See here. It seems like the comment style is hard coded. If anyone finds otherwise, I'd love to know about it. I guess templates will be the best thing for now unless the Javadoc style is okay for you.

编辑:这里。似乎评论风格是硬编码的。如果有人发现其他情况,我很想知道。我想模板将是现在最好的东西,除非 Javadoc 风格适合你。

回答by Theuns Alberts

Yes, this seems to be a bug in Eclipse CDT.

是的,这似乎是 Eclipse CDT 中的一个错误。

As a workaround I suggest you create a custom template which can be accessed with the Ctrl+Spacekey combination.

作为一种解决方法,我建议您创建一个可以使用Ctrl+Space组合键访问的自定义模板。

In Eclipse Helios: Window -> Preferences -> C/C++ -> Editor -> Templates

在 Eclipse Helios 中:窗口 -> 首选项 -> C/C++ -> 编辑器 -> 模板

Click on New...to create a new template and in the Namefield use some descriptive name e.g. "comment-function", and add your doxygen comment in the Patternfield. Confirm and apply this change.

单击New...创建一个新模板,并在Name字段中使用一些描述性名称,例如“comment-function”,并在Pattern字段中添加您的 doxygen 注释。确认并应用此更改。

In your code you can then go to the line above your function declaration, type the first few letters of your custom template name followed by the Ctrl+Spacekey combination.

在您的代码中,您可以转到函数声明上方的行,键入自定义模板名称的前几个字母,然后是Ctrl+Space组合键。

In this example:

在这个例子中:

com<Ctrl+space>

will bring up the Content Assist dialog filtered with "com*" from which you can select the "comment-function" template.

将调出用“com*”过滤的“内容辅助”对话框,您可以从中选择“注释功能”模板。

Note:

笔记:

com<Ctrl+space+space>

will filter even further by only showing Template Proposals in the Content Assist pop-up window.

将通过仅在 Content Assist 弹出窗口中显示模板建议来进一步过滤。

回答by Naveen Babu

This is a configuration I found in my java comment

这是我在我的 java 评论中找到的配置

Javadoc comment modification

Javadoc 注释修改

and when i edited as shown my java doc comment changed to

当我如图所示编辑时,我的 Java 文档注释更改为

image in java editor

Java 编辑器中的图像

Try to look for similar configuration under your php configuration.

尝试在您的 php 配置下寻找类似的配置。

回答by greywolf82

Starting from eclipse 2020-03 you can use a combination of options: code template to create your header and footer using /*****/ and then in the middle just use /// customizing the style in C/C++->Editor options.

从 eclipse 2020-03 开始​​,您可以使用以下选项的组合:代码模板使用 /*****/ 创建页眉和页脚,然后在中间使用 /// 在 C/C++->Editor 中自定义样式选项。

回答by xgretsch

I can get some of the way to what you want by going to: Preferences - PHP - Code Style - Code Templates - Comments.

我可以通过以下方式获得一些您想要的方式:首选项 - PHP - 代码样式 - 代码模板 - 注释。

I'm not sure that this will enable you to use backslashes instead of @s for your keywords, but I think it should achieve most of what you want.

我不确定这是否能让您对关键字使用反斜杠而不是 @s,但我认为它应该可以实现您想要的大部分内容。

回答by GlazedHam

A Doxygen tag uses this basic format.

Doxygen 标签使用这种基本格式。

/**
Your tags and such. It MUST have the /** and the */.
*/

It absolutely must have the /** */ around the whole Doxygen comment. If you modify the Code Templates it will do what you want.

它绝对必须在整个 Doxygen 注释周围有 /** */ 。如果您修改代码模板,它将执行您想要的操作。

The proposed comment style is wrong though.

不过,建议的评论风格是错误的。

/***************/ <-- These are terminated Doxygen blocks.
/// <-- These are used in xml style Doxygen blocks.
///
/// This isn't actually a Doxygen block and shouldn't work
/// if you run Doxygen on it.
///
/***************/ <-- These are terminated Doxygen blocks.

This below is standard for most companies who code in JAVA and eclipse. Since Doxygen is valid for multiple languages this is valid for C/C++ too.

以下是大多数使用 JAVA 和 eclipse 编码的公司的标准。由于 Doxygen 对多种语言有效,因此对 C/C++ 也有效。

/**
 * Brief description.
 *
 * @param[in|out] <value> <description>
 */

If you want to use the xml style tags...

如果要使用 xml 样式标签...

/// <summary>
/// This is a summary of the class, blah, blah.
/// </summary>

You're also going to want to make sure eclipse isn't inserting other comment styles too, otherwise you can end up with comments inserted inside other comments. Also generally it is a bad rule to mix comment styles like /** */ and ///.

您还需要确保 eclipse 也不会插入其他注释样式,否则您最终可能会在其他注释中插入注释。通常,将 /** */ 和 /// 之类的注释样式混合在一起也是一个不好的规则。

Finally if you select auto-generate comments when you create classes and such those comments will automatically be put in. And you can have eclipse auto-generate method headers as you type (though I forget how I did this).

最后,如果您在创建类时选择自动生成注释,这些注释将自动放入。并且您可以在键入时使用 Eclipse 自动生成方法标题(尽管我忘记了我是如何做到的)。