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

Side by Side Diff: chrome/common/extensions/docs/build/directory.py

Issue 9617010: Move chrome.downloads out of experimental to dev (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 6 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 """Class for parsing metadata about extension samples.""" 5 """Class for parsing metadata about extension samples."""
6 6
7 import locale 7 import locale
8 import os 8 import os
9 import os.path 9 import os.path
10 import re 10 import re
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 74
75 return json_obj 75 return json_obj
76 76
77 def parse_idl_file(path): 77 def parse_idl_file(path):
78 """ Load the specified file and parse it as IDL. 78 """ Load the specified file and parse it as IDL.
79 79
80 Args: 80 Args:
81 path: Path to a file containing JSON-encoded data. 81 path: Path to a file containing JSON-encoded data.
82 """ 82 """
83 api_def = idl_schema.Load(path) 83 api_def = idl_schema.Load(path)
84 for namespace_def in api_def:
85 namespace_dot = namespace_def['namespace'] + '.'
86 types = dict((type_['id'], type_)
87 for type_ in namespace_def.get('types', [])
88 if type_)
89 def SubstituteInlineDoc(prop):
90 prop_ref_type = prop.get('$ref', '')
91 type_obj = types.get(namespace_dot + prop_ref_type,
92 types.get(prop_ref_type, {}))
93 if not type_obj:
94 return
95 if 'properties' in type_obj:
96 del prop['$ref']
97 prop['properties'] = dict(type_obj['properties'])
98 prop['type'] = 'object'
99 for sub_prop in prop['properties'].values():
100 if isinstance(sub_prop, dict):
101 if 'nodoc' in sub_prop:
102 del sub_prop['nodoc']
103 if 'name' in sub_prop:
104 del sub_prop['name']
105 elif 'enum' in type_obj and 'type' in type_obj:
106 del prop['$ref']
107 prop['type'] = type_obj['type']
108 prop['enum'] = type_obj['enum']
109 def FixReferences(prop):
110 # Strip namespace_dot from $ref names.
111 if prop.get('$ref', '').startswith(namespace_dot):
112 prop['$ref'] = prop['$ref'][len(namespace_dot):]
113 if (prop.get('type', '') == 'array' and
114 prop.get('items', {}).get('$ref', '').startswith(namespace_dot)):
115 prop['items']['$ref'] = prop['items']['$ref'][len(namespace_dot):]
116 if prop.get('inline_doc', False):
117 del prop['inline_doc']
118 SubstituteInlineDoc(prop)
119 if 'items' in prop:
120 SubstituteInlineDoc(prop['items'])
121
122 for type_ in namespace_def.get('types', []):
123 if type_.get('id', '').startswith(namespace_dot):
124 type_['id'] = type_['id'][len(namespace_dot):]
125 for prop in type_.get('properties', {}).values():
126 FixReferences(prop)
127 for func in namespace_def.get('functions', []):
128 for param in func.get('parameters', []):
129 FixReferences(param)
130 for cb_param in param.get('parameters', []):
131 FixReferences(cb_param)
132 for event in namespace_def.get('events', []):
133 for param in event.get('parameters', []):
134 FixReferences(param)
84 return api_def 135 return api_def
85 136
86 def write_json_to_file(manifest, path): 137 def write_json_to_file(manifest, path):
87 """ Writes the contents of this manifest file as a JSON-encoded text file. 138 """ Writes the contents of this manifest file as a JSON-encoded text file.
88 139
89 Args: 140 Args:
90 manifest: The manifest structure to write. 141 manifest: The manifest structure to write.
91 path: The path to write the manifest file to. 142 path: The path to write the manifest file to.
92 143
93 Raises: 144 Raises:
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
810 zip_file.write(abspath, relpath) 861 zip_file.write(abspath, relpath)
811 if file == 'manifest.json': 862 if file == 'manifest.json':
812 info = zip_file.getinfo(zip_manifest_path) 863 info = zip_file.getinfo(zip_manifest_path)
813 info.comment = self['source_hash'] 864 info.comment = self['source_hash']
814 except RuntimeError, msg: 865 except RuntimeError, msg:
815 raise Exception("Could not write zip at %s: %s" % (zip_path, msg)) 866 raise Exception("Could not write zip at %s: %s" % (zip_path, msg))
816 finally: 867 finally:
817 zip_file.close() 868 zip_file.close()
818 869
819 return self._get_relative_zip_path() 870 return self._get_relative_zip_path()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/api_index.html ('k') | chrome/common/extensions/docs/downloads.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698