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 import docs_server_utils as utils | 9 import docs_server_utils as utils |
10 from branch_utility import ChannelInfo | 10 from branch_utility import ChannelInfo |
| 11 from environment import IsPreviewServer |
11 from extensions_paths import PUBLIC_TEMPLATES | 12 from extensions_paths import PUBLIC_TEMPLATES |
12 from file_system import FileNotFoundError | 13 from file_system import FileNotFoundError |
13 | 14 |
14 def _GetAPICategory(api_name, documented_apis): | 15 def _GetAPICategory(api_name, documented_apis): |
15 if (api_name.endswith('Private') or | 16 if (api_name.endswith('Private') or |
16 api_name not in documented_apis): | 17 api_name not in documented_apis): |
17 return 'private' | 18 return 'private' |
18 if api_name.startswith('experimental.'): | 19 if api_name.startswith('experimental.'): |
19 return 'experimental' | 20 return 'experimental' |
20 return 'chrome' | 21 return 'chrome' |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 api_names = set(utils.SanitizeAPIName(name) for name in files) | 69 api_names = set(utils.SanitizeAPIName(name) for name in files) |
69 return { | 70 return { |
70 'apps': GetDocumentedAPIsForPlatform(api_names, 'apps'), | 71 'apps': GetDocumentedAPIsForPlatform(api_names, 'apps'), |
71 'extensions': GetDocumentedAPIsForPlatform(api_names, 'extensions') | 72 'extensions': GetDocumentedAPIsForPlatform(api_names, 'extensions') |
72 } | 73 } |
73 | 74 |
74 def _GenerateAPIDict(self): | 75 def _GenerateAPIDict(self): |
75 documented_apis = self._cache.GetFromFileListing(PUBLIC_TEMPLATES).Get() | 76 documented_apis = self._cache.GetFromFileListing(PUBLIC_TEMPLATES).Get() |
76 | 77 |
77 def _GetChannelInfo(api_name): | 78 def _GetChannelInfo(api_name): |
| 79 if IsPreviewServer(): return ChannelInfo('dev', 'dev', 1000) |
78 return self._availability_finder.GetApiAvailability(api_name) | 80 return self._availability_finder.GetApiAvailability(api_name) |
79 | 81 |
80 def _GetApiPlatform(api_name): | 82 def _GetApiPlatform(api_name): |
81 feature = self._features_bundle.GetAPIFeatures().Get()[api_name] | 83 feature = self._features_bundle.GetAPIFeatures().Get()[api_name] |
82 return feature['platforms'] | 84 return feature['platforms'] |
83 | 85 |
84 def _MakeDictForPlatform(platform): | 86 def _MakeDictForPlatform(platform): |
85 platform_dict = { | 87 platform_dict = { |
86 'chrome': {'stable': [], 'beta': [], 'dev': [], 'trunk': []} | 88 'chrome': {'stable': [], 'beta': [], 'dev': [], 'trunk': []} |
87 } | 89 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 136 |
135 def _GetCachedAPIData(self): | 137 def _GetCachedAPIData(self): |
136 data = self._object_store.Get('api_data').Get() | 138 data = self._object_store.Get('api_data').Get() |
137 if data is None: | 139 if data is None: |
138 data = self._factory._GenerateAPIDict() | 140 data = self._factory._GenerateAPIDict() |
139 self._object_store.Set('api_data', data) | 141 self._object_store.Set('api_data', data) |
140 return data | 142 return data |
141 | 143 |
142 def get(self, key): | 144 def get(self, key): |
143 return self._GetCachedAPIData().get(key) | 145 return self._GetCachedAPIData().get(key) |
OLD | NEW |