2011-02-08 14 views
6

मैं एक नई पायथन पुस्तकालय प्रोग्रामिंग कर रहा हूं, जिसके लिए एक अच्छा दस्तावेज चाहिए। ऐसी पुस्तकालय दस्तावेज करने के अच्छे तरीके क्या हैं? मैं एक विधि का पक्ष लेगा जो एचटीएमएल में एक पूर्ण दस्तावेज उत्पन्न करता है।पायथन परियोजना को कैसे दस्तावेज़ित करें?

+0

स्वत: जनरेट एचटीएमएल प्रलेखन सबसे बुरी बात कभी प्रलेखन हुआ है, सदा ही [इस] के रूप में इस तरह के गर्भपात के लिए अग्रणी है (http://www.alsa-project.org/alsa-doc/alsa-lib/)। –

+4

खराब स्वत: उत्पन्न एचटीएमएल दस्तावेज> सभी –

+0

पर कोई दस्तावेज नहीं है मुझे लगता है कि एक उपयोगी HTML दस्तावेज़ उत्पन्न करना संभव है। और मुझे [स्पिंक्स] (http://sphinx.pocoo.org/contents.html) दस्तावेज जैसे कुछ की बजाय एएलएसए दस्तावेज की तरह कुछ नहीं चाहिए। – svenwltr

उत्तर

10

हर जगह डॉकस्ट्रिंग का उपयोग करना पहला कदम है। फिर आप गुणवत्ता दस्तावेज उत्पन्न करने के लिए कई पाइथन दस्तावेज उत्पादन उपकरण का उपयोग कर सकते हैं। यह Sphinx का उपयोग कर python.org करता है।

लेकिन docstrings का उपयोग कर के रूप में भी अच्छी तरह से सही दुभाषिया में प्रोग्रामर के लिए उपयोगी होने का अतिरिक्त लाभ है:

>>> help(dir) 
Help on built-in function dir in module __builtin__: 

dir(...) 
    dir([object]) -> list of strings 

    If called without an argument, return the names in the current scope. 
    Else, return an alphabetized list of names comprising (some of) the attributes 
    of the given object, and of attributes reachable from it. 
    If the object supplies a method named __dir__, it will be used; otherwise 
    the default dir() logic is used and returns: 
     for a module object: the module's attributes. 
     for a class object: its attributes, and recursively the attributes 
     of its bases. 
     for any other object: its attributes, its class's attributes, and 
     recursively the attributes of its class's base classes. 

यह सब dir() builtin समारोह के docstring से आता है, और यह अच्छी तरह से सुंदर मुद्रित हो जाता है बिल्टिन help() फ़ंक्शन के माध्यम से।

+1

तो स्फिंक्स दस्तावेज को डॉकस्ट्रिंग से उत्पन्न करता है? – svenwltr

+0

यह * केवल * डॉकस्ट्रिंग से खींचता नहीं है लेकिन ऑटोडोक एक्सटेंशन आपके लिए यह करता है: http://sphinx.pocoo.org/tutorial.html#autodoc –

+0

बढ़िया! मैं इसके लिए एक नज़र डालेगा। – svenwltr

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