更改 Eclipse 中的 doxygen 注释样式
有谁知道如何在 Eclipse CDT 中编辑 Doxygen 注释所使用的样式?
换句话说,在函数当前给我的内容之前键入 /** 并按 enter
/**
*
* @param one
* @param two
* @return
*/
Foo(int one, int two);
,我希望它给我类似的内容:
/**********************************************************************/
///
/// \param one
/// \param two
/// \return
/***********************************************************************/
Foo(int one, int two);
另外,如果有人知道如何绑定它,请加一到键盘快捷键(例如 Eclipse JDT 的 alt-shift-j)。
另外,仅供参考,基于 Google,Eclipse CDT 支持 Doxygen 的事实现在似乎是一个鲜为人知的事实。有关详细信息,请参阅此处。通过在“C/C++ 常规”选项卡中选择“启用项目特定设置”并选择“Doxygen”,可以在项目属性下启用 Doxygen。我的 CDT 版本是 7.0.1,但我认为它在 5.0 中可用。
最后,根据我的测试,首选项中代码模板下的注释部分无法实现此目的。
编辑: 请参阅这里。评论风格似乎是硬编码的。如果有人发现其他情况,我很想知道。我想模板将是目前最好的东西,除非 Javadoc 风格适合您。
Does anyone know how to edit the style used for Doxygen comments in Eclipse CDT?
In other words type /** and pressing enter on a line before a function currently gives me something like:
/**
*
* @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-j for Eclipse JDT).
Also, FYI, the fact that Eclipse CDT supports Doxygen now seems to be a little known fact based on Google. See here for 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.
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,这似乎是 Eclipse CDT 中的一个错误。
作为解决方法,我建议您创建一个自定义模板,可以使用 Ctrl+Space 组合键访问该模板。
在 Eclipse Helios 中:窗口 ->首选项-> C/C++->编辑->模板
单击新建... 创建一个新模板,并在名称 字段中使用一些描述性名称,例如“comment-function”,并添加您的 doxygen在模式字段中进行注释。确认并应用此更改。
然后,您可以在代码中转到函数声明上方的行,键入自定义模板名称的前几个字母,然后按 Ctrl+Space 组合键。
在此示例中:
将打开用“com*”过滤的“内容辅助”对话框,您可以从中选择“评论功能”模板。
注意:
将通过仅在内容辅助弹出窗口中显示模板提案来进一步过滤。
Yes, this seems to be a bug in Eclipse CDT.
As a workaround I suggest you create a custom template which can be accessed with the Ctrl+Space key combination.
In Eclipse Helios: Window -> Preferences -> C/C++ -> Editor -> Templates
Click on New... to create a new template and in the Name field use some descriptive name e.g. "comment-function", and add your doxygen comment in the Pattern field. Confirm and apply this change.
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+Space key combination.
In this example:
will bring up the Content Assist dialog filtered with "com*" from which you can select the "comment-function" template.
Note:
will filter even further by only showing Template Proposals in the Content Assist pop-up window.
中找到的配置
这是我在 java 注释
,当我如图所示编辑时,我的 java doc 注释更改为
< img src="https://i.sstatic.net/DGQaB.jpg" alt="java 编辑器中的图像">
尝试在 php 配置下查找类似的配置。
This is a configuration I found in my java comment
and when i edited as shown my java doc comment changed to
Try to look for similar configuration under your php configuration.
我可以通过以下方式获得您想要的东西:
首选项 - PHP - 代码样式 - 代码模板 - 注释。
我不确定这是否能让您在关键字中使用反斜杠而不是 @s,但我认为它应该可以实现您想要的大部分效果。
I can get some of the way to what you want by going to:
Preferences - PHP - Code Style - Code Templates - Comments.
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.
从 eclipse 2020-03 开始,您可以使用选项组合:代码模板使用 /*****/ 创建页眉和页脚,然后在中间使用 /// 自定义 C/C++ 中的样式 ->编辑器选项。
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.
Doxygen 标签使用这种基本格式。
它绝对必须在整个 Doxygen 注释周围有 /** */ 。如果您修改代码模板,它将执行您想要的操作。
不过,建议的评论风格是错误的。
以下是大多数使用 JAVA 和 Eclipse 编码的公司的标准。由于 Doxygen 对多种语言有效,因此对 C/C++ 也有效。
如果您想使用 xml 样式标签...
您还需要确保 Eclipse 不会插入其他注释样式,否则您最终可能会在其他注释中插入注释。通常,混合注释样式(例如 /** */ 和 ///)是一个不好的规则。
最后,如果您在创建类时选择自动生成注释,那么这些注释将自动放入。并且您可以在键入时让 Eclipse 自动生成方法头(尽管我忘记了我是如何做到的)。
A Doxygen tag uses this basic format.
It absolutely must have the /** */ around the whole Doxygen comment. If you modify the Code Templates it will do what you want.
The proposed comment style is wrong though.
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.
If you want to use the xml style tags...
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 ///.
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).