# 【Python】Python中的多行注释文档编写风格汇总

【笔记】

Epytext风格比较紧凑（推荐）；

================================

A docstring is a string literal that occurs as the first statement in
a module, function, class, or method definition. Such a docstring
becomes the __doc__ special attribute of that object.

 12 def foo():  """ This is function foo"""

Epytext

 12345678 """This is a javadoc style. @param param1: this is a first param@param param2: this is a second param@return: this is a description of what is returned@raise keyError: raises an exception"""

reST

 12345678 """This is a reST style. :param param1: this is a first param:param param2: this is a second param:returns: this is a description of what is returned:raises keyError: raises an exception"""

 12345678910111213 """This is a groups style docs. Parameters:  param1 - this is the first param  param2 - this is a second param Returns:  This is a description of what is returned Raises:  KeyError - raises an exception"""

Numpydoc (Numpy风格)

 12345678910111213141516171819202122232425 """My numpydoc description of a kindof very exhautive numpydoc format docstring. Parameters----------first : array_like  the 1st param name firstsecond :  the 2nd paramthird : {'value', 'other'}, optional  the 3rd param, by default 'value' Returns-------string  a value in a string Raises------KeyError  when a key errorOtherError  when an other error"""

docstring工具之第三方库pyment

 12 $pyment test.py #生成patch$ patch -p1 < test.py.patch #打patch

©️2019 CSDN 皮肤主题: 编程工作室 设计师: CSDN官方博客