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

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

Issue 10832259: Extensions Docs Server: Apps api_index.html shows correct APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | 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 logging 5 import logging
6 import os 6 import os
7 7
8 from file_system import FileNotFoundError 8 from file_system import FileNotFoundError
9 import third_party.json_schema_compiler.model as model 9 import third_party.json_schema_compiler.model as model
10 from docs_server_utils import SanitizeAPIName 10 from docs_server_utils import SanitizeAPIName
11 11
12 # These files are special cases that shouldn't be in the API list.
13 IGNORED_FILES = [
14 'devtools'
15 ]
16
12 class APIListDataSource(object): 17 class APIListDataSource(object):
13 """ This class creates a list of chrome.* APIs and chrome.experimental.* APIs 18 """ This class creates a list of chrome.* APIs and chrome.experimental.* APIs
14 that are used in the api_index.html and experimental.html pages. 19 that are used in the api_index.html and experimental.html pages.
15 """ 20 """
16 def __init__(self, cache_builder, file_system, api_path, public_path): 21 def __init__(self, cache_builder, file_system, api_path, public_path):
17 self._cache = cache_builder.build(self._ListAPIs) 22 self._cache = cache_builder.build(self._ListAPIs)
18 self._file_system = file_system 23 self._file_system = file_system
19 self._api_path = api_path + '/' 24 self._api_path = api_path + '/'
20 self._public_path = public_path + '/' 25 self._public_path = public_path + '/'
21 26
22 def _GetAPIsInSubdirectory(self, api_names, doc_type): 27 def _GetAPIsInSubdirectory(self, api_names, doc_type):
23 public_templates = self._file_system.ReadSingle( 28 public_templates = self._file_system.ReadSingle(
24 self._public_path + doc_type + '/') 29 self._public_path + doc_type + '/')
25 template_names = [os.path.splitext(name)[0] 30 template_names = [os.path.splitext(name)[0]
26 for name in public_templates] 31 for name in public_templates]
27 experimental_apis = [] 32 experimental_apis = []
28 chrome_apis = [] 33 chrome_apis = []
29 for i, template_name in enumerate(sorted(template_names)): 34 for template_name in sorted(template_names):
35 if template_name in IGNORED_FILES:
36 continue
30 if model.UnixName(template_name) in api_names: 37 if model.UnixName(template_name) in api_names:
31 if template_name.startswith('experimental'): 38 if template_name.startswith('experimental'):
32 experimental_apis.append({ 39 experimental_apis.append({
33 'name': template_name.replace('_', '.') 40 'name': template_name.replace('_', '.')
34 }) 41 })
35 else: 42 else:
36 chrome_apis.append({ 'name': template_name.replace('_', '.') }) 43 chrome_apis.append({ 'name': template_name.replace('_', '.') })
37 chrome_apis[-1]['last'] = True 44 chrome_apis[-1]['last'] = True
38 experimental_apis[-1]['last'] = True 45 experimental_apis[-1]['last'] = True
39 return { 46 return {
(...skipping 10 matching lines...) Expand all
50 57
51 def __getitem__(self, key): 58 def __getitem__(self, key):
52 return self.get(key) 59 return self.get(key)
53 60
54 def get(self, key): 61 def get(self, key):
55 try: 62 try:
56 return self._cache.GetFromFileListing(self._api_path)[key] 63 return self._cache.GetFromFileListing(self._api_path)[key]
57 except FileNotFoundError as e: 64 except FileNotFoundError as e:
58 logging.error(e) 65 logging.error(e)
59 return None 66 return None
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/converter.py » ('j') | chrome/common/extensions/docs/server2/converter.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698