我将 sphinx 与numpydocs
,doctest
和 scipy 主题一起使用。
在文档字符串中使用.. plot::
时,所有图都被创建,除了没有显示它们被调用的位置,它们都移动到文档的末尾。有没有办法强制它内联,而不需要在.rst
文件中重写示例?这是我的example.py
文件文档字符串的样子:
.. plot::
>>> import numpy as np
>>> import matplotlib.pylab as plt
# commentary breaking the block
Finished Imports
>>> x = np.linspace(-np.pi*2, np.pi*2, 2000)
>>> y = np.sin(x)
>>> plt.plot(x, y)#doctest: +SKIP
>>> plt.show()#doctest: +SKIP
First plot should be here
>>> x2 = x
>>> plt.plot(x2, y)#doctest: +SKIP
>>> plt.show()#doctest: +SKIP
Second plot should be here
……
But both are here.
或者,我尝试添加另一种.. plot::
方法,但它改变了范围。
.. plot::
>>> import numpy as np
>>> import matplotlib.pylab as plt
# commentary breaking the block
Finished Imports
>>> x = np.linspace(-np.pi*2, np.pi*2, 2000)
>>> y = np.sin(x)
>>> plt.plot(x, y)#doctest: +SKIP
>>> plt.show()#doctest: +SKIP
First plot should be here
.. plot::
>>> x2 = x
>>> plt.plot(x2, y)#doctest: +SKIP
>>> plt.show()#doctest: +SKIP
使用make html
will state时x
未定义。