Ken*_*ier 5 python documentation docstring python-sphinx
我刚刚开始使用狮身人面像,并愿意学习.
我想将我的各种函数分解到index.rst文件中的不同部分.所以每个函数都有自己的头.
因此,例如,如果我有一个名为test.py的python文件,并且在该文件中我有2个函数
def foo():
"""This prints bar"""
print("bar")
def bar():
"""This prints foo"""
print("foo")
Run Code Online (Sandbox Code Playgroud)
我怎么能在index.rst中将test.py文件中的2个函数分开.
:mod:`test` -- foo
.. automodule:: test.foo
:members:
:undoc-members:
:show-inheritance:
:mod:`test` -- bar
.. automodule:: test.bar
:members:
:undoc-members:
:show-inheritance:
Run Code Online (Sandbox Code Playgroud)
如果我能弄清楚如何分离这些函数,那么它在index.html中看起来更干净,那将是非常棒的!因为现在输出不是很干净,如果我只是运行以下:
:mod:`test` -- these are my functions
--------------------------------------------
.. automodule:: test
:members:
:undoc-members:
:show-inheritance:
Run Code Online (Sandbox Code Playgroud)
你可以用autofunction.像这样:
The test module
===============
The test module contains...
.. currentmodule:: test
The foo function
----------------
.. autofunction:: foo
The bar function
----------------
.. autofunction:: bar
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4359 次 |
| 最近记录: |