我正在使用Sphinx来记录返回字典的方法。
def do_stuff(foo, bar):
"""Do some stuff
:param foo: I'm an argument
:param bar: So am I
:return: dict::
{
"success": (Boolean) True if stuff was done
"meta": {
"aaa": A nested return value
"bbb": Another nested return value
}
}
"""
字典对象的格式设置为:
我可以说,问题是RST中的字符串文字预计会缩进到同一级别。
有解决方法吗?
答案 0 :(得分:2)
缩进::
然后进一步缩进字典,将其识别为代码块。这是使用.. autofunction:: do_stuff
和sphinx 1.5.2。
def do_stuff(foo, bar):
"""Do some stuff
:param foo: I'm an argument
:param bar: So am I
:return: dict
::
{
"success": (Boolean) True if stuff was done
"meta": {
"aaa": A nested return value
"bbb": Another nested return value
}
}
"""
当我把dict部分分开时,我不得不这样格式化。
def do_stuff(foo, bar):
"""Do some stuff
:param foo: I'm an argument
:param bar: So am I
:rtype: dict
:return:
::
{
"success": (Boolean) True if stuff was done
"meta": {
"aaa": A nested return value
"bbb": Another nested return value
}
}
"""