Sphinx 自动函数生成 python 没有换行符的文档字符串
Sphinx autofunction generate python docstring without newlines
我有一个简单的 python 包,其中包含 1 个包含以下功能的模块:
def sample_addition(num1=1, num2=2):
"""adding 2 numbers as an example
this function will add 2 numbers in case of failre it will raise an exception
@param num1: first number
@type num1: float
@param num2: second number
@type num2: float
@return: addition result
@rtype: float
"""
return num1 + num2
当使用 .. autofunction:: sample_addition
和 make html
时,结果是:
general.sample_addition(num1=1, num2=2)
adding 2 numbers as an example
this function will add 2 numbers in case of failre it will raise an exception @param num1: first number @type num1: float @param num2: second number @type num2: float @return: addition result @rtype: float
我已经在 conf.py -> extensions
中安装并使用了 sphinx_epytext
,但它无助于正确转换和显示 Epytext
问题:
我怎样才能让它看到文档字符串中的新行?
就像markdown和rst一样,需要换行来分隔不同的段落,你需要在this function...
和@param ...
之间添加换行符,就像这样:
def sample_addition(num1=1, num2=2):
"""adding 2 numbers as an example
this function will add 2 numbers in case of failre it will raise an exception
@param num1: first number
@type num1: float
@param num2: second number
@type num2: float
@return: addition result
@rtype: float
"""
return num1 + num2
我有一个简单的 python 包,其中包含 1 个包含以下功能的模块:
def sample_addition(num1=1, num2=2):
"""adding 2 numbers as an example
this function will add 2 numbers in case of failre it will raise an exception
@param num1: first number
@type num1: float
@param num2: second number
@type num2: float
@return: addition result
@rtype: float
"""
return num1 + num2
当使用 .. autofunction:: sample_addition
和 make html
时,结果是:
general.sample_addition(num1=1, num2=2)
adding 2 numbers as an example
this function will add 2 numbers in case of failre it will raise an exception @param num1: first number @type num1: float @param num2: second number @type num2: float @return: addition result @rtype: float
我已经在 conf.py -> extensions
中安装并使用了 sphinx_epytext
,但它无助于正确转换和显示 Epytext
问题:
我怎样才能让它看到文档字符串中的新行?
就像markdown和rst一样,需要换行来分隔不同的段落,你需要在this function...
和@param ...
之间添加换行符,就像这样:
def sample_addition(num1=1, num2=2):
"""adding 2 numbers as an example
this function will add 2 numbers in case of failre it will raise an exception
@param num1: first number
@type num1: float
@param num2: second number
@type num2: float
@return: addition result
@rtype: float
"""
return num1 + num2