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

Unified Diff: chrome/common/extensions/docs/server2/api_data_source.py

Issue 11079010: Extensions Docs Server: Preserve JSON declaration order in extensions documentation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more efficient ordered_dict Created 8 years, 2 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
Index: chrome/common/extensions/docs/server2/api_data_source.py
diff --git a/chrome/common/extensions/docs/server2/api_data_source.py b/chrome/common/extensions/docs/server2/api_data_source.py
index 49421a60f7dce381f57afb087093c8fe099cf006..4f66df76fd19e2dafe7bed4b7a6779edf3dd3bee 100644
--- a/chrome/common/extensions/docs/server2/api_data_source.py
+++ b/chrome/common/extensions/docs/server2/api_data_source.py
@@ -3,13 +3,12 @@
# found in the LICENSE file.
import copy
-import json
import os
from docs_server_utils import GetLinkToRefType
import compiled_file_system as compiled_fs
from file_system import FileNotFoundError
-import third_party.json_schema_compiler.json_comment_eater as json_comment_eater
+import third_party.json_schema_compiler.json_parse as json_parse
import third_party.json_schema_compiler.model as model
import third_party.json_schema_compiler.idl_schema as idl_schema
import third_party.json_schema_compiler.idl_parser as idl_parser
@@ -17,10 +16,10 @@ import third_party.json_schema_compiler.idl_parser as idl_parser
# Increment this version when there are changes to the data stored in any of
# the caches used by APIDataSource. This allows the cache to be invalidated
# without having to flush memcache on the production server.
-_VERSION = 2
+_VERSION = 3
def _RemoveNoDocs(item):
- if type(item) == dict:
+ if isinstance(item, (dict, json_parse.OrderedDict)):
if item.get('nodoc', False):
not at google - send to devlin 2012/11/16 18:45:56 might be cleaner exposing like json_parse.IsDict(.
cduvall 2012/11/17 01:55:12 Done.
return True
to_remove = []
@@ -274,10 +273,10 @@ class APIDataSource(object):
self._samples_factory.Create(request))
def _LoadPermissions(self, json_str):
- return json.loads(json_comment_eater.Nom(json_str))
+ return json_parse.Parse(json_str)
def _LoadJsonAPI(self, api):
- return _JscModel(json.loads(json_comment_eater.Nom(api))[0])
+ return _JscModel(json_parse.Parse(api)[0])
def _LoadIdlAPI(self, api):
idl = idl_parser.IDLParser().ParseData(api)
@@ -322,11 +321,9 @@ class APIDataSource(object):
return api_perms
def _GenerateHandlebarContext(self, handlebar, path):
- return_dict = {
- 'permissions': self._GetFeature(path),
- 'samples': _LazySamplesGetter(path, self._samples)
- }
- return_dict.update(handlebar.ToDict())
+ return_dict = handlebar.ToDict()
+ return_dict['permissions'] = self._GetFeature(path)
+ return_dict['samples'] = _LazySamplesGetter(path, self._samples)
return return_dict
def __getitem__(self, key):
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/api_data_source_test.py » ('j') | tools/json_schema_compiler/json_parse.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698