就是这样。如果你想要的文件的一个函数或一个班,你把一串后的定义。例如:

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.

这里是一个 例如谷歌风格Python文档字符串 关于如何模块可以记录在案。基本上有一个信息有关的模块,如何执行和信息有关模块的水平的变量和清单的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