http://www.sphinx-doc.org/en/stable/domains.html#cross-referencing-python-objectsでSphinxのドキュメントは言う、Python Sphinxの:func:と:meth:rolesの動作の違いは何ですか?
:PY:FUNC:リファレンスPythonの関数。点線の名前を使用することができます。ロールテキストには、可読性を高めるためにカッコを後に付ける必要はありません。 add_function_parentheses設定値がTrue(デフォルト)の場合、Sphinxによって自動的に追加されます。
:py:meth: オブジェクトのメソッドを参照してください。ロールテキストには、タイプ名とメソッド名を含めることができます。 型の記述内にある場合は型名を省略することができます。点線の名前を使用することができます。
しかし、私は彼らの振る舞いに違いは見出せませんでした。
ここに私が書いた私のPythonモジュールがあります。
"""foo module."""
def hello(name):
"""Print hello addressed to *name*.
Args:
name (str): Name to address.
"""
print('hello', name)
class Foo:
"""Foo class."""
def bye(self, name):
"""Print bye addressed to *name*.
Args:
name (str): Name to address.
"""
print('bye', name)
if __name__ == '__main__':
hello('world')
Foo().bye('python')
これは私のindex.rst
ファイルの内容です。
Foo Documentation
=================
See :func:`foo.hello` and :func:`foo.Foo.bye`.
Also, see :meth:`foo.hello` and :meth:`foo.Foo.bye`.
foo module
==========
.. automodule:: foo
:members:
make html
を実行すると、これは私が見る出力です。
両方:func:
と:meth:
役割に関係なく、ターゲットが関数またはメソッドであるか否かのhello
とFoo.bye
に有効な相互参照ハイパーリンクを生成しました。
次に、:func:
と:meth:
の役割の違いは何ですか。彼らの行動が違っている例を教えてください。