如何在嵌套目录中生成狮身人面像停靠? [英] How to generate sphinx docks in nested directory?

查看:29
本文介绍了如何在嵌套目录中生成狮身人面像停靠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要从嵌套文件夹结构中的脚本生成Shinx AutoDoc文档:

└── programs
    └── general_name
        └── another_folder
            ├── script1.py
            └── script2.py

由于某种原因,自动文档中没有显示script1.py和script2.py,我只能看到脚本名称:

programs.general_name.another_folder package

¶Submodules

programs.general_name.another_folder.script1 module
programs.general_name.another_folder.script2 module

完整文件夹结构:

../
├── docs
│   ├── _build
│   │   ├── doctrees
│   │   │   ├── environment.pickle
│   │   │   ├── index.doctree
│   │   │   └── rst
│   │   └── html
│   │       ├── genindex.html
│   │       ├── index.html
│   │       ├── objects.inv
│   │       ├── rst
│   │       ├── search.html
│   │       ├── searchindex.js
│   │       ├── _sources
│   │       └── _static
│   ├── conf.py
│   ├── index.rst
│   ├── make.bat
│   ├── Makefile
│   ├── rst
│   │   ├── modules.rst
│   │   ├── programs.general_name.another_folder.rst
│   │   ├── programs.general_name.rst
│   │   └── programs.rst
│   ├── _static
│   └── _templates
└── programs
    └── general_name
        └── another_folder
            ├── script1.py
            └── script2.py

我正在运行此命令:

/docs $ sphinx-apidoc -f -o rst/ ../programs/ && make html

我也试过了:

$ sphinx-apidoc -f -o rst/ ../programs/general_name/another_folder/ && make html

但在生成html文件时,脚本1模块和脚本2模块为空。

解决方案:

找到了导致问题的原因-破折号"-"。 另一个文件夹实际命名为GET_REQUESTS_FROM_SERVER-10

将文件夹重命名为GET_REQUESTS_FROM_SERVER_10后,自动停靠开始工作

推荐答案

根据sphinx-apidoc的文档:

sphinx-apidoc是一个用于自动生成Sphinx源代码的工具,它使用AutoDoc扩展名以其他自动API文档工具的风格记录整个

Sourcedir必须指向Python包

(已添加强调)

按此SO Answer

任何Python文件都是module,其名称是不带.py扩展名的文件的基本名称。package是一个Python模块的集合:一个模块是一个单独的Python文件,而包是一个包含额外__init__.py文件的Python模块的目录,以便将一个包与恰好包含一堆Python脚本的目录区分开来。

首先向每个sourcedir添加一个空的__init__.py,然后查看这是否解决了问题。

这篇关于如何在嵌套目录中生成狮身人面像停靠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