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

Side by Side Diff: chrome/common/extensions/docs/server2/jsc_view.py

Issue 498813002: Rename the docserver third_party dependency "handlebar" to "motemplate", as part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: imports Created 6 years, 4 months 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 unified diff | Download patch
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 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 from copy import copy 5 from copy import copy
6 import logging 6 import logging
7 import posixpath 7 import posixpath
8 8
9 from api_models import GetNodeCategories 9 from api_models import GetNodeCategories
10 from api_schema_graph import APINodeCursor 10 from api_schema_graph import APINodeCursor
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 def _FormatValue(value): 56 def _FormatValue(value):
57 '''Inserts commas every three digits for integer values. It is magic. 57 '''Inserts commas every three digits for integer values. It is magic.
58 ''' 58 '''
59 s = str(value) 59 s = str(value)
60 return ','.join([s[max(0, i - 3):i] for i in range(len(s), 0, -3)][::-1]) 60 return ','.join([s[max(0, i - 3):i] for i in range(len(s), 0, -3)][::-1])
61 61
62 62
63 class JSCView(object): 63 class JSCView(object):
64 '''Uses a Model from the JSON Schema Compiler and generates a dict that 64 '''Uses a Model from the JSON Schema Compiler and generates a dict that
65 a Handlebar template can use for a data source. 65 a Motemplate template can use for a data source.
66 ''' 66 '''
67 67
68 def __init__(self, 68 def __init__(self,
69 content_script_apis, 69 content_script_apis,
70 jsc_model, 70 jsc_model,
71 availability_finder, 71 availability_finder,
72 json_cache, 72 json_cache,
73 template_cache, 73 template_cache,
74 features_bundle, 74 features_bundle,
75 event_byname_future, 75 event_byname_future,
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
543 return misc_rows 543 return misc_rows
544 544
545 for category in table_info.iterkeys(): 545 for category in table_info.iterkeys():
546 content = [] 546 content = []
547 for node in table_info[category]: 547 for node in table_info[category]:
548 ext_type = PlatformToExtensionType(self._platform) 548 ext_type = PlatformToExtensionType(self._platform)
549 # Don't display nodes restricted to a different platform. 549 # Don't display nodes restricted to a different platform.
550 if ext_type not in node.get('extension_types', (ext_type,)): 550 if ext_type not in node.get('extension_types', (ext_type,)):
551 continue 551 continue
552 # If there is a 'partial' argument and it hasn't already been 552 # If there is a 'partial' argument and it hasn't already been
553 # converted to a Handlebar object, transform it to a template. 553 # converted to a Motemplate object, transform it to a template.
554 if 'partial' in node: 554 if 'partial' in node:
555 # Note: it's enough to copy() not deepcopy() because only a single 555 # Note: it's enough to copy() not deepcopy() because only a single
556 # top-level key is being modified. 556 # top-level key is being modified.
557 node = copy(node) 557 node = copy(node)
558 node['partial'] = self._template_cache.GetFromFile( 558 node['partial'] = self._template_cache.GetFromFile(
559 posixpath.join(PRIVATE_TEMPLATES, node['partial'])).Get() 559 posixpath.join(PRIVATE_TEMPLATES, node['partial'])).Get()
560 content.append(node) 560 content.append(node)
561 misc_rows.append({ 'title': category, 'content': content }) 561 misc_rows.append({ 'title': category, 'content': content })
562 return misc_rows 562 return misc_rows
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/content_provider_test.py ('k') | chrome/common/extensions/docs/server2/jsc_view_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698