OLD | NEW |
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 from operator import itemgetter | 5 from operator import itemgetter |
6 import os | 6 import os |
7 import posixpath | 7 import posixpath |
8 | 8 |
9 from svn_constants import PUBLIC_TEMPLATE_PATH | 9 from svn_constants import PUBLIC_TEMPLATE_PATH |
10 import docs_server_utils as utils | 10 import docs_server_utils as utils |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 return [name.replace('_', '.') for name in template_names] | 59 return [name.replace('_', '.') for name in template_names] |
60 api_names = set(utils.SanitizeAPIName(name) for name in files) | 60 api_names = set(utils.SanitizeAPIName(name) for name in files) |
61 return { | 61 return { |
62 'apps': GetDocumentedAPIsForPlatform(api_names, 'apps'), | 62 'apps': GetDocumentedAPIsForPlatform(api_names, 'apps'), |
63 'extensions': GetDocumentedAPIsForPlatform(api_names, 'extensions') | 63 'extensions': GetDocumentedAPIsForPlatform(api_names, 'extensions') |
64 } | 64 } |
65 | 65 |
66 def _GenerateAPIDict(self): | 66 def _GenerateAPIDict(self): |
67 documented_apis = self._cache.GetFromFileListing( | 67 documented_apis = self._cache.GetFromFileListing( |
68 PUBLIC_TEMPLATE_PATH).Get() | 68 PUBLIC_TEMPLATE_PATH).Get() |
69 api_features = self._features_bundle.GetAPIFeatures() | 69 api_features = self._features_bundle.GetAPIFeatures().Get() |
70 | 70 |
71 def FilterAPIs(platform): | 71 def FilterAPIs(platform): |
72 return (api for api in api_features.itervalues() | 72 return (api for api in api_features.itervalues() |
73 if platform in api['platforms']) | 73 if platform in api['platforms']) |
74 | 74 |
75 def MakeDictForPlatform(platform): | 75 def MakeDictForPlatform(platform): |
76 platform_dict = { 'chrome': [], 'experimental': [], 'private': [] } | 76 platform_dict = { 'chrome': [], 'experimental': [], 'private': [] } |
77 for api in FilterAPIs(platform): | 77 for api in FilterAPIs(platform): |
78 if api['name'] in documented_apis[platform]: | 78 if api['name'] in documented_apis[platform]: |
79 category = _GetAPICategory(api, documented_apis[platform]) | 79 category = _GetAPICategory(api, documented_apis[platform]) |
(...skipping 17 matching lines...) Expand all Loading... |
97 | 97 |
98 def _GetCachedAPIData(self): | 98 def _GetCachedAPIData(self): |
99 data = self._object_store.Get('api_data').Get() | 99 data = self._object_store.Get('api_data').Get() |
100 if data is None: | 100 if data is None: |
101 data = self._factory._GenerateAPIDict() | 101 data = self._factory._GenerateAPIDict() |
102 self._object_store.Set('api_data', data) | 102 self._object_store.Set('api_data', data) |
103 return data | 103 return data |
104 | 104 |
105 def get(self, key): | 105 def get(self, key): |
106 return self._GetCachedAPIData().get(key) | 106 return self._GetCachedAPIData().get(key) |
OLD | NEW |