Sphinx 忽略文件名中以 _ 开头的 py 文件

发布于 2025-01-11 09:08:43 字数 1120 浏览 3 评论 0原文

我正在 测试项目中使用 Sphinx 4.4.0。我使用 sphinx.ext.autodoc 和 sphinx-apidoc。

但并非所有 py 文件都能被识别。看起来文件名中以 _ 开头的文件被忽略(例如 _mypackage.py)。但我不确定这个角色是原因还是其他原因。

您是否知道修改该行为的选项?

这是项目结构

sphinx_versuch
├── docs
│   ├── make.bat
│   ├── Makefile
│   └── source
│       ├── conf.py
│       ├── index.rst
│       ├── modules.rst
│       ├── mypackage.rst
│       ├── _static
│       └── _templates
├── LICENSE
├── README.md
├── src
│   ├── mypackage
│   │   ├── a.py
│   │   ├── b.py
│   │   ├── __init__.py
│   │   └── _mypackage.py
│   ├── setup.cfg
│   └── setup.py
└── tests
    ├── __init__.py
    ├── test_a.py
    ├── test_b.py
    └── test_mypackage.py

I am playing around with Sphinx 4.4.0 in a test project. I use sphinx.ext.autodoc and sphinx-apidoc.

But not all py files are recognized. It seams like that files with a starting _ in filename are ignored (e.g. _mypackage.py). But i am not sure if that character is the cause or something else.

Are you aware of an option to modify that behavior?

This is the project structure

sphinx_versuch
├── docs
│   ├── make.bat
│   ├── Makefile
│   └── source
│       ├── conf.py
│       ├── index.rst
│       ├── modules.rst
│       ├── mypackage.rst
│       ├── _static
│       └── _templates
├── LICENSE
├── README.md
├── src
│   ├── mypackage
│   │   ├── a.py
│   │   ├── b.py
│   │   ├── __init__.py
│   │   └── _mypackage.py
│   ├── setup.cfg
│   └── setup.py
└── tests
    ├── __init__.py
    ├── test_a.py
    ├── test_b.py
    └── test_mypackage.py

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独留℉清风醉 2025-01-18 09:08:43

sphinx-apidoc 的选项 --private-P 确保还包含私有文件(按照惯例以下划线开头) 。

参见
https://www.sphinx-apidoc.html sphinx-doc.org/en/master/man/sphinx-apidoc.html#cmdoption-sphinx-apidoc-P

The option --private or -P for sphinx-apidoc make sure that private files (which start with an underscore by convention) are included also.

See also
https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html#cmdoption-sphinx-apidoc-P

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文