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ドキュメント生成ツールのいずれかを使用して、高品質のドキュメントを生成することができます。それはSphinxを使ってpython.orgがしているものです。

しかし、ドキュメンテーション文字列を使用した場合も、同様に右インタプリタでプログラマのために有用であることの余分な利点があります。

>>> 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

したがって、Sphinxはdocstringsからドキュメンテーションを生成しますか? – svenwltr

+0

* docstringから* pull *するだけではなく、Autodoc拡張がそれを行います:http://sphinx.pocoo.org/tutorial.html#autodoc –

+0

素晴らしい!私はそれを見てみましょう。 – svenwltr

関連する問題