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

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

Issue 68873003: Docserver: Serve docs out of src/ not src/chrome/common/extensions. This allows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix samples Created 7 years, 1 month 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 os 5 import os
6 from collections import Mapping 6 from collections import Mapping
7 7
8 from api_schema_graph import APISchemaGraph 8 from api_schema_graph import APISchemaGraph
9 from branch_utility import BranchUtility 9 from branch_utility import BranchUtility
10 from extensions_paths import API
10 from file_system import FileNotFoundError 11 from file_system import FileNotFoundError
11 from svn_constants import API_PATH
12 from third_party.json_schema_compiler import idl_schema, idl_parser 12 from third_party.json_schema_compiler import idl_schema, idl_parser
13 from third_party.json_schema_compiler.model import UnixName 13 from third_party.json_schema_compiler.model import UnixName
14 14
15 15
16 _EXTENSION_API = 'extension_api.json' 16 _EXTENSION_API = 'extension_api.json'
17 17
18 18
19 def _GetChannelFromFeatures(api_name, json_fs, path): 19 def _GetChannelFromFeatures(api_name, json_fs, file_name):
20 '''Finds API channel information within _features.json files at the given 20 '''Finds API channel information from the features |file_name| within the the
21 |path| for the given |json_fs|. Returns None if channel information for the 21 given |json_fs|. Returns None if channel information for the API cannot be
22 API cannot be located. 22 located.
23 ''' 23 '''
24 feature = json_fs.GetFromFile(path).Get().get(api_name) 24 feature = json_fs.GetFromFile('%s/%s' % (API, file_name)).Get().get(api_name)
25
26 if feature is None: 25 if feature is None:
27 return None 26 return None
28 if isinstance(feature, Mapping): 27 if isinstance(feature, Mapping):
29 # The channel information exists as a solitary dict. 28 # The channel information exists as a solitary dict.
30 return feature.get('channel') 29 return feature.get('channel')
31 # The channel information dict is nested within a list for whitelisting 30 # The channel information dict is nested within a list for whitelisting
32 # purposes. Take the newest channel out of all of the entries. 31 # purposes. Take the newest channel out of all of the entries.
33 return BranchUtility.NewestChannel(entry.get('channel') for entry in feature) 32 return BranchUtility.NewestChannel(entry.get('channel') for entry in feature)
34 33
35 34
36 def _GetChannelFromApiFeatures(api_name, json_fs): 35 def _GetChannelFromApiFeatures(api_name, json_fs):
37 return _GetChannelFromFeatures(api_name, 36 return _GetChannelFromFeatures(api_name, json_fs, '_api_features.json')
38 json_fs,
39 '%s/_api_features.json' % API_PATH)
40 37
41 38
42 def _GetChannelFromManifestFeatures(api_name, json_fs): 39 def _GetChannelFromManifestFeatures(api_name, json_fs):
43 return _GetChannelFromFeatures(#_manifest_features uses unix_style API names 40 # _manifest_features.json uses unix_style API names.
44 UnixName(api_name), 41 api_name = UnixName(api_name)
45 json_fs, 42 return _GetChannelFromFeatures(api_name, json_fs, '_manifest_features.json')
46 '%s/_manifest_features.json' % API_PATH)
47 43
48 44
49 def _GetChannelFromPermissionFeatures(api_name, json_fs): 45 def _GetChannelFromPermissionFeatures(api_name, json_fs):
50 return _GetChannelFromFeatures(api_name, 46 return _GetChannelFromFeatures(api_name, json_fs, '_permission_features.json')
51 json_fs,
52 '%s/_permission_features.json' % API_PATH)
53 47
54 48
55 def _GetApiSchemaFilename(api_name, schema_fs): 49 def _GetApiSchemaFilename(api_name, schema_fs):
56 '''Gets the name of the file which contains the schema for |api_name| in 50 '''Gets the name of the file which contains the schema for |api_name| in
57 |schema_fs|, or None if the API is not found. Note that this may be the 51 |schema_fs|, or None if the API is not found. Note that this may be the
58 single _EXTENSION_API file which all APIs share in older versions of Chrome. 52 single _EXTENSION_API file which all APIs share in older versions of Chrome.
59 ''' 53 '''
60 def under_api_path(path): 54 def under_api_path(path):
61 return '%s/%s' % (API_PATH, path) 55 return '%s/%s' % (API, path)
62 56
63 try: 57 try:
64 # Prior to Chrome version 18, _EXTENSION_API contained all API schema 58 # Prior to Chrome version 18, _EXTENSION_API contained all API schema
65 # data, which replaced the current implementation of individual API files. 59 # data, which replaced the current implementation of individual API files.
66 # We're forced to parse this (very large) file to determine if the API 60 # We're forced to parse this (very large) file to determine if the API
67 # exists in it. 61 # exists in it.
68 extension_api_path = under_api_path(_EXTENSION_API) 62 extension_api_path = under_api_path(_EXTENSION_API)
69 extension_api_json = schema_fs.GetFromFile(extension_api_path).Get() 63 extension_api_json = schema_fs.GetFromFile(extension_api_path).Get()
70 if any(api['namespace'] == api_name for api in extension_api_json): 64 if any(api['namespace'] == api_name for api in extension_api_json):
71 return extension_api_path 65 return extension_api_path
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 238
245 # Continue looping until there are no longer differences between this 239 # Continue looping until there are no longer differences between this
246 # version and trunk. 240 # version and trunk.
247 return trunk_graph != version_graph 241 return trunk_graph != version_graph
248 242
249 self._file_system_iterator.Ascending(self.GetApiAvailability(api_name), 243 self._file_system_iterator.Ascending(self.GetApiAvailability(api_name),
250 update_availability_graph) 244 update_availability_graph)
251 245
252 self._node_level_object_store.Set(api_name, availability_graph) 246 self._node_level_object_store.Set(api_name, availability_graph)
253 return availability_graph 247 return availability_graph
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698