我不能制作狮身人面像文档

2024-04-18 11:19:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我是斯芬克斯文档的新手,我尝试了一天却没有成功。我有目录“directory”和两个子目录“project”(这是我的项目的文件夹,其中包含4个python模块(file1.py,file2.py,file3.py,file4.py)和“docs”,在那里我使用sphinx-quickstart制作了所有必要的文件。然后我编辑了形态py通过取消注释

import os
import sys
sys.path.insert(0, os.path.abspath('..')) # two dots are good here for my situation?

我还编辑了索引.rst地址:

Welcome to Project's documentation!
=====================================

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   modules

我发出命令sphinx-apidoc -o . ../project/项目.rst以及模块.rst. 你知道吗

当我在docs dir中尝试“生成html”时,会出现以下错误:

WARNING: autodoc: failed to import module 'file2' from module 'project'; the following exception was raised:
No module named 'file1'
WARNING: autodoc: failed to import module 'file3' from module 'project'; the following exception was raised:
No module named 'file1'
WARNING: autodoc: failed to import module 'file4' from module 'project'; the following exception was raised:
No module named 'file1'
WARNING: autodoc: failed to import module 'file1' from module 'project'; the following exception was raised:
No module named 'file1'
WARNING: autodoc: failed to import module 'project'; the following exception was raised:
No module named 'file1'

我还有__init__.py文件,它看起来:

from file1 import *
from file2 import *
from file3 import *
from file4 import *

有人能帮我解决问题吗?你知道吗

你知道吗模块.rst地址:

project
=========

.. toctree::
   :maxdepth: 4

   project

你知道吗项目.rst地址:

project package
=================

Submodules
----------

project.file1 module
--------------------------

.. automodule:: project.file1
    :members:
    :undoc-members:
    :show-inheritance:

project.file2
------------------------------

.. automodule:: project.file2
    :members:
    :undoc-members:
    :show-inheritance:

project.file3 module
----------------------------

.. automodule:: project.file3
    :members:
    :undoc-members:
    :show-inheritance:

project.file4 module
----------------------

.. automodule:: project.file4
    :members:
    :undoc-members:
    :show-inheritance:

Module contents
---------------

.. automodule:: project
    :members:
    :undoc-members:
    :show-inheritance:

Tags: tofrompyimportprojectrstfile1file2