반응형
파이썬으로 모듈을 어떻게 문서화합니까?
그게 다야. 함수 나 클래스를 문서화하려면 정의 바로 뒤에 문자열을 넣습니다. 예를 들면 :
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
...
...
당신은 똑같은 방식으로 그것을합니다. 모듈의 첫 번째 명령문으로 문자열을 넣으십시오.
간단합니다. 모듈 상단에 독 스트링을 추가하기 만하면됩니다.
PyPI 패키지의 경우 :
아래와 같이 __init__.py 파일 에 이와 같은 문서 문자열을 추가하면
"""
Please refer to the documentation provided in the README.md,
which can be found at gorpyter's PyPI URL: https://pypi.org/project/gorpyter/
"""
# <IMPORT_DEPENDENCIES>
def setup():
"""Verify your Python and R dependencies."""
그러면 도움말 기능을 일상적으로 사용할 때 이것을 받게됩니다.
help(<YOUR_PACKAGE>)
DESCRIPTION
Please refer to the documentation provided in the README.md,
which can be found at gorpyter's PyPI URL: https://pypi.org/project/gorpyter/
FUNCTIONS
setup()
Verify your Python and R dependencies.
내 도움 DESCRIPTION
은 파일 맨 위에 첫 번째 독 스트링이 있으면 트리거됩니다.
참고 URL : https://stackoverflow.com/questions/44084/how-do-i-document-a-module-in-python
반응형
'developer tip' 카테고리의 다른 글
Microsoft Edge가 일부 로컬 웹 사이트를 열지 만 다른 웹 사이트는 열지 않는 이유는 도메인 이름이 호스트 파일에서 127.0.0.1로 라우팅되는 이유 (0) | 2020.11.17 |
---|---|
Angular 2에서 클릭 이벤트에 대한 함수 호출 (0) | 2020.11.17 |
WPF ListView 항목을 가로 스크롤 막대처럼 가로로 반복하려면 어떻게해야합니까? (0) | 2020.11.16 |
WPF 전역 글꼴 크기 (0) | 2020.11.16 |
테이블 행 수를 얻는 가장 효율적인 방법 (0) | 2020.11.16 |