2012-06-17 108 views
9

在twisted的源代碼中,許多文檔包含如下格式:L {xxx}或C {xxx}或以'@'開頭的行,它們的含義是什麼?這些格式在twisted的文檔字符串中是什麼意思?

例如,在扭曲/互聯網/ interfaces.py:

def registerProducer(producer, streaming): 
    """ 
    Register to receive data from a producer. 
    ... 
    For L{IPullProducer} providers, C{resumeProducing} will be called once 
    each time data is required. 
    ... 
    @type producer: L{IProducer} provider 
    ... 
    @return: C{None} 
    """ 

L {多IPullProducer},C {} resumeProducing,@type生產者?

順便說一下,這些格式是標準python文檔字符串格式的一部分嗎?如果是這樣,我應該在哪裏提及?謝謝:)

回答

11

Twisted使用的文檔格式是Epytext, which is documented on epydoc.sourceforge.net

L{}指「鏈接」(即:「這是一個Python標識符,請鏈接的」)C{}手段「代碼」(即hello C{foo} bar應格式化像「你好foo條」)。 I{}只是表示「斜體」。你可以在epytext文檔中看到更多的字段。

Twisted項目生成其文檔pydoctor,使用像pydoctor --add-package twisted這樣的調用。還有一點,可以生成Twisted所依賴的其他項目的鏈接,但是如果您想爲Twisted提供文檔字符串,可以使用它來獲得一個想法。你也可以用epydoc本身生成文檔,使用epydoc twisted,但epydoc不知道Zope接口,所以不會自動將類鏈接到它們實現的接口。

The generated API documentation for each release is published on twistedmatrix.com,你可以在那裏瀏覽它。