Emacs 使用SRecode为现有的C文件生成doxygen注释

Emacs 使用SRecode为现有的C文件生成doxygen注释,emacs,emacs24,Emacs,Emacs24,我正在寻找一种为现有源文件中的函数自动生成doxygen注释块的方法。在查看备选方案时,我看到了对SRecode中现有机制的引用,该机制可以使用SRecode document insert函数comment生成正确的注释。使用M-x语义模式和M-x SRecode次要模式启用标记生成后。一切似乎都在运行,模板和表在使用SRecode调试功能时似乎检测到了c模式 但是,当我使用SRecode->Generate菜单选项而不是doxygen函数注释时,我得到一个简单的注释,如下所示: /** ma

我正在寻找一种为现有源文件中的函数自动生成doxygen注释块的方法。在查看备选方案时,我看到了对SRecode中现有机制的引用,该机制可以使用
SRecode document insert函数comment
生成正确的注释。使用
M-x语义模式
M-x SRecode次要模式
启用标记生成后。一切似乎都在运行,模板和表在使用SRecode调试功能时似乎检测到了c模式

但是,当我使用SRecode->Generate菜单选项而不是doxygen函数注释时,我得到一个简单的注释,如下所示:

/** main --
* 
*/
void main(int argc, char **argv)
我只收到以下带有
C-he
的消息:

Adding srecode-insert-getset to srecode menu
Adding srecode-document-insert-comment to srecode menu
我已经在其他函数上尝试过它,并尝试过使用edebug defun进行调试,但我无法理解输出

有人能建议其他需要的设置吗

其他详情:

  • 2013年3月17日于马文发布的GNU Emacs 24.3.1(i386-mingw-nt6.1.7601)
  • 语义2.2
  • SRecode 1.2
更新20131009:

  • 从不同的光标位置重试(例如,在函数内部,在函数名的开头)会产生相同的结果
  • 从菜单调用或直接调用函数会产生相同的结果
  • 我在.emacs中没有针对语义或SRemote的特殊定制,并且在我按照上面所述专门调用这些模式之前,这些模式都不会被启用(可能这实际上是缺少的;是否需要某种全局设置?)
更新20131012:

  • 使用不同的PC(配置不同)重试,并使用-q启动选项忽略.emacs文件。在这两种情况下,输出是相同的
更新20131013:

  • 在第一次运行generate之后,我注意到*messages*缓冲区中有以下内容。也许这里面有个暗示

    Adding srecode-insert-getset to srecode menu
    Adding srecode-document-insert-comment to srecode menu
    Adding srecode-insert-getset to srecode menu
    Adding srecode-document-insert-comment to srecode menu
    Compiling template default.srt...
    2 templates compiled for default
    Templates default.srt has estimated priority of 80
    Compiling template c.srt...
    17 templates compiled for c-mode
    Templates c.srt has estimated priority of 90
    Compiling template c.srt...
    14 templates compiled for c-mode
    Templates c.srt has estimated priority of 90
    Compiling template doc-default.srt...
    7 templates compiled for default
    Templates doc-default.srt has estimated priority of 80
    Auto-saving...done
    

您应该与函数名在同一行,或者在函数的定义中-然后,
srecode document insert comment
C-C/C
)将插入正确的注释。以下是在我的CEDET安装上执行此命令的结果(来自bzr,但在24.3.1中应该是相同的):


您应该与函数名在同一行,或者在函数的定义中-然后,
srecode document insert comment
C-C/C
)将插入正确的注释。以下是在我的CEDET安装上执行此命令的结果(来自bzr,但在24.3.1中应该是相同的):


光标应位于左括号之前。
如果您在参数列表中,则不会插入任何内容。

光标应位于左括号之前。
如果您在参数列表中,则不会插入任何内容。

看起来有人在某个时候将doc-c.srt移动到doc-cpp.srt,而不是复制它(这是emacs 24.3.1)。
因此,
srecode document insert comment
只能在
c++模式下工作(正如您所期望的那样)

为了在
c-mode
中启用它,创建一个包含以下内容的文件~/.srecode/doc-c.srt,它应该可以正常工作

;; doc-c.srt --- SRecode templates for "document" applications

;; Copyright (C) 2008-2013 Free Software Foundation, Inc.

;; Author: Eric M. Ludlam <eric@siege-engine.com>

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

set mode "c-mode"

set application "document"
context declaration

;;; Notes on the DOCUMENT templates.
;;
;; These templates recycle existing templates for doxygen in the
;; more general C template set.

template section-comment :indent :blank
"A comment separating major sections of a file."
----
{{>:declaration:doxygen-section-comment}}
----

template function-comment :tag :indent :blank
"A comment occurring in front of a function.
Recycle doxygen comment code from the more general template set."
----
{{>:declaration:doxygen-function}}
----

template variable-same-line-comment :tag
"A comment occurring after a variable declaration.
Recycle doxygen comment code from the more general template set."
----
{{>:declaration:doxygen-variable-same-line}}
----

;; These happen to be the same as in a classdecl.
template group-comment-start :blank :indent
"A comment occurring in front of a group of declarations.
Recycle doxygen comment code from the more general template set."
----
{{>:classdecl:doxygen-function-group-start}}
----

template group-comment-end :blank :indent
"A comment occurring at the end of a group of declarations.
Recycle doxygen comment code from the more general template set."
----
{{>:classdecl:doxygen-function-group-end}}
----

;; end
;;doc-c.srt--“文档”应用程序的SRecode模板
;; 版权所有(C)2008年至2013年自由软件基金会。
;; 作者:Eric M.Ludlam
;; 此文件是GNU Emacs的一部分。
;; GNU Emacs是自由软件:您可以重新发布和/或修改它
;; 它是根据GNU通用公共许可证的条款发布的
;; 自由软件基金会,或者许可证的第3版,或者
;; (由您选择)任何更高版本。
;; 分发GNU Emacs是希望它会有用,
;; 但无任何保证;甚至没有任何关于
;; 适销性或适合某一特定目的。见
;; 有关更多详细信息,请参阅GNU通用公共许可证。
;; 您应该已经收到GNU通用公共许可证的副本
;; 以及GNU Emacs。如果没有,请参阅。
设置模式“c模式”
设置应用程序“文档”
上下文声明
;;; 文档模板上的注释。
;;
;; 这些模板循环使用中的doxygen现有模板
;; 更通用的C模板集。
模板节注释:缩进:空白
“分隔文件主要部分的注释。”
----
{{>:声明:doxygen节注释}
----
模板函数注释:标记:缩进:空白
“出现在函数前面的注释。
从更通用的模板集中回收doxygen注释代码。”
----
{{>:声明:doxygen函数}
----
模板变量同一行注释:标记
“在变量声明之后出现的注释。
从更通用的模板集中回收doxygen注释代码。”
----
{{>:声明:doxygen变量同一行}
----
;; 这些恰好与classdecl中的相同。
模板组注释开始:空白:缩进
“出现在一组声明前面的注释。
从更通用的模板集中回收doxygen注释代码。”
----
{{>:classdecl:doxygen函数组开始}
----
模板组注释结束:空白:缩进
“出现在一组声明末尾的注释。
从更通用的模板集中回收doxygen注释代码。”
----
{{>:classdecl:doxygen函数组end}
----
;; 结束

生成doxygen注释的另一种方法是

看起来有人在某个时候将doc-c.srt移动到doc-cpp.srt,而不是复制它(这是emacs 24.3.1)。
因此,
srecode document insert comment
只能在
c++模式下工作(正如您所期望的那样)

为了在
c-mode
中启用它,创建一个包含以下内容的文件~/.srecode/doc-c.srt,它应该可以正常工作

;; doc-c.srt --- SRecode templates for "document" applications

;; Copyright (C) 2008-2013 Free Software Foundation, Inc.

;; Author: Eric M. Ludlam <eric@siege-engine.com>

;; This file is part of GNU Emacs.

;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.

set mode "c-mode"

set application "document"
context declaration

;;; Notes on the DOCUMENT templates.
;;
;; These templates recycle existing templates for doxygen in the
;; more general C template set.

template section-comment :indent :blank
"A comment separating major sections of a file."
----
{{>:declaration:doxygen-section-comment}}
----

template function-comment :tag :indent :blank
"A comment occurring in front of a function.
Recycle doxygen comment code from the more general template set."
----
{{>:declaration:doxygen-function}}
----

template variable-same-line-comment :tag
"A comment occurring after a variable declaration.
Recycle doxygen comment code from the more general template set."
----
{{>:declaration:doxygen-variable-same-line}}
----

;; These happen to be the same as in a classdecl.
template group-comment-start :blank :indent
"A comment occurring in front of a group of declarations.
Recycle doxygen comment code from the more general template set."
----
{{>:classdecl:doxygen-function-group-start}}
----

template group-comment-end :blank :indent
"A comment occurring at the end of a group of declarations.
Recycle doxygen comment code from the more general template set."
----
{{>:classdecl:doxygen-function-group-end}}
----

;; end
;;doc-c.srt--“文档”应用程序的SRecode模板
;; 版权所有(C)2008年至2013年自由软件基金会。
;; 作者:Eric M.Ludlam
;; 此文件是GNU Emacs的一部分。
;; 编辑器