【发布时间】:2020-10-20 19:19:55
【问题描述】:
如何将代码嵌入到文档字符串中以告诉 Sphinx 格式化代码,就像在 Markdown 中所做的一样(不同的背景颜色,等宽的无字体)?例如记录一个代码使用示例。
""" This is a module documentation
Use this module like this:
res = aFunction(something, goes, in)
print(res.avalue)
"""
【问题讨论】:
-
像这样使用 f-string
string = f"""Example {variable_name}""" -
@Abbas Sphinx 是一个文档渲染引擎。 F弦与它无关。
标签: python python-3.x python-sphinx docstring