使用sphinx autodoc,有没有一种方法可以以特殊方式格式化多行文档字符串的第一行?
考虑:
def whatever():
"""This function does something.
This really should have a full function definition, but I am too lazy.
Some more stuff.
"""
正在生成的html代码:
<dd>
<p>This function does something.</p>
<p>This really should have a full function definition, but I am too lazy. Some more stuff.</p>
</dd>
我希望它类似于:
<dd>
<p class='headline'>This function does something.</p>
<p>This really should have a full function definition, but I am too lazy. Some more stuff.</p>
</dd>
据我所知,autodoc并没有给您很多标记文档字符串的功能,尤其是在向文档字符串添加自定义样式方面。有两种方法可以解决此问题:1)将第一行包装在**This function does something**
中,以便将其加粗。 2)编写一个自定义的sphinx扩展名,该扩展名在autodoc解析文档字符串之前将其截取,并相应地处理它们。