2011-02-08 8 views
6

새로운 Python 라이브러리를 프로그래밍하고 있습니다. 좋은 설명서가 필요합니다. 그러한 도서관을 문서화하는 좋은 방법은 무엇입니까? html로 완전한 문서를 생성하는 메소드를 선호합니다.Python 프로젝트를 문서화하는 방법은 무엇입니까?

+0

자동 생성 된 HTML 문서는 문서화 작업 중 최악의 경우이며, 항상 [this] (http://www.alsa-project.org/alsa-doc/alsa-lib/)와 같은 낙태로 이어집니다. –

+4

잘못된 자동 생성 HTML 문서> 전혀 문서가 없습니다 –

+0

유용한 HTML 문서를 생성 할 수 있다고 생각합니다. 그리고 나는 [Sphinx] (http://sphinx.pocoo.org/contents.html) 문서와 같은 것보다는 ALSA 문서와 같은 것을 원하지 않습니다. – svenwltr

답변

10

모든 곳에 문서화 문자열을 사용하는 것이 첫 번째 단계입니다. 그런 다음 여러 가지 파이썬 문서 생성 도구 중 하나를 사용하여 양질의 문서를 생성 할 수 있습니다. Python.org가 수행하는 작업으로 Sphinx을 사용합니다.

그러나 문서화 문자열을 사용하는 것은 물론 오른쪽 인터프리터 프로그래머를위한 유용한의 추가 혜택이 있습니다

>>> 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() 내장 함수의 문서화 문자열에서 제공을하고 멋지게 꽤 인쇄됩니다 내장 된 help() 기능을 통해.

+1

그래서 스핑크스는 docstrings에서 문서를 생성합니까? – svenwltr

+0

* 단지 * docstring에서 가져 오지는 않지만 Autodoc 확장이 지원합니다 : http://sphinx.pocoo.org/tutorial.html#autodoc –

+0

멋지다! 나는 그것을 살펴볼 것이다. – svenwltr

관련 문제