Skip to content

Commit

Permalink
Resolve all paths in the include directive (#11650)
Browse files Browse the repository at this point in the history
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 <9087854+aa-turner@users.noreply.github.com>
  • Loading branch information
mitya57 and AA-Turner committed Aug 28, 2023
1 parent 3037f85 commit 3e943d9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sphinx/directives/other.py
@@ -1,6 +1,7 @@
from __future__ import annotations

import re
from os.path import abspath
from typing import TYPE_CHECKING, Any, cast

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

# The docname to pass into the source-read event
docname = self.env.path2doc(os_path(source))
docname = self.env.path2doc(abspath(os_path(source)))
# Emit the "source-read" event
arg = [text]
self.env.app.events.emit("source-read", docname, arg)
Expand Down

0 comments on commit 3e943d9

Please sign in to comment.