我使用Sphinx为python项目生成文档。 输出html没有保留docstring中的换行符。 示例:
代码
def testMethod(arg1,arg2):
"""
This is a test method
Arguments:
arg1: arg1 description
arg2: arg2 description
Returns:
None
"""
print "I am a test method"
斯芬克斯O/p:
TestModule.testMethod(arg1, arg2)
This is a test method
Arguments: arg1: arg1 description arg2: arg2 description
Returns: None
知道怎么修吗?
这个答案来得很晚,但也许对其他人还是有用的。
您可以在docstring中使用
reStructuredText
。这看起来像然而,从您的示例的外观来看,您似乎正在对docstring(http://google-styleguide.googlecode.com/svn/trunk/pyguide.html?showone=Comments#Comments)使用Google样式。
狮身人面像本身并不支持这些。但是,有一个名为
napoleon
的扩展名,它在https://pypi.python.org/pypi/sphinxcontrib-napoleon解析Google和Numpy风格的docstring。要使用扩展名,必须将
'sphinxcontrib.napoleon'
附加到Sphinxconf.py
(通常是doc/source/conf.py
)中的extension
列表中,这样它就变得类似于通常在重组文本中使用
保持换行符
如果将以下内容添加到主.rst文件中:
然后在标记中,您可以添加
|br|
来仅为HTML创建换行符。发件人:http://docutils.sourceforge.net/FAQ.html#how-to-indicate-a-line-break-or-a-significant-newline
相关问题 更多 >
编程相关推荐