How to generate sphinx docks in nested directory?(如何在嵌套目录中生成狮身人面像停靠?)
本文介绍了如何在嵌套目录中生成狮身人面像停靠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要从嵌套文件夹结构中的脚本生成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
,然后查看这是否解决了问题。
这篇关于如何在嵌套目录中生成狮身人面像停靠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:如何在嵌套目录中生成狮身人面像停靠?


基础教程推荐
猜你喜欢
- 症状类型错误:无法确定关系的真值 2022-01-01
- 哪些 Python 包提供独立的事件系统? 2022-01-01
- 使 Python 脚本在 Windows 上运行而不指定“.py";延期 2022-01-01
- Python 的 List 是如何实现的? 2022-01-01
- 如何在 Python 中检测文件是否为二进制(非文本)文 2022-01-01
- 使用 Google App Engine (Python) 将文件上传到 Google Cloud Storage 2022-01-01
- 将 YAML 文件转换为 python dict 2022-01-01
- 合并具有多索引的两个数据帧 2022-01-01
- 如何在Python中绘制多元函数? 2022-01-01
- 使用Python匹配Stata加权xtil命令的确定方法? 2022-01-01