インストール
pip install sphinx sphinx_rtd_theme sphinx-autobuild
sphinxの実行
#
# -F, conf.pyやmakeファイルを生成するオプション。スフィンクスPJの最初だけつける
# -H <PJ名>
# -A <作者>
# -V <version>
# -o <出力先ディレクトリ>
# 最後に対象のソースコードが入ったディレクトリを指定する
sphinx-apidoc -F -H kaida_PJ0525 -A Ryosuke -V 0.0.1 -o ./docs ./mylibraries
conf.py
import os
import sys
sys.path.insert(0, os.path.abspath('../mylibraries'))
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = 'kaida_lib'
copyright = '2024, ryosuke'
author = 'ryosuke'
version = '0.0.1'
release = '0.0.1'
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinx.ext.todo',
'sphinx.ext.napoleon'
]
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
language = 'ja'
# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
# -- Options for todo extension ----------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/extensions/todo.html#configuration
todo_include_todos = True
ビルド
# sphinxビルドコマンドを実行
# -b: ビルダー。HTMLを指定してあげる
# 次に、ビルド用のコードが入っているディレクトリ。つまり./docs
# 最後に、ビルド先のディレクトリ。つまり./docs/_build
sphinx-build -b html ./docs ./docs/_build