【发布时间】:2011-07-17 02:41:56
【问题描述】:
我目前从 Python 开始,我有很强的 PHP 背景,在 PHP 中我习惯使用javadoc 作为文档模板。
我想知道 javadoc 是否在 Python 中作为 docstring 文档的位置。 这里的既定惯例和/或官方准则是什么?
例如像这样的东西太复杂了,不适合 Python 的思维方式,还是我应该尽量简洁?
"""
replaces template place holder with values
@param string timestamp formatted date to display
@param string priority priority number
@param string priority_name priority name
@param string message message to display
@return string formatted string
"""
如果我有点过于详尽,我应该改用这样的东西吗(大多数文档都没有通过__doc__ 方法打印出来)?
# replaces template place holder with values
#
# @param string timestamp formatted date to display
# @param string priority priority number
# @param string priority_name priority name
# @param string message message to display
#
# @return string formatted string
def format(self, timestamp = '', priority = '', priority_name = '', message = ''):
"""
replaces template place holder with values
"""
values = {'%timestamp%' : timestamp,
'%priorityName%' : priority_name,
'%priority%' : priority,
'%message%' : message}
return self.__pattern.format(**values)
【问题讨论】:
-
Thera 在earlier question 上也有更多答案,这是重复的。
标签: python documentation javadoc docstring