sphinx-doc/sphinx

Warning for include directive shows wrong path

Open

#11.755 aperta il 15 nov 2023

Vedi su GitHub
 (2 commenti) (0 reazioni) (0 assegnatari)Python (1985 fork)batch import
help wantedtype:docs

Metriche repository

Star
 (5625 star)
Metriche merge PR
 (Merge medio 13g 10h) (8 PR mergiate in 30 g)

Descrizione

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

Guida contributor