sphinx创建一个空文档

2024-07-01 08:21:31 发布

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

假设以下是我的代码结构:

   A/
       __init__.py
       B.py
    
  Run.py

我继续安装sphinx和numpydoc扩展。然后我发布sphinx quickstart并选择默认值(不要将源代码和生成器分开),然后我有以下文件:

   A/
      docs/
           conf.py
           index.rst
           static
           templates
      __init__.py
      B.py
  Run.py

下一步我编辑index.rst并添加以下内容:

    .. automodule:: Run
       :members:

然后我编辑conf.py,如下所示:

     import os
     import sys
     sys.path.insert(0, os.path.abspath('../..'))

然后我cd进入docs目录并发出makehtml,但是当我打开index.HTML文件时,我没有看到任何文档,它是空的

我在网上和这里搜索了所有的帖子,但没有一篇适合我

我想知道谁能告诉我:

1-如果我所做的是正确的

2-由于我在我的docstring中使用numpydoc约定,这可能是我不使用的原因吗 看到什么了吗

编辑:我将项目和源代码分离,并运行sphinx apidoc-o./source。。这会为A.rst和modules.rst生成另外两个rst文件,我相应地更改了index.rst,但是在运行make HTML之后,我收到警告:没有模块名称A,并且无法从模块A导入B

A/
      __init__.py
      B.py
      source/
             module.rst
             index.rst
             A.rst
Run.py

顺便说一句,我补充说

'sphinx.ext.autodoc','sphinx.ext.napoleon'

到conf.py中的扩展列表

这是my index.rst的内容:

.. toctree::
   :maxdepth: 2
   :caption: Contents:
   
   A
   modules   
   


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

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

Tags: 文件runpyimportref编辑docsindex

热门问题