封裝結構和文件設置是這樣的:如何用sphinx生成函數簽名?
$ tree .
.
├── doc
│ ├── Makefile
│ ├── README.md
│ ├── _build
│ ├── _static
│ ├── conf.py
│ ├── foo.rst
│ ├── index.rst
│ └── make.bat
└── foo
├── __init__.py
└── spam.py
$ cat foo/__init__.py
r'''
The Foo module
==============
.. autosummary::
:toctree: generated
spam
'''
$ cat foo/spam.py
r'''
The Spam Module
===============
'''
def prepare(a):
'''Prepare function.
Parameters
----------
a : int
'''
print(a)
$ cat doc/index.rst
Welcome to foo's documentation!
=====================================
API Reference
-------------
.. toctree::
:maxdepth: 1
foo
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
$ cat doc/foo.rst
.. automodule:: foo
產生獅身人面像文檔後make html
,功能prepare
上市了,但有沒有這個功能的簽名記載:
$ cat generated/foo.spam.rst
foo.spam
========
.. automodule:: foo.spam
.. rubric:: Functions
.. autosummary::
prepare
我問題在於如何生成,那麼在這種情況下如何自動生成函數簽名呢?
編碼的第一個存根? – donkopotamus
'sphinx-autogen' – RNA
您是否期待'foo.spam.rst'在'autosummary'塊中包含'prepare'簽名?因爲它不會......會由'autodoc'生成(並且插入到生成的**輸出**中) – donkopotamus