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

Unified Diff: tools/json_schema_compiler/previewserver.py

Issue 9447090: Allow comments in extension config files. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Added minify to some files in tools/json_schema_compiler Created 8 years, 10 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: tools/json_schema_compiler/previewserver.py
diff --git a/tools/json_schema_compiler/previewserver.py b/tools/json_schema_compiler/previewserver.py
index c7ab26279c69cce7a2157167cc7fb03258930486..047bf394b69ebcf75c636e88fc27f760ec864324 100755
--- a/tools/json_schema_compiler/previewserver.py
+++ b/tools/json_schema_compiler/previewserver.py
@@ -21,6 +21,14 @@ from highlighters import (
pygments_highlighter, none_highlighter, hilite_me_highlighter)
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
+# We need to get json_minify from the third_party directory.
+# This is similar to what is done in chrome/common/extensions/docs/build.py
+third_party_path = os.path.dirname(os.path.realpath(__file__)) + \
+ '/../../third_party/'
+if third_party_path not in sys.path:
+ sys.path.insert(0, third_party_path)
+import json_minify as minify
+
class CompilerHandler(BaseHTTPRequestHandler):
"""A HTTPRequestHandler that outputs the result of tools/json_schema_compiler.
"""
@@ -189,7 +197,7 @@ updateEverything();
try:
# Get main json file
with open(json_file_path) as json_file:
- api_defs = json.loads(json_file.read())
+ api_defs = json.loads(minify.json_minify(json_file.read()))
namespace = api_model.AddNamespace(api_defs[0], json_file_path)
if not namespace:
body.Append("<pre>Target file %s is marked nocompile</pre>" %
@@ -202,7 +210,7 @@ updateEverything();
for dependency in api_defs[0].get('dependencies', []):
json_file_path = os.path.join(filedir, dependency + '.json')
with open(json_file_path) as json_file:
- api_defs = json.loads(json_file.read())
+ api_defs = json.loads(minify.json_minify(json_file.read()))
referenced_namespace = api_model.AddNamespace(api_defs[0],
json_file_path)
if referenced_namespace:
« tools/json_schema_compiler/model_test.py ('K') | « tools/json_schema_compiler/model_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698