2013-10-30 64 views
1

我想向Python類的描述中添加一個示例。由於某種原因,它似乎不起作用。該示例已添加到生成的HTML頁面上的「示例」選項卡上,但該示例的鏈接未顯示在類的說明中。我已閱讀Doxygen手冊中涵蓋特殊命令'@example'(http://www.stack.nl/~dimitri/doxygen/manual/commands.html#cmdexample)的部分,但我仍然無法弄清楚如何正確執行。看起來無論我放置@example命令的位置,鏈接都不顯示。我正在使用Doxygen 1.8.5。在Doxygen生成的Python文檔中添加一個示例

簡化Python類,其中一示例的鏈路應該顯示:

class TestClass: 

    ## The constructor. 
    # @param self The object pointer. 
    def __init__(self): 
     self.__value = 0 

    ## Stores a value. 
    # @param value The value to be stored.   
    def setValue(self, value): 
     self.__value = value 

    ## Gets stored value. 
    # @return The stored value.     
     def getValue(self): 
     return self.__value 

## @example TestClass_Example.py 
# This is an example of how to use TestClass 

的例子如下所示:

from TestClass import TestClass 

def main(): 
    myTestClass = TestClass() 
    myTestClass.setValue(37) 
    print "The stored value is:", myTestClass.getValue()  

if __name__ == '__main__': 
    main() 

任何幫助理解。

回答

0

答案可以找到here

簡而言之:不能使用特殊命令(如示例)使用doxygen的python語法。 您必須使用以##開頭的註釋,然後使用特殊命令。

請注意,在這種情況下,doxygen的特殊命令都不支持 。

還有另一種方法來使用註釋 以「##」開頭的註釋來記錄Python代碼。這些類型的註釋塊更符合 文檔塊對doxygen支持的其他語言的工作方式,這也允許使用特殊命令。

編輯:對不起啊...剛纔讀你已經這樣做..

你確定的doxygen知道路徑的文件嗎?它在同一個目錄中嗎? 嘗試在doxygen配置中設置EXAMPLE_PATH

+0

其實我已經將示例文件目錄添加到配置文件中的EXAMPLE_PATH,並且假設示例已添加到輸出HTML中的「示例」選項卡,我想這不是問題。 – ThGJoer