sphinx-doc/sphinx

Warning for include directive shows wrong path

Open

#11,755 opened on 2023年11月15日

GitHub で見る
 (2 comments) (0 reactions) (0 assignees)Python (5,625 stars) (1,985 forks)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