Django Sphinx编译错误:找不到index.rst,并且警告:未知指令

问题描述

我正面临着一个奇怪的错误在这里我有一个在本地运行得很好的Django项目,我什至生成了文档,而且一切进展顺利。 问题是,当我在https://readthedocs.org/中导入项目时,编译失败,我几乎尝试了所有方法,但始终遇到相同的问题。

我使用Django == 2.2 Python == 3.7.8

我的项目结构:

- Myproject
  -- docs
     -- build
     -- source
        - conf.py
        - index.rst
        - file.rst
        - another_file.rst
     make.bat
     Makefile
     requirements.txt
 -- MyprojectDir
 -- MyappDir
     

我的源目录中的conf.py文件如下所示:

# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,# add these directories to sys.path here. If the directory is relative to the
# documentation root,use os.path.abspath to make it absolute,like shown here.
#
# import os
# import sys
# sys.path.insert(0,os.path.abspath('.'))


# -- Project information -----------------------------------------------------

import os
import sys
import django
cwd = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0,os.path.abspath(os.path.join(cwd,'../../')))
os.environ['DJANGO_SETTINGS_MODULE'] = 'vtcvlp.settings'
django.setup()

from sphinx.ext.autosummary import Autosummary
from sphinx.ext.autosummary import get_documenter
from docutils.parsers.rst import directives
from sphinx.util.inspect import safe_getattr
import re


class AutoAutoSummary(Autosummary):

    option_spec = {
        'methods': directives.unchanged,'attributes': directives.unchanged
    }

    required_arguments = 1

    @staticmethod
    def get_members(obj,typ,include_public=None):
        if not include_public:
            include_public = []
        items = []
        for name in dir(obj):
            try:
                documenter = get_documenter(safe_getattr(obj,name),obj)
            except AttributeError:
                continue
            if documenter.objtype == typ:
                items.append(name)
        public = [x for x in items if x in include_public or not x.startswith('_')]
        return public,items

    def run(self):
        clazz = str(self.arguments[0])
        try:
            (module_name,class_name) = clazz.rsplit('.',1)
            m = __import__(module_name,globals(),locals(),[class_name])
            c = getattr(m,class_name)
            if 'methods' in self.options:
                _,methods = self.get_members(c,'method',['__init__'])

                self.content = ["~%s.%s" % (clazz,method) for method in methods if not method.startswith('_')]
            if 'attributes' in self.options:
                _,attribs = self.get_members(c,'attribute')
                self.content = ["~%s.%s" % (clazz,attrib) for attrib in attribs if not attrib.startswith('_')]
        finally:
            return super(AutoAutoSummary,self).run()


def setup(app):
    app.add_directive('autoautosummary',AutoAutoSummary)


project = 'vtc-video-link-post'
copyright = '2020,MBAMBA FABRICE damIEN'
author = 'MBAMBA FABRICE damIEN'

# The full version,including alpha/beta/rc tags
release = '1.0'
master_doc = 'index'
autosummary_generate = True

source_suffix = [".rst",".md"]
pygments_style = "sphinx"

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here,as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc','sphinx.ext.doctest','sphinx.ext.intersphinx','sphinx.ext.todo','sphinx.ext.ifconfig','sphinx.ext.viewcode','sphinx.ext.inheritance_diagram','sphinx.ext.autosummary','recommonmark','sphinx.ext.coverage'
              'sphinx.ext.ifconfig','sphinx_autodoc_typehints',]

# Add any paths that contain templates here,relative to this directory.
templates_path = ['_templates']

# List of patterns,relative to source directory,that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Add any paths that contain custom static files (such as style sheets) here,# relative to this directory. They are copied after the builtin static files,# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

https://readthedocs.org/中编译文档时,出现此错误,但它安装了所有需求文件

Running Sphinx v3.2.1
loading translations [en]... done
making output directory... done
building [mo]: targets for 0 po files that are out of date
building [readthedocs]: targets for 5 source files that are out of date
updating environment: [new config] 5 added,0 changed,0 removed
reading sources... [ 20%] source/index
reading sources... [ 40%] source/intro
reading sources... [ 60%] source/launch
reading sources... [ 80%] source/usage
reading sources... [100%] source/vtcvlp

/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/checkouts/latest/docs/source/vtcvlp.rst:7: WARNING: UnkNown directive type "autoclass".

