Skip to content

Commit 3e943d9

Browse files
mitya57AA-Turner
andauthored
Resolve all paths in the include directive (#11650)
Because pytest's base tmp_path is also in /tmp, ``source`` here is relative path, and thus is not properly converted to doc name. So the test fails because `sources_reported` dict has a key like ``../../../pytest/pytest-0/directive-include/baz/baz``, and ``assert "baz/baz" in sources_reported`` fails. Co-authored-by: Adam Turner <[email protected]>
1 parent 3037f85 commit 3e943d9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sphinx/directives/other.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import re
4+
from os.path import abspath
45
from typing import TYPE_CHECKING, Any, cast
56

67
from docutils import nodes
@@ -386,7 +387,7 @@ def _insert_input(include_lines, source):
386387
text = "\n".join(include_lines[:-2])
387388

388389
# The docname to pass into the source-read event
389-
docname = self.env.path2doc(os_path(source))
390+
docname = self.env.path2doc(abspath(os_path(source)))
390391
# Emit the "source-read" event
391392
arg = [text]
392393
self.env.app.events.emit("source-read", docname, arg)

0 commit comments

Comments
 (0)