Chromium Code Reviews| Index: chrome/common/extensions/docs/server2/manifest_data_source.py |
| diff --git a/chrome/common/extensions/docs/server2/manifest_data_source.py b/chrome/common/extensions/docs/server2/manifest_data_source.py |
| index 2315cbb6c04e49dedebfd87ef70115aec9968735..6102eff23a190c08c098946adb26cc12faca204e 100644 |
| --- a/chrome/common/extensions/docs/server2/manifest_data_source.py |
| +++ b/chrome/common/extensions/docs/server2/manifest_data_source.py |
| @@ -8,6 +8,8 @@ from operator import itemgetter |
| from third_party.json_schema_compiler.json_parse import Parse |
| +_PROPERTY_STATUSES = ('required', 'only_one', 'recommended', 'optional') |
| + |
| class ManifestDataSource(object): |
| """ Provides a template with access to manifest properties specific to apps or |
| extensions. |
| @@ -24,19 +26,40 @@ class ManifestDataSource(object): |
| self._CreateManifestData, ManifestDataSource) |
| def _ApplyAppsTransformations(self, manifest): |
| - manifest['required'][0]['example'] = 'Application' |
| + manifest['required'][0]['example'] = {'value': 'Application'} |
| manifest['optional'][-1]['is_last'] = True |
| def _ApplyExtensionsTransformations(self, manifest): |
| manifest['optional'][-1]['is_last'] = True |
| + def _InsertSubDocs(self, manifest_dict): |
| + """ Insert all docs in the 'subdoc' category into their 'parent' objcets, |
|
not at google - send to devlin
2013/07/02 18:23:11
objcets
also """ -> '''
oh damn they're all like
jshumway
2013/07/24 17:40:07
Rewrote pretty much the entire file, so it should
|
| + determined by the section of the subdocs name before a period. Only nests |
| + one level. |
| + """ |
| + for key in manifest_dict.get('subdoc', []): |
| + parent_name, doc_name = key['name'].split('.', 1) |
| + key['name'] = doc_name |
| + for category in _PROPERTY_STATUSES: |
| + for entry in manifest_dict[category]: |
| + if parent_name == entry['name']: |
| + parent = entry |
| + |
| + assert parent |
| + if 'subdoc' in parent: |
| + parent['subdoc'].append(key) |
| + else: |
| + parent['subdoc'] = [key] |
| + |
| + del manifest_dict['subdoc'] |
| + |
| def _CreateManifestData(self, _, content): |
| - """Take the contents of |_manifest_path| and create apps and extensions |
| + """ Take the contents of |_manifest_path| and create apps and extensions |
| versions of a manifest example based on the contents of |_features_path|. |
| """ |
| def create_manifest_dict(): |
| d = OrderedDict() |
| - for category in ['required', 'only_one', 'recommended', 'optional']: |
| + for category in _PROPERTY_STATUSES + ('subdoc',): |
| d[category] = [] |
| return d |
| @@ -48,9 +71,12 @@ class ManifestDataSource(object): |
| self._features_path)) |
| def add_property(feature, manifest_key, category): |
| - """If |feature|, from features_json, has the correct extension_types, add |
| + """ If |feature|, from features_json, has the correct extension_types, add |
| |manifest_key| to either apps or extensions. |
| """ |
| + # Save the subdocs for later by putting them in their own category. |
| + category = 'subdoc' if '.' in manifest_key['name'] else category |
| + |
| added = False |
| extension_types = feature['extension_types'] |
| if extension_types == 'all' or 'platform_app' in extension_types: |
| @@ -81,6 +107,9 @@ class ManifestDataSource(object): |
| apps['optional'].sort(key=itemgetter('name')) |
| extensions['optional'].sort(key=itemgetter('name')) |
| + self._InsertSubDocs(extensions) |
| + self._InsertSubDocs(apps) |
| + |
| self._ApplyAppsTransformations(apps) |
| self._ApplyExtensionsTransformations(extensions) |
|
not at google - send to devlin
2013/07/02 18:23:11
how about this:
apps['required'][0]['example'] =
jshumway
2013/07/24 17:40:07
Done.
|