mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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 <9087854+aa-turner@users.noreply.github.com>
This commit is contained in:
parent
3037f8599c
commit
3e943d9e79
@ -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
|
||||
@ -386,7 +387,7 @@ class Include(BaseInclude, SphinxDirective):
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user