Index: chrome/common/extensions/docs/server2/reference_resolver.py |
diff --git a/chrome/common/extensions/docs/server2/reference_resolver.py b/chrome/common/extensions/docs/server2/reference_resolver.py |
index 4a344fbf9aed4f0253bcc8a99e9833b7221beb05..e63f4e4aa22f916b4098f4b1c5f228f313514952 100644 |
--- a/chrome/common/extensions/docs/server2/reference_resolver.py |
+++ b/chrome/common/extensions/docs/server2/reference_resolver.py |
@@ -44,7 +44,6 @@ def _MakeKey(namespace, ref): |
key = key[:max_size] |
return key |
- |
not at google - send to devlin
2013/11/22 20:16:10
python style is actually to have 2 blank lines bet
benwells
2013/11/27 07:28:31
Done.
|
class ReferenceResolver(object): |
"""Resolves references to $ref's by searching through the APIs to find the |
correct node. |
@@ -170,13 +169,22 @@ class ReferenceResolver(object): |
'name': ref |
} |
- def ResolveAllLinks(self, text, namespace=None): |
+ def ResolveAllLinks(self, text, requestPath='', namespace=None): |
not at google - send to devlin
2013/11/22 20:16:10
requestPath -> request_path
benwells
2013/11/27 07:28:31
Done.
|
"""This method will resolve all $ref links in |text| using namespace |
|namespace| if not None. Any links that cannot be resolved will be replaced |
using the default link format that |SafeGetLink| uses. |
+ The links are relative, with the prefix for the path determined by |
+ inspecting request.path. |
not at google - send to devlin
2013/11/22 20:16:10
Perhaps just "Links will be generated relative to
benwells
2013/11/27 07:28:31
Done.
|
""" |
if text is None or '$ref:' not in text: |
return text |
+ |
+ link_prefix = '' |
+ # requestPath should be of the form (apps|extensions)/...../page.html. |
+ # link_prefix should that the target will point to |
+ # (apps|extensions)/target.html. |
+ if requestPath is not '': |
+ link_prefix = '../' * (requestPath.count('/') - 1) |
split_text = text.split('$ref:') |
# |split_text| is an array of text chunks that all start with the |
# argument to '$ref:'. |
@@ -204,6 +212,6 @@ class ReferenceResolver(object): |
rest = ref_and_rest[match.end():] |
ref_dict = self.SafeGetLink(ref, namespace=namespace, title=title) |
- formatted_text.append('<a href="%(href)s">%(text)s</a>%(rest)s' % |
- { 'href': ref_dict['href'], 'text': ref_dict['text'], 'rest': rest }) |
+ formatted_text.append('<a href="%s%s">%s</a>%s' % |
+ (link_prefix, ref_dict['href'], ref_dict['text'], rest)) |
return ''.join(formatted_text) |