diff options
author | Georg Brandl <georg@python.org> | 2008-02-01 20:44:17 +0000 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-02-01 20:44:17 +0000 |
commit | b2ec05e690aa2870967ed188ac9a3be0b0fd8db6 (patch) | |
tree | b250499a21cd2db4748cb1a0102e882120878a5e /sphinx/directives.py | |
parent | 8ca7c9144317ca8ce1b1f29383174a884ac910b3 (diff) | |
download | sphinx-git-b2ec05e690aa2870967ed188ac9a3be0b0fd8db6.tar.gz |
More refactoring, this time allowing different file extensions
and a different master file. Also fix environment warning reporting
and improve handling of error conditions.
Diffstat (limited to 'sphinx/directives.py')
-rw-r--r-- | sphinx/directives.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/sphinx/directives.py b/sphinx/directives.py index 2d9dac1eb..5a712c322 100644 --- a/sphinx/directives.py +++ b/sphinx/directives.py @@ -539,15 +539,28 @@ directives.register_directive('moduleauthor', author_directive) def toctree_directive(name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): env = state.document.settings.env - dirname = posixpath.dirname(env.filename) + suffix = env.config.source_suffix + dirname = posixpath.dirname(env.docname) + ret = [] subnode = addnodes.toctree() - includefiles = filter(None, content) - # absolutize filenames - includefiles = [posixpath.normpath(posixpath.join(dirname, x)) for x in includefiles] + includefiles = [] + for docname in content: + if not docname: + continue + # absolutize filenames, remove suffixes + if docname.endswith(suffix): + docname = docname[:-len(suffix)] + docname = posixpath.normpath(posixpath.join(dirname, docname)) + if docname not in env.found_docs: + ret.append(state.document.reporter.warning( + 'toctree references unknown document %s' % docname, line=lineno)) + else: + includefiles.append(docname) subnode['includefiles'] = includefiles subnode['maxdepth'] = options.get('maxdepth', -1) - return [subnode] + ret.append(subnode) + return ret toctree_directive.content = 1 toctree_directive.options = {'maxdepth': int} |