From 5fa51aa5a0681ded545ce976ba90b1dcb8f503d8 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 27 Apr 2008 15:48:24 +0000 Subject: [PATCH] Follow links when searching documents and document changes from Armin. --- CHANGES | 5 +++++ sphinx/util/__init__.py | 26 +++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 5c742a73b..a018d451d 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,9 @@ Incompatible changes and putting ``'index': name of your template`` in ``html_additional_pages``. +* In the layout template, redundant ``block``\s were removed; you should use + Jinja's standard ``{{ super() }}`` mechanism instead. + New features added ------------------ @@ -83,6 +86,8 @@ Bugs fixed * sphinx.builder, sphinx.environment: Gracefully handle some user error cases. +* sphinx.util: Follow symbolic links when searching for documents. + Release 0.1.61950 (Mar 26, 2008) ================================ diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index dba5055c6..94ca66843 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -50,6 +50,30 @@ def ensuredir(path): raise +def walk(top, topdown=True, followlinks=False): + """ + Backport of os.walk from 2.6, where the followlinks argument was added. + """ + names = os.listdir(top) + + dirs, nondirs = [], [] + for name in names: + if path.isdir(path.join(top, name)): + dirs.append(name) + else: + nondirs.append(name) + + if topdown: + yield top, dirs, nondirs + for name in dirs: + fullpath = path.join(top, name) + if followlinks or not path.islink(fullpath): + for x in walk(fullpath, topdown, followlinks): + yield x + if not topdown: + yield top, dirs, nondirs + + def get_matching_docs(dirname, suffix, exclude=(), prune=()): """ Get all file names (without suffix) matching a suffix in a @@ -61,7 +85,7 @@ def get_matching_docs(dirname, suffix, exclude=(), prune=()): # dirname is a normalized absolute path. dirname = path.normpath(path.abspath(dirname)) dirlen = len(dirname) + 1 # exclude slash - for root, dirs, files in os.walk(dirname): + for root, dirs, files in walk(dirname, followlinks=True): dirs.sort() files.sort() for prunedir in prune: