2013-07-01 40 views
4

我想用獅身人面像建造我們的文檔,並獲得參數作爲NumPy的文檔(https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txtNumPy如何處理文檔到參數的sphinx文檔中?

我發現兩種方式與獅身人面像這第一個風格記錄參數,其中一個是

:param name: description 
相同的格式

:keyword name: description 

,另一個(它是NumPy的樣式)

Parameters 
---------- 
name: type 
    description 

這裏是什麼樣子的例子:

http://docs.scipy.org/doc/numpy/reference/distutils.html#module-numpy.distutils

和源

def get_subpackage(self,subpackage_name, 
        subpackage_path=None, 
        parent_name=None, 
        caller_level = 1): 
    """Return list of subpackage configurations. 

    Parameters 
    ---------- 
    subpackage_name: str,None 
     Name of the subpackage to get the configuration. '*' in 
     subpackage_name is handled as a wildcard. 
    subpackage_path: str 
     If None, then the path is assumed to be the local path plus the 
     subpackage_name. If a setup.py file is not found in the 
     subpackage_path, then a default configuration is used. 
    parent_name: str 
     Parent name. 
    """ 

然而,當我建立與獅身人面像的文檔(我用的獅身人面像,apidoc和sphinx-build),當我使用第一種語法(:param name:description)時,我可以生成格式化的列表,但是當我嘗試使用NumPy樣式時,我沒有得到格式。縱觀第一個語法(http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#sections)似乎像

Parameters 
---------- 

僅僅是一個章節標題。但是在sphinx中使用這種格式,標題Parameter不會出現在輸出中,並且它不會得到參數部分的格式。

有誰知道NumPy如何使用sphinx構建文檔以獲得這種格式來處理參數?

我也想看看makefile文件和conf.py,我只是不知道

回答

8

NumPy的如何使用自定義的獅身人面像的擴展:https://pypi.python.org/pypi/numpydoc

您可以

pip install numpydoc 

安裝它,然後你通過向擴展名列表

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage', 'numpydoc'] 
+0

能否請您更新(現在斷開)的鏈接將其添加到獅身人面像conf.py文件?乾杯! –