sphinx.ext.autodoc
#Sphinx_built-in拡張
https://www.sphinx-doc.org/ja/master/usage/extensions/autodoc.html
この拡張機能は、docstringでドキュメントが書かれているモジュールをインポートして、そのdocstringから、半自動的にドキュメントを取り込みます。
インポートしたいモジュールやパッケージがsys.pathで設定されているディレクトリのどれかに入っている必要がある
automodule
モジュールのドキュメントを作成
オプション
members
If set, autodoc will generate document for the members of the target module, class or exception.
「対象モジュールのメンバーのドキュメントを生成」
undoc-members
If set, autodoc will also generate document for the members not having docstrings:
「docstringを持たないメンバーもドキュメントを生成」
membersを指定した上でundoc-membersを追加する使い方と思われる(undoc-membersだけではドキュメントが表示されなかった)
Pythonドメイン(py)の.. py:function::を使った例
autodata, autoattribute
モジュールのデータメンバーとクラス属性については、特別なフォーマットでコメントの中に (コメントの開始に単に # を使う代わりに #: を使用して)、または定義の 後の docstring の中にドキュメンテーションを入れることができます。
autodocのすべてのディレクティブはnoindexというフラグオプションをサポートしています。
ドキュメントが生成されるオブジェクトと、それに含まれるメンバーに対する索引が生成されなくなります。
If you prefer NumPy or Google style docstrings over reStructuredText, you can also enable the napoleon extension
sphinx.ext.napoleon
reSTスタイル + 型ヒントならnapoleonなしでもいけそう(ref: チームメイトのためにdocstringを書こう)
使用例
jsonlines
https://jsonlines.readthedocs.io/en/latest/#api
https://github.com/wbolster/jsonlines/blob/1b080e77ddb80978b4e03568c0054eb8d8d670bd/doc/index.rst#L151-L168