sphinx-doc/sphinx

Warning for include directive shows wrong path

Open

#11,755 创建于 2023年11月15日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)Python (5,625 star) (1,985 fork)batch import
help wantedtype:docs

描述

Describe the bug

If the author provides an absolute path to the include directive, and the file does not exist, the warning message prepends the relative path of the document containing the include directive, which leads to confusing output.

E.g., a file "source/index.rst" in a folder named /home/user/projects/sphinx-include-example contains:

.. include:: /home/user/projects/sphinx-include-example/build/generated_images.rst

The file does not exist. The warning message is:

/home/user/projects/sphinx-include-example/source/index.rst:16: CRITICAL: Problems with "include" directive path:
InputError: [Errno 2] No such file or directory: 'source/home/user/projects/sphinx-include-example/build/generated_images.rst'.

How to Reproduce

  • Create a minimal example with sphinx-quickstart, with separate build paths
  • Add the above include directive to index.rst
  • run make html

Environment Information

Platform:              linux; (Linux-5.15.0-88-generic-x86_64-with-glibc2.35)
Python version:        3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0])
Python implementation: CPython
Sphinx version:        5.3.0
Docutils version:      0.17.1
Jinja2 version:        3.0.3

Sphinx extensions

none

Additional context

Tested also with sphinx 6.1.3, the issue is the same:

```text
Platform:              linux; (Linux-5.15.0-88-generic-x86_64-with-glibc2.35)
Python version:        3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0])
Python implementation: CPython
Sphinx version:        6.1.3
Docutils version:      0.18.1
Jinja2 version:        3.0.3
Pygments version:      2.16.1

贡献者指南

Warning for include directive shows wrong path · sphinx-doc/sphinx#11755 | Good First Issue