masklinn  committed 03c2e8c

Fix generation of relative path to generated files for inclusion

a straight relpath() call would generate a path to the tempfile
relative to the build root, but Sphinx's include expects a path
relative to the document file.

Use Sphinx's API to get the absolute path to the file being build, and
generate a path relative to *that*.

  • Participants
  • Parent commits 2110741

Comments (0)

Files changed (1)


         if 'hidden' in self.options:
             return []
+        env = document.settings.env
+        doc_dir = os.path.dirname(env.doc2path(env.docname))
         patch_root = nodes.container(classes=['pq-patch'])
         for fname, path, hunks in patch:
-            relative_path = os.path.relpath(path)
+            relative_path = os.path.relpath(path, doc_dir)
                 lang = pygments.lexers.guess_lexer_for_filename(