【发布时间】:2015-08-13 20:38:37
【问题描述】:
我正在使用 Sphinx autodoc 来记录我的 Python 代码。我的文档中的示例包含:
- 我不想在 HTML 文档中呈现无趣的设置代码
- 应出现在文档中的代码
例如:
Then you process file `example.txt` with `frobnicate()`:
>>> with open('example.txt', 'w') as f:
... _ = f.write("first boring line\\n")
... _ = f.write("second boring line\\n")
>>> frobnicate('example.txt')
True
我希望 Sphinx 自动文档隐藏无趣的设置代码,以便从 Sphinx 呈现的 HTML 输出仅包含:
Then you process file example.txt with frobnicate():
>>> frobnicate('example.txt')
True
显然我仍然希望 doctest 像往常一样执行整个示例。
【问题讨论】:
标签: python python-sphinx doctest autodoc