문제

그게 다야.함수나 클래스를 문서화하려면 정의 바로 뒤에 문자열을 넣으세요.예를 들어:

def foo():
    """This function does nothing."""
    pass

하지만 모듈은 어떻습니까?무엇을 문서화할 수 있나요? file.py 하다?

도움이 되었습니까?

해결책

패키지의 경우 문서화할 수 있습니다. __init__.py.모듈의 경우, 모듈 파일에 간단하게 독스트링을 추가할 수 있습니다.

모든 정보는 여기에 있습니다: http://www.python.org/dev/peps/pep-0257/

다른 팁

독스트링을 모듈의 첫 번째 문.

"""
Your module's verbose yet thorough docstring.
"""

import foo

# ...

패키지의 경우 독스트링을 추가할 수 있습니다. __init__.py.

여기는 Google 스타일 Python Docstring의 예 모듈을 문서화하는 방법에 대해 설명합니다.기본적으로 모듈에 대한 정보와 실행 방법, 모듈 레벨 변수 및 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 
... 
...

당신은 똑같은 방식으로 그것을 수행합니다.모듈의 첫 번째 명령문으로 문자열을 넣습니다.

쉽습니다. 모듈 상단에 독스트링을 추가하기만 하면 됩니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top