diff options
| -rw-r--r-- | sphinx/directives/other.py | 8 | ||||
| -rw-r--r-- | sphinx/util/__init__.py | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 8a4224a9..2aa5a7fb 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -8,14 +8,13 @@ """ import re -import posixpath from docutils import nodes from docutils.parsers.rst import directives from sphinx import addnodes from sphinx.locale import pairindextypes -from sphinx.util import patfilter, ws_re, caption_ref_re +from sphinx.util import patfilter, ws_re, caption_ref_re, docname_join from sphinx.util.compat import make_admonition @@ -25,7 +24,6 @@ def toctree_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): env = state.document.settings.env suffix = env.config.source_suffix - dirname = posixpath.dirname(env.docname) glob = 'glob' in options ret = [] @@ -49,14 +47,14 @@ def toctree_directive(name, arguments, options, content, lineno, if docname.endswith(suffix): docname = docname[:-len(suffix)] # absolutize filenames - docname = posixpath.normpath(posixpath.join(dirname, docname)) + docname = docname_join(env.docname, docname) if docname not in env.found_docs: ret.append(state.document.reporter.warning( 'toctree references unknown document %r' % docname, line=lineno)) else: includefiles.append(docname) else: - patname = posixpath.normpath(posixpath.join(dirname, entry)) + patname = docname_join(env.docname, entry) docnames = sorted(patfilter(all_docnames, patname)) for docname in docnames: all_docnames.remove(docname) # don't include it again diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 04be80d1..1d654134 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -15,6 +15,7 @@ import sys import time import fnmatch import tempfile +import posixpath import traceback from os import path @@ -48,6 +49,11 @@ def relative_uri(base, to): return ('..' + SEP) * (len(b2)-1) + SEP.join(t2) +def docname_join(basedocname, docname): + return posixpath.normpath( + posixpath.join('/' + basedocname, '..', docname))[1:] + + def ensuredir(path): """Ensure that a path exists.""" try: |
