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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/build/directory.py
diff --git a/chrome/common/extensions/docs/build/directory.py b/chrome/common/extensions/docs/build/directory.py
index b7522f02dc8ab33b7c84b20609903f099bba4968..a751b5a8704231323366b14166c5acb461473c8a 100644
--- a/chrome/common/extensions/docs/build/directory.py
+++ b/chrome/common/extensions/docs/build/directory.py
@@ -81,6 +81,57 @@ def parse_idl_file(path):
path: Path to a file containing JSON-encoded data.
"""
api_def = idl_schema.Load(path)
+ for namespace_def in api_def:
+ namespace_dot = namespace_def['namespace'] + '.'
+ types = dict((type_['id'], type_)
+ for type_ in namespace_def.get('types', [])
+ if type_)
+ def SubstituteInlineDoc(prop):
+ prop_ref_type = prop.get('$ref', '')
+ type_obj = types.get(namespace_dot + prop_ref_type,
+ types.get(prop_ref_type, {}))
+ if not type_obj:
+ return
+ if 'properties' in type_obj:
+ del prop['$ref']
+ prop['properties'] = dict(type_obj['properties'])
+ prop['type'] = 'object'
+ for sub_prop in prop['properties'].values():
+ if isinstance(sub_prop, dict):
+ if 'nodoc' in sub_prop:
+ del sub_prop['nodoc']
+ if 'name' in sub_prop:
+ del sub_prop['name']
+ elif 'enum' in type_obj and 'type' in type_obj:
+ del prop['$ref']
+ prop['type'] = type_obj['type']
+ prop['enum'] = type_obj['enum']
+ def FixReferences(prop):
+ # Strip namespace_dot from $ref names.
+ if prop.get('$ref', '').startswith(namespace_dot):
+ prop['$ref'] = prop['$ref'][len(namespace_dot):]
+ if (prop.get('type', '') == 'array' and
+ prop.get('items', {}).get('$ref', '').startswith(namespace_dot)):
+ prop['items']['$ref'] = prop['items']['$ref'][len(namespace_dot):]
+ if prop.get('inline_doc', False):
+ del prop['inline_doc']
+ SubstituteInlineDoc(prop)
+ if 'items' in prop:
+ SubstituteInlineDoc(prop['items'])
+
+ for type_ in namespace_def.get('types', []):
+ if type_.get('id', '').startswith(namespace_dot):
+ type_['id'] = type_['id'][len(namespace_dot):]
+ for prop in type_.get('properties', {}).values():
+ FixReferences(prop)
+ for func in namespace_def.get('functions', []):
+ for param in func.get('parameters', []):
+ FixReferences(param)
+ for cb_param in param.get('parameters', []):
+ FixReferences(cb_param)
+ for event in namespace_def.get('events', []):
+ for param in event.get('parameters', []):
+ FixReferences(param)
return api_def
def write_json_to_file(manifest, path):
« 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