그게 전부입니다. 함수 또는 클래스를 문서화하려면 정의 바로 뒤에 문자열을 넣습니다. 예 :파이썬에서 모듈을 문서화하려면 어떻게해야합니까?
def foo():
"""This function does nothing."""
pass
하지만 모듈은 어떻습니까? 파일의 기능은 무엇입니까?
그게 전부입니다. 함수 또는 클래스를 문서화하려면 정의 바로 뒤에 문자열을 넣습니다. 예 :파이썬에서 모듈을 문서화하려면 어떻게해야합니까?
def foo():
"""This function does nothing."""
pass
하지만 모듈은 어떻습니까? 파일의 기능은 무엇입니까?
패키지의 경우 __init__.py
에 문서화 할 수 있습니다. 모듈의 경우 모듈 파일에 docstring을 추가 할 수 있습니다.
모든 정보는 여기에 있습니다 : http://www.python.org/dev/peps/pep-0257/
쉽습니다. 모듈 상단에 문서 문자열을 추가하기 만하면됩니다.
docstring을 first statement in the module으로 추가하십시오.
내가 예를보고 좋아하기 때문에 :
"""
Your module's verbose yet thorough docstring.
"""
import foo
# ...
를 여기하는 모듈을 문서화 할 수있는 방법에 Example Google Style Python Docstrings입니다. 기본적으로 모듈에 대한 정보, 실행 방법 및 모듈 수준 변수 및 ToDo 항목 목록에 대한 정보가 있습니다.
"""Example Google style docstrings.
This module demonstrates documentation as specified by the `Google
Python Style Guide`_. Docstrings may extend over multiple lines.
Sections are created with a section header and a colon followed by a
block of indented text.
Example:
Examples can be given using either the ``Example`` or ``Examples``
sections. Sections support any reStructuredText formatting, including
literal blocks::
$ python example_google.py
Section breaks are created by resuming unindented text. Section breaks
are also implicitly created anytime a new section starts.
Attributes:
module_level_variable1 (int): Module level variables may be documented in
either the ``Attributes`` section of the module docstring, or in an
inline docstring immediately following the variable.
Either form is acceptable, but the two should not be mixed. Choose
one convention to document module level variables and be consistent
with it.
Todo:
* For module TODOs
* You have to also use ``sphinx.ext.todo`` extension
.. _Google Python Style Guide:
http://google.github.io/styleguide/pyguide.html
"""
module_level_variable1 = 12345
def my_function():
pass
...
...
봐, 난 그냥이를 발견했습니다 http://docs.python.org/devguide/documenting.html 희망이 당신을 위해 유용합니다. –