summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/common/extensions/docs/server2/app.yaml2
-rw-r--r--chrome/common/extensions/docs/server2/cron.yaml2
-rw-r--r--chrome/common/extensions/docs/server2/document_renderer.py10
-rwxr-xr-xchrome/common/extensions/docs/server2/document_renderer_test.py86
4 files changed, 58 insertions, 42 deletions
diff --git a/chrome/common/extensions/docs/server2/app.yaml b/chrome/common/extensions/docs/server2/app.yaml
index 8398139..4ba9a44 100644
--- a/chrome/common/extensions/docs/server2/app.yaml
+++ b/chrome/common/extensions/docs/server2/app.yaml
@@ -1,5 +1,5 @@
application: chrome-apps-doc
-version: 3-39-2
+version: 3-39-3
runtime: python27
api_version: 1
threadsafe: false
diff --git a/chrome/common/extensions/docs/server2/cron.yaml b/chrome/common/extensions/docs/server2/cron.yaml
index f03c1d9..e34952b 100644
--- a/chrome/common/extensions/docs/server2/cron.yaml
+++ b/chrome/common/extensions/docs/server2/cron.yaml
@@ -2,4 +2,4 @@ cron:
- description: Repopulates all cached data.
url: /_cron
schedule: every 5 minutes
- target: 3-39-2
+ target: 3-39-3
diff --git a/chrome/common/extensions/docs/server2/document_renderer.py b/chrome/common/extensions/docs/server2/document_renderer.py
index 6a03375..2e3556f 100644
--- a/chrome/common/extensions/docs/server2/document_renderer.py
+++ b/chrome/common/extensions/docs/server2/document_renderer.py
@@ -79,8 +79,10 @@ class DocumentRenderer(object):
path=path)
new_document.append(document[cursor_index:start_ref_index])
- new_document.append('<a href=%s>%s</a>' % (ref_dict['href'],
- ref_dict['text']))
+ new_document.append('<a href=%s/%s>%s</a>' % (
+ self._platform_bundle._base_path + platform,
+ ref_dict['href'],
+ ref_dict['text']))
cursor_index = end_ref_index + 1
start_ref_index = document.find(START_REF, cursor_index)
@@ -90,6 +92,10 @@ class DocumentRenderer(object):
return ''.join(new_document)
def Render(self, document, path, render_title=False):
+ ''' |document|: document to be rendered.
+ |path|: request path to the document.
+ |render_title|: boolean representing whether or not to render a title.
+ '''
# Render links first so that parsing and later replacements aren't
# affected by $(ref...) substitutions
document = self._RenderLinks(document, path)
diff --git a/chrome/common/extensions/docs/server2/document_renderer_test.py b/chrome/common/extensions/docs/server2/document_renderer_test.py
index afbee7556..5394ea3 100755
--- a/chrome/common/extensions/docs/server2/document_renderer_test.py
+++ b/chrome/common/extensions/docs/server2/document_renderer_test.py
@@ -15,28 +15,32 @@ class DocumentRendererUnittest(unittest.TestCase):
def setUp(self):
self._renderer = ServerInstance.ForTest(
TestFileSystem(CANNED_TEST_FILE_SYSTEM_DATA)).document_renderer
+ self._path = 'apps/some/path/to/document.html'
+
+ def _Render(self, document, render_title=False):
+ return self._renderer.Render(document,
+ self._path,
+ render_title=render_title)
def testNothingToSubstitute(self):
document = 'hello world'
- path = 'apps/some/path/to/document.html'
- text, warnings = self._renderer.Render(document, path)
+ text, warnings = self._Render(document)
self.assertEqual(document, text)
self.assertEqual([], warnings)
- text, warnings = self._renderer.Render(document, path, render_title=True)
+ text, warnings = self._Render(document, render_title=True)
self.assertEqual(document, text)
self.assertEqual(['Expected a title'], warnings)
def testTitles(self):
document = '<h1>title</h1> then $(title) then another $(title)'
- path = 'apps/some/path/to/document.html'
- text, warnings = self._renderer.Render(document, path)
+ text, warnings = self._Render(document)
self.assertEqual(document, text)
self.assertEqual(['Found unexpected title "title"'], warnings)
- text, warnings = self._renderer.Render(document, path, render_title=True)
+ text, warnings = self._Render(document, render_title=True)
self.assertEqual('<h1>title</h1> then title then another $(title)', text)
self.assertEqual([], warnings)
@@ -45,73 +49,74 @@ class DocumentRendererUnittest(unittest.TestCase):
'and another $(table_of_contents)')
expected_document = ('here is a toc <table-of-contents> and another '
'$(table_of_contents)')
- path = 'apps/some/path/to/document.html'
- text, warnings = self._renderer.Render(document, path)
+ text, warnings = self._Render(document)
self.assertEqual(expected_document, text)
self.assertEqual([], warnings)
- text, warnings = self._renderer.Render(document, path, render_title=True)
+ text, warnings = self._Render(document, render_title=True)
self.assertEqual(expected_document, text)
self.assertEqual(['Expected a title'], warnings)
def testRefs(self):
# The references in this and subsequent tests won't actually be resolved
document = 'A ref $(ref:baz.baz_e1) here, $(ref:foo.foo_t3 ref title) there'
- expected_document = ('A ref <a href=#type-baz_e1>baz.baz_e1</a> '
- 'here, <a href=#type-foo_t3>ref title</a> '
- 'there')
- path = 'apps/some/path/to/document.html'
+ expected_document = ''.join([
+ 'A ref <a href=/apps/#type-baz_e1>baz.baz_e1</a> here, ',
+ '<a href=/apps/#type-foo_t3>ref title</a> there'
+ ])
- text, warnings = self._renderer.Render(document, path)
+ text, warnings = self._Render(document)
self.assertEqual(expected_document, text)
self.assertEqual([], warnings)
- text, warnings = self._renderer.Render(document, path, render_title=True)
+ text, warnings = self._Render(document, render_title=True)
self.assertEqual(expected_document, text)
self.assertEqual(['Expected a title'], warnings)
def testTitleAndToc(self):
document = '<h1>title</h1> $(title) and $(table_of_contents)'
- path = 'apps/some/path/to/document.html'
- text, warnings = self._renderer.Render(document, path)
+ text, warnings = self._Render(document)
self.assertEqual('<h1>title</h1> $(title) and <table-of-contents>', text)
self.assertEqual(['Found unexpected title "title"'], warnings)
- text, warnings = self._renderer.Render(document, path, render_title=True)
+ text, warnings = self._Render(document, render_title=True)
self.assertEqual('<h1>title</h1> title and <table-of-contents>', text)
self.assertEqual([], warnings)
def testRefInTitle(self):
document = '<h1>$(ref:baz.baz_e1 title)</h1> A $(title) was here'
- expected_document_no_title = ('<h1><a href=#type-baz_e1>'
- 'title</a></h1> A $(title) was here')
+ href = '/apps/#type-baz_e1'
+ expected_document_no_title = ''.join([
+ '<h1><a href=%s>title</a></h1> A $(title) was here' % href
+ ])
- expected_document = ('<h1><a href=#type-baz_e1>title</a></h1>'
- ' A title was here')
- path = 'apps/some/path/to/document.html'
+ expected_document = ''.join([
+ '<h1><a href=%s>title</a></h1> A title was here' % href
+ ])
- text, warnings = self._renderer.Render(document, path)
+ text, warnings = self._Render(document)
self.assertEqual(expected_document_no_title, text)
self.assertEqual([('Found unexpected title "title"')], warnings)
- text, warnings = self._renderer.Render(document, path, render_title=True)
+ text, warnings = self._Render(document, render_title=True)
self.assertEqual(expected_document, text)
self.assertEqual([], warnings)
def testRefSplitAcrossLines(self):
document = 'Hello, $(ref:baz.baz_e1 world). A $(ref:foo.foo_t3\n link)'
- expected_document = ('Hello, <a href=#type-baz_e1>world</a>. A <a href='
- '#type-foo_t3>link</a>')
+ expected_document = ''.join([
+ 'Hello, <a href=/apps/#type-baz_e1>world</a>. ',
+ 'A <a href=/apps/#type-foo_t3>link</a>'
+ ])
- path = 'apps/some/path/to/document.html'
- text, warnings = self._renderer.Render(document, path)
+ text, warnings = self._Render(document)
self.assertEqual(expected_document, text)
self.assertEqual([], warnings)
- text, warnings = self._renderer.Render(document, path, render_title=True)
+ text, warnings = self._Render(document, render_title=True)
self.assertEqual(expected_document, text)
self.assertEqual(['Expected a title'], warnings)
@@ -126,17 +131,22 @@ class DocumentRendererUnittest(unittest.TestCase):
'reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla '
'pariatur. Excepteur sint occaecat cupidatat non proident, sunt in '
'culpa qui officia deserunt mollit anim id est laborum.')
- document = ('An invalid $(ref:foo.foo_t3 a title ' + _LOREM_IPSUM +
- '$(ref:baz.baz_e1) here')
- expected_document = ('An invalid $(ref:foo.foo_t3 a title ' + _LOREM_IPSUM +
- '<a href=#type-baz_e1>baz.baz_e1</a> here')
- path = 'apps/some/path/to/document_api.html'
-
- text, warnings = self._renderer.Render(document, path)
+ document = ''.join([
+ 'An invalid $(ref:foo.foo_t3 a title ',
+ _LOREM_IPSUM,
+ '$(ref:baz.baz_e1) here'
+ ])
+ expected_document = ''.join([
+ 'An invalid $(ref:foo.foo_t3 a title ',
+ _LOREM_IPSUM,
+ '<a href=/apps/#type-baz_e1>baz.baz_e1</a> here'
+ ])
+
+ text, warnings = self._Render(document)
self.assertEqual(expected_document, text)
self.assertEqual([], warnings)
- text, warnings = self._renderer.Render(document, path, render_title=True)
+ text, warnings = self._Render(document, render_title=True)
self.assertEqual(expected_document, text)
self.assertEqual(['Expected a title'], warnings)