2015-06-01 7 views
6

पायचर्म, पायथन आईडीई डॉकस्ट्रिंग के लिए एक टेम्पलेट उत्पन्न करता है क्योंकि मैं डॉकस्ट्रिंग में टाइप करना शुरू करता हूं। यह एक साधारण फ़ंक्शन के लिए जेनरेट किया गया टेम्पलेट है।PyCharm के docstring टेम्पलेट का उपयोग क्या है? मैं इसे प्रभावी ढंग से कैसे उपयोग करूं?

def add_them(x, y): 
    """ 

    :param x: 
    :param y: 
    :return: 
    """ 
    z = x + y 
    return z 

मैं इसे अजगर की आधिकारिक docstring conventions के लिए इसी तरह कुछ भी नहीं है।

क्या इस टेम्पलेट में रीडहेडॉक्स जैसे किसी दस्तावेज़ प्रलेखन के साथ कोई उपयोग है?

कोई प्रभावी ढंग से उपयोग कैसे करता है?

टेम्पलेट भरने का सही तरीका क्या है?

धन्यवाद।

उत्तर

12

हम अपने एचटीएमएल और पीडीएफ दस्तावेज उत्पन्न करने के लिए स्फिंक्स-एपिडोक के साथ इसका इस्तेमाल करते हैं।

def add_pdr(process, userid, log): 
    """ Create and perform the target account operation PDR 

    If the function/method is complex, I'd put a short one-line 
    summary in the first line above, and a more detailed explanation 
    here. 

    :param dict process: dict of process details 
    :param str userid: userid to perform actions on 
    :param obj log: log object to perform logging to 

    :raises KeyError: if the userid doesn't exist 
    :raises APIError: if process dict is invalid 

    :return: True on success, False upon failure 

    """ 
+2

आप के लिए 'भी exception' उदाहरण के साथ जवाब को अपडेट होगा:

यहाँ एक उदाहरण है कि कैसे मैं docstrings का उपयोग है? – x0x

+2

जोड़ा गया अपवाद/उठाता है उदाहरण – stevieb

+1

उपयोगकर्ता या ऑटो द्वारा उत्पन्न पैरामीटर प्रकार है? – x0x

संबंधित मुद्दे

 संबंधित मुद्दे