1. ホーム
  2. python-sphinx

[解決済み] Sphinxのエラーです。不明なディレクティブタイプ "automodule" または "autoclass" があります。

2023-03-22 19:18:32

質問

Sphinxを使ってPythonのプロジェクトをドキュメント化する必要があります。しかし、私は autodoc .

プロジェクトを設定するときに、私はオプション "拡張オートドキュメント" を選択します。

.. autoclass:: Class

エラーが出ます。

ERROR: Unknown directive type "autoclass"

を構成しています。 PYTHONPATH を設定し、今は良い状態です。しかし、私はすでにこの問題があります。

私のインデックスファイルは

.. ATOM documentation master file, created by
   sphinx-quickstart on Thu Nov 22 15:24:42 2012.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

Welcome to ATOM's documentation!
================================

Contents:

.. toctree::
   :maxdepth: 2

.. automodule:: atom

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

どうすれば問題を解決できるのか、その誰かに教えてもらいたいのです。

ありがとうございます。

どのように解決するのですか?

同じことが私に起こりました! 解決するには、conf.pyの以下のような行に移動します。

extensions = ['sphinx.ext.todo', 'sphinx.ext.viewcode']

あなたのは、おそらく違って見えるでしょう。とにかく 'sphinx.ext.autodoc' を追加してください。例えば

extensions = ['sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc']

もしそうなら

extensions = []

とすれば、それを変更する。

extensions = ['sphinx.ext.autodoc']

ソース Sphinxのドキュメントです。ERROR: 不明なディレクティブタイプ "program-output"