diff options
author | Georg Brandl <georg@python.org> | 2009-02-24 13:38:15 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2009-02-24 13:38:15 +0100 |
commit | fb511a015aa47c943c5dc1286f58743fca307b1c (patch) | |
tree | 737f4a288eaaf69898c3139fdb0c79499c4bf910 /sphinx/directives/code.py | |
parent | 29247f0896fc66a54d2fe77d05d32b0786c84a18 (diff) | |
download | sphinx-git-fb511a015aa47c943c5dc1286f58743fca307b1c.tar.gz |
Paths to literal include files and download files can now be absolute too.
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r-- | sphinx/directives/code.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 70aecd83e..645bc7844 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -7,6 +7,7 @@ :license: BSD, see LICENSE for details. """ +import os import sys import codecs from os import path @@ -95,11 +96,12 @@ class LiteralInclude(Directive): return [document.reporter.warning('File insertion disabled', line=self.lineno)] env = document.settings.env - rel_fn = filename - sourcename = self.state_machine.input_lines.source( - self.lineno - self.state_machine.input_offset - 1) - source_dir = path.dirname(path.abspath(sourcename)) - fn = path.normpath(path.join(source_dir, rel_fn)) + if filename.startswith('/') or filename.startswith(os.sep): + rel_fn = filename[1:] + else: + docdir = path.dirname(env.doc2path(env.docname, base=None)) + rel_fn = path.normpath(path.join(docdir, filename)) + fn = path.join(env.srcdir, rel_fn) if 'pyobject' in self.options and 'lines' in self.options: return [document.reporter.warning( |