summaryrefslogtreecommitdiff
path: root/sandbox/py-rest-doc/sphinx/web/application.py
diff options
context:
space:
mode:
authorblackbird <blackbird@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-05-22 13:14:50 +0000
committerblackbird <blackbird@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-05-22 13:14:50 +0000
commitff997d5a24d0f427e785ebaab42ae6b65e74c38c (patch)
treebffff49c6143c931af69baeedfcd094e47e5614a /sandbox/py-rest-doc/sphinx/web/application.py
parent49b51ed098782ea4b802264e98182adad0e2f4f5 (diff)
downloaddocutils-ff997d5a24d0f427e785ebaab42ae6b65e74c38c.tar.gz
added close matches
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@5086 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/py-rest-doc/sphinx/web/application.py')
-rw-r--r--sandbox/py-rest-doc/sphinx/web/application.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/sandbox/py-rest-doc/sphinx/web/application.py b/sandbox/py-rest-doc/sphinx/web/application.py
index 81af09b9f..48f18ef49 100644
--- a/sandbox/py-rest-doc/sphinx/web/application.py
+++ b/sandbox/py-rest-doc/sphinx/web/application.py
@@ -100,20 +100,30 @@ class DocumentationApplication(object):
Lookup close matches. If there is an exact match (for example
http://docs.python.org/os.path.exists would automatically
redirect to http://docs.python.org/modules/os.path/#os.path.exists.
+
+ Module references are processed first so that "os.path" is
+ handled as module and not as member of os.
"""
+ # module references
+ if url in self.environment.modules:
+ filename, title, system = self.environment.modules[url]
+ url = get_target_uri(filename)
+ return RedirectResponse(url)
# direct references
if url in self.environment.descrefs:
filename, ref_type = self.environment.descrefs[url]
url = get_target_uri(filename) + '#' + url
return RedirectResponse(url)
- # module references
- # XXX: should those have a higher priority?
- if url in self.environment.modules:
- filename, title, arg = self.environment.modules[url]
- url = get_target_uri(filename)
- return RedirectResponse(url)
- # XXX: do a difflib match test here
- return Response(render_template(req, 'not_found.html'), status=404)
+ # get some close matches
+ close_matches = []
+ for type, filename, title in self.environment.get_close_matches(url):
+ link = get_target_uri(filename)
+ if type == 'ref':
+ link += '#' + title
+ close_matches.append((relative_uri(url + '/', link), title))
+ return Response(render_template(req, 'not_found.html', {
+ 'close_matches': close_matches
+ }), status=404)
def __call__(self, environ, start_response):
"""