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: |