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

Side by Side Diff: chrome/common/extensions/docs/server2/converter.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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 # Example run from the server2/ directory: 6 # Example run from the server2/ directory:
7 # $ converter.py ../static/ ../../api templates/articles/ templates/intros/ 7 # $ converter.py ../static/ ../../api templates/articles/ templates/intros/
8 # templates/public/ static/images/ -r 8 # templates/public/ static/images/ -r
9 9
10 import json 10 import json
(...skipping 30 matching lines...) Expand all
41 'app_window': 'app_window' 41 'app_window': 'app_window'
42 } 42 }
43 43
44 # These are the extension-only APIs that don't have explicit entries in 44 # These are the extension-only APIs that don't have explicit entries in
45 # _permission_features.json, so we can't programmatically figure out that it's 45 # _permission_features.json, so we can't programmatically figure out that it's
46 # extension-only. 46 # extension-only.
47 # From api_page_generator.js:548. 47 # From api_page_generator.js:548.
48 EXTENSIONS_ONLY = [ 48 EXTENSIONS_ONLY = [
49 'browserAction', 49 'browserAction',
50 'extension', 50 'extension',
51 'input.ime', 51 'input_ime',
52 'fontSettings',
53 'fileBrowserHandler',
52 'omnibox', 54 'omnibox',
53 'pageAction', 55 'pageAction',
54 'scriptBadge', 56 'scriptBadge',
55 'windows', 57 'windows',
56 'experimental.devtools.audits', 58 'experimental_devtools_audits',
57 'experimental.devtools.console', 59 'experimental_devtools_console',
58 'experimental.discovery', 60 'experimental_discovery',
59 'experimental.infobars', 61 'experimental_infobars',
60 'experimental.offscreenTabs', 62 'experimental_offscreenTabs',
61 'experimental.processes', 63 'experimental_processes',
62 'experimental.speechInput' 64 'experimental_speechInput'
63 ] 65 ]
64 66
65 def _ReadFile(filename): 67 def _ReadFile(filename):
66 with open(filename, 'r') as f: 68 with open(filename, 'r') as f:
67 return f.read() 69 return f.read()
68 70
69 def _WriteFile(filename, data): 71 def _WriteFile(filename, data):
70 with open(filename, 'w+') as f: 72 with open(filename, 'w+') as f:
71 f.write(data) 73 f.write(data)
72 74
(...skipping 10 matching lines...) Expand all
83 if api_name in EXTENSIONS_ONLY: 85 if api_name in EXTENSIONS_ONLY:
84 return ['extensions'] 86 return ['extensions']
85 if api_name.startswith('app'): 87 if api_name.startswith('app'):
86 return ['apps'] 88 return ['apps']
87 with open(os.path.join(api_dir, '_permission_features.json')) as f: 89 with open(os.path.join(api_dir, '_permission_features.json')) as f:
88 permissions = json.loads(json_comment_eater.Nom(f.read())) 90 permissions = json.loads(json_comment_eater.Nom(f.read()))
89 permissions_key = api_name.replace('experimental_', '').replace('_', '.') 91 permissions_key = api_name.replace('experimental_', '').replace('_', '.')
90 if permissions_key in permissions: 92 if permissions_key in permissions:
91 return_list = [] 93 return_list = []
92 types = permissions[permissions_key]['extension_types'] 94 types = permissions[permissions_key]['extension_types']
93 if ('packaged_app' in types or 95 if 'platform_app' in types:
94 'hosted_app' in types or
95 'platform_app' in types):
96 return_list.append('apps') 96 return_list.append('apps')
97 if 'extension' in types: 97 if 'extension' in types:
98 return_list.append('extensions') 98 return_list.append('extensions')
not at google - send to devlin 2012/08/13 01:56:35 Are there any APIs that would be orphaned here?
cduvall 2012/08/13 16:58:10 I don't think there are. If the API isn't in the p
99 return return_list 99 return return_list
100 return ['extensions', 'apps'] 100 return ['extensions', 'apps']
101 101
102 def _ListAllAPIs(dirname): 102 def _ListAllAPIs(dirname):
103 all_files = [] 103 all_files = []
104 for path, dirs, files in os.walk(dirname): 104 for path, dirs, files in os.walk(dirname):
105 if path == '.': 105 if path == '.':
106 all_files.extend([f for f in files 106 all_files.extend([f for f in files
107 if f.endswith('.json') or f.endswith('.idl')]) 107 if f.endswith('.json') or f.endswith('.idl')])
108 else: 108 else:
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 if (not opts.file and len(args) != 6) or (opts.file and len(args) != 7): 351 if (not opts.file and len(args) != 6) or (opts.file and len(args) != 7):
352 parser.error('incorrect number of arguments.') 352 parser.error('incorrect number of arguments.')
353 353
354 if opts.file: 354 if opts.file:
355 _MoveSingleFile(*args, replace=opts.replace, svn=opts.svn) 355 _MoveSingleFile(*args, replace=opts.replace, svn=opts.svn)
356 else: 356 else:
357 _MoveAllFiles(*args, 357 _MoveAllFiles(*args,
358 replace=opts.replace, 358 replace=opts.replace,
359 exclude_dir=opts.exclude, 359 exclude_dir=opts.exclude,
360 svn=opts.svn) 360 svn=opts.svn)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698