diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 8caef4f05fb..20fb05b5048 100644 --- a/sphinx/directives/other.py +++ b/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 @@ -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)