Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1890)

Unified Diff: chrome/common/extensions/docs/server2/samples_data_source.py

Issue 55913003: Docserver: Fix 3 issues relating to finding API references in sample files, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/samples_data_source.py
diff --git a/chrome/common/extensions/docs/server2/samples_data_source.py b/chrome/common/extensions/docs/server2/samples_data_source.py
index 9a57fba423a1f2d1eebf76b3eb40331cbcdda94f..29b45a92b652cf52401e5fd294f5171ea7156b0e 100644
--- a/chrome/common/extensions/docs/server2/samples_data_source.py
+++ b/chrome/common/extensions/docs/server2/samples_data_source.py
@@ -56,14 +56,14 @@ class SamplesDataSource(object):
request)
def _GetAPIItems(self, js_file):
- chrome_regex = '(chrome\.[a-zA-Z0-9\.]+)'
+ chrome_regex = r'(chrome\.[a-zA-Z0-9\.]+)'
calls = set(re.findall(chrome_regex, js_file))
# Find APIs that have been assigned into variables.
- assigned_vars = dict(re.findall('var\s*([^\s]+)\s*=\s*%s;' % chrome_regex,
- js_file))
+ assigned_vars = dict(
+ re.findall(r'var\s*([^\s]+)\s*=\s*%s;' % chrome_regex, js_file))
# Replace the variable name with the full API name.
for var_name, value in assigned_vars.iteritems():
Jeffrey Yasskin 2013/11/01 18:00:24 You might be able to make this loop more efficient
- js_file = js_file.replace(var_name, value)
+ js_file = re.compile(r'\b%s\b' % var_name).sub(value, js_file)
not at google - send to devlin 2013/11/01 17:12:04 this is the most important change.
Jeffrey Yasskin 2013/11/01 18:00:24 Instead of re.compile(variable_string).sub(...), u
Jeffrey Yasskin 2013/11/01 18:00:24 You probably want re.escape(var_name) in case it c
return calls.union(re.findall(chrome_regex, js_file))
Jeffrey Yasskin 2013/11/01 18:00:24 Wait a second, you're just trying to find the APIs
not at google - send to devlin 2013/11/04 21:51:01 I got a little bit lost in your comments there + t
def _GetDataFromManifest(self, path, file_system):

Powered by Google App Engine
This is Rietveld 408576698