2016-12-03 39 views
1

什麼是標準的方式來記錄的函數參數和類的類型屬性那些有望成爲一個類的實例和這些區分被預期爲類對象他們自己?類VS類的實例Python文檔樣式對象

class TestClass(object): 
    def __init__(self): 
     pass 

class Objectify(object): 
    def __init__(self): 
     pass  

class NeatDocumentation(object): 
    """A class demonstrating neat documentation style. 

    Attributes: 
     cls (TestClass?): A class you want to test. 
     obj (Objectify?): An instance of `Objectify` class. 
     string (str): A string because why not. 
    """ 

    def __init__(self, cls_, obj, string): 
     self.cls = cls_ # An instance can be created by executing self.cls() 
     self.obj = obj 
     self.string = string 

回答

0

Python標準是使用新結構化(http://www.sphinx-doc.org/en/1.4.9/rest.html

獅身人面像的風格

更確切地說,車博士模塊風格:http://www.sphinx-doc.org/en/1.4.8/ext/autodoc.html

如果你想擁有漂亮的字符串,你也可以使用獅身人面像拿破崙風格: http://www.sphinx-doc.org/en/1.4.9/ext/napoleon.html

在你的情況,你可以這樣做:

:param your_param: Class to test 
:type your_param: :class:`Objectify` 

或者用拿破崙:

Args: 
    your_param (Objectify): The :class:`Objectify` class to test