shphinxを使ってPythonのコードからAPIドキュメント作成

無駄に苦労したのでメモ

  • shphinxのquick_start autodocはy
  • 20行目あたり,conf.pyの以下のコメントアウトを外し、sys.path.insertの表記を[srcフォルダ] へのパスにする

# import sys
# import os

# sys.path.insert(0, os.path.abspath('.'))

import sys
import os

sys.path.insert(0, os.path.abspath('[srcDirectoryPath]'))
  • extensionsの値を ["sphinx.ext.autodoc"]

  • コマンドsphinx-apidoc -f -o [出力フォルダ] [srcフォルダ]

  • index.rstの書換えmodulesの追加
.. toctree::
   :maxdepth: 2
   :caption: Contents:

   modules 
  • コマンドsphinx-build -b html [conf.pyのフォルダ] [ビルド先フォルダ]

おまけ


というかここがわかりやすかったので参考

bonbonbe.hatenablog.com