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

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

Issue 10825067: Extensions Docs Server: Apps samples page (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: less is_apps and fixes Created 8 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 | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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 copy 5 import copy
6 import os 6 import os
7 7
8 from docs_server_utils import GetLinkToRefType 8 from docs_server_utils import GetLinkToRefType
9 import third_party.json_schema_compiler.model as model 9 import third_party.json_schema_compiler.model as model
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 ref, rest = parts 57 ref, rest = parts
58 rest = ' ' + rest 58 rest = ' ' + rest
59 if not ref[-1].isalnum(): 59 if not ref[-1].isalnum():
60 rest = ref[-1] + rest 60 rest = ref[-1] + rest
61 ref = ref[:-1] 61 ref = ref[:-1]
62 ref_dict = GetLinkToRefType(self._namespace.name, ref) 62 ref_dict = GetLinkToRefType(self._namespace.name, ref)
63 formatted_description.append('<a href="%(href)s">%(text)s</a>%(rest)s' % 63 formatted_description.append('<a href="%(href)s">%(text)s</a>%(rest)s' %
64 { 'href': ref_dict['href'], 'text': ref_dict['text'], 'rest': rest }) 64 { 'href': ref_dict['href'], 'text': ref_dict['text'], 'rest': rest })
65 return ''.join(formatted_description) 65 return ''.join(formatted_description)
66 66
67 def Generate(self, samples): 67 def Generate(self):
68 if self._namespace is None: 68 if self._namespace is None:
69 return { 'samples': samples } 69 return {}
70 return { 70 return {
71 'name': self._namespace.name, 71 'name': self._namespace.name,
72 'types': map(self._GenerateType, self._namespace.types.values()), 72 'types': map(self._GenerateType, self._namespace.types.values()),
73 'functions': self._GenerateFunctions(self._namespace.functions), 73 'functions': self._GenerateFunctions(self._namespace.functions),
74 'events': map(self._GenerateEvent, self._namespace.events.values()), 74 'events': map(self._GenerateEvent, self._namespace.events.values()),
75 'properties': self._GenerateProperties(self._namespace.properties), 75 'properties': self._GenerateProperties(self._namespace.properties)
76 'samples': samples,
77 } 76 }
78 77
79 def _GenerateType(self, type_): 78 def _GenerateType(self, type_):
80 type_dict = { 79 type_dict = {
81 'name': self._StripPrefix(type_.name), 80 'name': self._StripPrefix(type_.name),
82 'description': self._FormatDescription(type_.description), 81 'description': self._FormatDescription(type_.description),
83 'properties': self._GenerateProperties(type_.properties), 82 'properties': self._GenerateProperties(type_.properties),
84 'functions': self._GenerateFunctions(type_.functions), 83 'functions': self._GenerateFunctions(type_.functions),
85 'events': map(self._GenerateEvent, type_.events.values()) 84 'events': map(self._GenerateEvent, type_.events.values())
86 } 85 }
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 elif property_.type_ == model.PropertyType.ENUM: 171 elif property_.type_ == model.PropertyType.ENUM:
173 dst_dict['enum_values'] = [] 172 dst_dict['enum_values'] = []
174 for enum_value in property_.enum_values: 173 for enum_value in property_.enum_values:
175 dst_dict['enum_values'].append({'name': enum_value}) 174 dst_dict['enum_values'].append({'name': enum_value})
176 if len(dst_dict['enum_values']) > 0: 175 if len(dst_dict['enum_values']) > 0:
177 dst_dict['enum_values'][-1]['last'] = True 176 dst_dict['enum_values'][-1]['last'] = True
178 elif property_.instance_of: 177 elif property_.instance_of:
179 dst_dict['simple_type'] = property_.instance_of.lower() 178 dst_dict['simple_type'] = property_.instance_of.lower()
180 else: 179 else:
181 dst_dict['simple_type'] = property_.type_.name.lower() 180 dst_dict['simple_type'] = property_.type_.name.lower()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698