2016-12-03 6 views
1

클래스의 인스턴스가 될 것으로 예상되는 클래스와 클래스 개체가 될 것으로 예상되는 클래스와를 구별하기 위해 함수 인수 및 클래스 특성의 형식을 문서화하는 표준 방법은 무엇입니까? 그들 자신?클래스 대 클래스 개체의 인스턴스에 대한 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

파이썬 표준은 restructuredtext (http://www.sphinx-doc.org/en/1.4.9/rest.html)

을 사용하고있는 스핑크스 스타일

더 정확하게는, autodoc 모듈 스타일 : 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