Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import logging | 5 import logging |
| 6 import os | 6 import os |
| 7 from document_parser import ParseDocument | 7 from document_parser import ParseDocument |
| 8 from third_party.json_schema_compiler.model import UnixName | 8 from third_party.json_schema_compiler.model import UnixName |
| 9 | 9 |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 | 23 |
| 24 def __init__(self, table_of_contents_renderer, ref_resolver): | 24 def __init__(self, table_of_contents_renderer, ref_resolver): |
| 25 self._table_of_contents_renderer = table_of_contents_renderer | 25 self._table_of_contents_renderer = table_of_contents_renderer |
| 26 self._ref_resolver = ref_resolver | 26 self._ref_resolver = ref_resolver |
| 27 | 27 |
| 28 def _RenderLinks(self, document, path): | 28 def _RenderLinks(self, document, path): |
| 29 ''' Replaces all $(ref:...) references in |document| with html links | 29 ''' Replaces all $(ref:...) references in |document| with html links |
| 30 ''' | 30 ''' |
| 31 START_REF = '$(ref:' | 31 START_REF = '$(ref:' |
| 32 END_REF = ')' | 32 END_REF = ')' |
| 33 MAX_REF_LENGTH = 100 | 33 MAX_REF_LENGTH = 110 |
|
ahernandez
2014/03/28 19:04:52
It turns out a couple refs are actually longer tha
not at google - send to devlin
2014/03/28 21:48:22
yikes, which ones?
ahernandez
2014/03/28 22:03:25
fileBrowserHandler.FileHandlerExecuteEventDetails
| |
| 34 | 34 |
| 35 new_document = [] | 35 new_document = [] |
| 36 | 36 |
| 37 # Keeps track of position within |document| | 37 # Keeps track of position within |document| |
| 38 cursor_index = 0 | 38 cursor_index = 0 |
| 39 start_ref_index = document.find(START_REF) | 39 start_ref_index = document.find(START_REF) |
| 40 | 40 |
| 41 while start_ref_index != -1: | 41 while start_ref_index != -1: |
| 42 end_ref_index = document.find(END_REF, start_ref_index) | 42 end_ref_index = document.find(END_REF, start_ref_index) |
| 43 | 43 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 82 parsed_document = ParseDocument(document, expect_title=render_title) | 82 parsed_document = ParseDocument(document, expect_title=render_title) |
| 83 toc_text, toc_warnings = self._table_of_contents_renderer.Render( | 83 toc_text, toc_warnings = self._table_of_contents_renderer.Render( |
| 84 parsed_document.sections) | 84 parsed_document.sections) |
| 85 | 85 |
| 86 # Only 1 title and 1 table of contents substitution allowed; in the common | 86 # Only 1 title and 1 table of contents substitution allowed; in the common |
| 87 # case, save necessarily running over the entire file. | 87 # case, save necessarily running over the entire file. |
| 88 if parsed_document.title: | 88 if parsed_document.title: |
| 89 document = document.replace('$(title)', parsed_document.title, 1) | 89 document = document.replace('$(title)', parsed_document.title, 1) |
| 90 return (document.replace('$(table_of_contents)', toc_text, 1), | 90 return (document.replace('$(table_of_contents)', toc_text, 1), |
| 91 parsed_document.warnings + toc_warnings) | 91 parsed_document.warnings + toc_warnings) |
| OLD | NEW |