Follow links when searching documents and document changes from Armin.

This commit is contained in:
Georg Brandl 2008-04-27 15:48:24 +00:00
parent 6d51bd128e
commit 5fa51aa5a0
2 changed files with 30 additions and 1 deletions

View File

@ -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)
================================

View File

@ -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: