2013-10-08 35 views
1

我正在尋找一種方法來爲現有源文件中的函數自動生成doxygen註釋塊。在查看備選方案時,我看到了SRecode中對現有機制的引用,它可以通過srecode-document-insert-function-comment生成正確的評論。在啓用M-x semantic-mode和SRecode與M-x srecode-minor-mode的代碼生成之後。似乎一切正常,模板和表格似乎在使用SRecode調試功能時檢測到了c模式。使用SRecode爲現有C文件生成doxygen註釋

然而,當我使用SRecode->生成菜單選項,而不是一個doxygen的功能註釋,我得到一個簡單的評論如下:

/** main -- 
* 
*/ 
void main(int argc, char **argv) 

我什麼也沒得到,但下面的信息與C-h e

Adding srecode-insert-getset to srecode menu 
Adding srecode-document-insert-comment to srecode menu 

我已經嘗試過其他功能,並試圖用edebug-defun進行調試,但我無法理解輸出。

有人可以建議其他設置是必要的嗎?

的附加細節:

  • GNU Emacs的24.3.1上MARVIN
  • 語義2.2
  • SRecode 1.2
的2013年3月17日(I386-的mingw-nt6.1.7601)

更新20131009:

  • 從不同的遊標posi重試(例如,在函數內部,在函數名稱的開頭)產生相同的結果
  • 從菜單調用或直接調用該函數會產生相同的結果
  • 我在.emacs中沒有針對語義或SRemote的特殊定製,該模式沒有啓用,直到我專門打電話給他們如上所述(也許這實際上缺少了什麼,有沒有一些必要的某種全局設置的?)

更新20131012:

  • 用不同的PC重試(與不同公司合作nfiguration)並使用-q啓動選項忽略.emacs文件。在這兩種情況下,產量都是一樣的。

更新20131013:

  • 我注意到,在*消息如下*運行生成後的第一時間緩衝。也許這裏有一個提示。

    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 
    

回答

1

看起來像某人在某個時刻將doc-c.srt移到了doc-cpp.srt而不是複製它(這是emacs 24.3.1)。
因此srecode-document-insert-comment的作品(如你所期望的)僅在c++-mode
爲了啓用它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 <[email protected]> 

;; 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 

對doxygen的評論代另一種方法是doxymacs

+0

就是這樣。目錄名中有一個錯字,我把模板放在.srecode中,它起作用 – tiktok

+0

@tiktok修正了錯字:) – zakkak

0

你應該在同一行的函數名或內部函數的定義 - 然後,srecode-document-insert-commentC-c/C)將插入正確的評論。這是在我的CEDET安裝上的這個命令的結果(來自bzr,儘管在24.3。1應該是相同的):

/** 
* @name main - 
* @param argc - Number of arguments 
* @param argv - Argument vector 
* @return int 
*/ 
int main(int argc, char **argv) { 

    return 0; 
} 
+0

嗨亞歷克斯,這是我在做什麼。我調用語義模式,解析緩衝區,調用srecode-minor-mode,將光標放在函數中,然後調用Generate菜單選項。我也試着直接調用'document-insert-comment'。我仍然得到我提到的輸出。我打開函數突出顯示來檢查標記是否正確解析,確定是否正確,函數名稱是否突出顯示,因此解析似乎不成問題。 – tiktok

+0

我會嘗試設置純粹的24.3.1&嘗試 - 但不能保證會發生快速:-) –

0

您的光標應該在左括號之前。 如果您在參數列表中,則不會插入任何內容。

+0

它沒有區別。我已經嘗試了函數內部函數名稱的開始行。結果始終是相同的輸出。 – tiktok