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

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

Issue 10835012: Extension Docs Server: Include a list of samples used in the api reference page. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . 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
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 logging 6 import logging
7 import os 7 import os
8 8
9 from docs_server_utils import GetLinkToRefType 9 from docs_server_utils import GetLinkToRefType
10 import third_party.json_schema_compiler.model as model 10 import third_party.json_schema_compiler.model as model
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 ref, rest = parts 60 ref, rest = parts
61 rest = ' ' + rest 61 rest = ' ' + rest
62 if not ref[-1].isalnum(): 62 if not ref[-1].isalnum():
63 rest = ref[-1] + rest 63 rest = ref[-1] + rest
64 ref = ref[:-1] 64 ref = ref[:-1]
65 ref_dict = GetLinkToRefType(self._namespace.name, ref) 65 ref_dict = GetLinkToRefType(self._namespace.name, ref)
66 formatted_description.append('<a href="%(href)s">%(text)s</a>%(rest)s' % 66 formatted_description.append('<a href="%(href)s">%(text)s</a>%(rest)s' %
67 { 'href': ref_dict['href'], 'text': ref_dict['text'], 'rest': rest }) 67 { 'href': ref_dict['href'], 'text': ref_dict['text'], 'rest': rest })
68 return ''.join(formatted_description) 68 return ''.join(formatted_description)
69 69
70 def Generate(self): 70 def Generate(self, samples):
71 try: 71 try:
72 return { 72 return {
73 'name': self._namespace.name, 73 'name': self._namespace.name,
74 'types': map(self._GenerateType, self._namespace.types.values()), 74 'types': map(self._GenerateType, self._namespace.types.values()),
75 'functions': self._GenerateFunctions(self._namespace.functions), 75 'functions': self._GenerateFunctions(self._namespace.functions),
76 'events': map(self._GenerateEvent, self._namespace.events.values()), 76 'events': map(self._GenerateEvent, self._namespace.events.values()),
77 'properties': self._GenerateProperties(self._namespace.properties) 77 'properties': self._GenerateProperties(self._namespace.properties),
78 'samples': samples,
78 } 79 }
79 except Exception as e: 80 except Exception as e:
80 logging.error(e) 81 logging.error(e)
81 raise 82 raise
82 83
83 def _GenerateType(self, type_): 84 def _GenerateType(self, type_):
84 type_dict = { 85 type_dict = {
85 'name': self._StripPrefix(type_.name), 86 'name': self._StripPrefix(type_.name),
86 'description': self._FormatDescription(type_.description), 87 'description': self._FormatDescription(type_.description),
87 'properties': self._GenerateProperties(type_.properties), 88 'properties': self._GenerateProperties(type_.properties),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 elif property_.type_ == model.PropertyType.ENUM: 177 elif property_.type_ == model.PropertyType.ENUM:
177 dst_dict['enum_values'] = [] 178 dst_dict['enum_values'] = []
178 for enum_value in property_.enum_values: 179 for enum_value in property_.enum_values:
179 dst_dict['enum_values'].append({'name': enum_value}) 180 dst_dict['enum_values'].append({'name': enum_value})
180 if len(dst_dict['enum_values']) > 0: 181 if len(dst_dict['enum_values']) > 0:
181 dst_dict['enum_values'][-1]['last'] = True 182 dst_dict['enum_values'][-1]['last'] = True
182 elif property_.instance_of: 183 elif property_.instance_of:
183 dst_dict['simple_type'] = property_.instance_of.lower() 184 dst_dict['simple_type'] = property_.instance_of.lower()
184 else: 185 else:
185 dst_dict['simple_type'] = property_.type_.name.lower() 186 dst_dict['simple_type'] = property_.type_.name.lower()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698