.. autoclass:: vtcuser.models.CustomUser
    :members:
    :undoc-members:
    :show-inheritance:

    .. rubric:: Methods

    .. autoautosummary:: vtcuser.models.CustomUser
        :methods:

    .. rubric:: Attributes

    .. autoautosummary:: vtcuser.models.CustomUser
        :attributes:
/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/checkouts/latest/docs/source/vtcvlp.rst:24: WARNING: UnkNown directive type "autoclass".

.. autoclass:: vtcuser.models.VideoLink
    :members:
    :undoc-members:
    :show-inheritance:

    .. rubric:: Methods

    .. autoautosummary:: vtcuser.models.VideoLink
        :methods:

    .. rubric:: Attributes

    .. autoautosummary:: vtcuser.models.VideoLink
        :attributes:
/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/checkouts/latest/docs/source/vtcvlp.rst:41: WARNING: UnkNown directive type "autoclass".

.. autoclass:: vtcuser.api.CustomUserViewSet
    :members:
    :undoc-members:

    .. rubric:: Methods

    .. autoautosummary:: vtcuser.api.CustomUserViewSet
        :methods:

    .. rubric:: Attributes

    .. autoautosummary:: vtcuser.api.CustomUserViewSet
        :attributes:
/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/checkouts/latest/docs/source/vtcvlp.rst:57: WARNING: UnkNown directive type "autoclass".

.. autoclass:: vtcuser.api.VideoLinkViewSet
    :members:
    :undoc-members:
    :show-inheritance:

    .. rubric:: Methods

    .. autoautosummary:: vtcuser.api.VideoLinkViewSet
        :methods:

    .. rubric:: Attributes

    .. autoautosummary:: vtcuser.api.VideoLinkViewSet
        :attributes:
/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/checkouts/latest/docs/source/vtcvlp.rst:74: WARNING: UnkNown directive type "autoclass".

.. autoclass:: vtcuser.serializers.CustomUserSerializer
    :members:
    :undoc-members:
    :show-inheritance:

    .. rubric:: Methods

    .. autoautosummary:: vtcuser.serializers.CustomUserSerializer
        :methods:

    .. rubric:: Attributes

    .. autoautosummary:: vtcuser.serializers.CustomUserSerializer
        :attributes:
/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/checkouts/latest/docs/source/vtcvlp.rst:91: WARNING: UnkNown directive type "autoclass".

.. autoclass:: vtcuser.serializers.VideoLinkSerializer
    :members:
    :undoc-members:
    :show-inheritance:

    .. rubric:: Methods

    .. autoautosummary:: vtcuser.serializers.VideoLinkSerializer
        :methods:

    .. rubric:: Attributes

    .. autoautosummary:: vtcuser.serializers.VideoLinkSerializer
        :attributes:
/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/checkouts/latest/docs/source/vtcvlp.rst:109: WARNING: UnkNown directive type "automodule".

.. automodule:: vtcuser.views
    :members:
    :undoc-members:
    :show-inheritance:

Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py",line 280,in build_main
    app.build(args.force_all,filenames)
  File "/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/envs/latest/lib/python3.7/site-packages/sphinx/application.py",line 348,in build
    self.builder.build_update()
  File "/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/envs/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py",line 299,in build_update
    len(to_build))
  File "/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/envs/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py",line 311,in build
    updated_docnames = set(self.read())
  File "/home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/envs/latest/lib/python3.7/site-packages/sphinx/builders/__init__.py",line 422,in read
    self.env.doc2path(self.config.master_doc))
sphinx.errors.SphinxError: master file /home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/checkouts/latest/docs/index.rst not found

Sphinx error:
master file /home/docs/checkouts/readthedocs.org/user_builds/vtc-vlp/checkouts/latest/docs/index.rst not found

本地化效果很好:

Running Sphinx v3.2.1
making output directory... done
[autosummary] generating autosummary for: index.rst,intro.rst,launch.rst,usage.rst,vtcvlp.rst
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 5 source files that are out of date
updating environment: [new config] 5 added,0 removed
reading sources... [100%] vtcvlp
looking for Now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] vtcvlp
generating indices...  genindex py-modindexdone
highlighting module code... [100%] vtcuser.views
writing additional pages...  searchdone
copying images... [100%] capture4.png
copying static files... ... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.

The HTML pages are in build\html.

阅读文档错误日志详细信息:---- >>>> The build log details

我在哪里出错了?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)