Allow comments in extension config files.
Added a script to remove comments from the extension api JSON files before processing for the extension docs. We will now be able to comment in the JSON files, and they should be much easier to read. Also added the license header to all the JSON files. BUG=114233 TEST=Put comments in one of the JSON files and remake the docs. They will make with no problems. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=124660 Review URL: http://codereview.chromium.org/9447090 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@124878 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
chrome/common/extensions
api
bookmarks.jsonbrowserAction.jsonbrowsingData.jsonchromeAuthPrivate.jsonchromePrivate.jsonchromeosInfoPrivate.jsoncontentSettings.jsoncontextMenus.jsoncookies.jsondebugger.jsondevtools.jsondevtools_api.jsonexperimental.accessibility.jsonexperimental.app.jsonexperimental.bookmarkManager.jsonexperimental.declarative.jsonexperimental.dns.jsonexperimental.downloads.jsonexperimental.extension.jsonexperimental.fonts.jsonexperimental.infobars.jsonexperimental.input.ui.jsonexperimental.input.virtualKeyboard.jsonexperimental.keybinding.jsonexperimental.processes.jsonexperimental.rlz.jsonexperimental.serial.jsonexperimental.socket.jsonexperimental.speechInput.jsonexperimental.topSites.jsonextension.jsonfileBrowserHandler.jsonfileBrowserPrivate.jsonhistory.jsoni18n.jsonidle.jsoninput.ime.jsoninputMethodPrivate.jsonmanagement.jsonmediaPlayerPrivate.jsonmetricsPrivate.jsonomnibox.jsonpageAction.jsonpageActions.jsonpageCapture.jsonpermissions.jsonprivacy.jsonproxy.jsonstorage.jsonsystemPrivate.jsontabs.jsonterminalPrivate.jsontest.jsontts.jsonttsEngine.jsontypes.jsonwebNavigation.jsonwebRequest.jsonwebSocketProxyPrivate.jsonwebstorePrivate.jsonwindows.json
docs
third_party/json_minify
tools/json_schema_compiler
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "bookmarks",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "browserAction",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "browsingData",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "chromeAuthPrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "chromePrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "chromeosInfoPrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "contentSettings",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "contextMenus",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "cookies",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "debugger",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "devtools",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "devtools.inspectedWindow",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.accessibility",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace":"experimental.app",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.bookmarkManager",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.declarative",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.dns",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.downloads",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.extension",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.fontSettings",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.infobars",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.input.ui",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.input.virtualKeyboard",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.keybinding",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.processes",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.rlz",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.serial",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.socket",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.speechInput",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "experimental.topSites",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "extension",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace":"fileBrowserHandler",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace":"fileBrowserPrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "history",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "i18n",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "idle",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "input.ime",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "inputMethodPrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace":"management",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "mediaPlayerPrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "metricsPrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "omnibox",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "pageAction",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "pageActions",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "pageCapture",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "permissions",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "privacy",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "proxy",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "storage",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "systemPrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "tabs",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "terminalPrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "test",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "tts",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "ttsEngine",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "types",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "webNavigation",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "webRequest",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "webSocketProxyPrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace":"webstorePrivate",
|
||||
|
@ -1,3 +1,7 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
[
|
||||
{
|
||||
"namespace": "windows",
|
||||
|
@ -12,6 +12,7 @@ import re
|
||||
import hashlib
|
||||
import zipfile
|
||||
import simplejson as json
|
||||
import json_minify as minify
|
||||
|
||||
# Make sure we get consistent string sorting behavior by explicitly using the
|
||||
# default C locale.
|
||||
@ -48,7 +49,8 @@ def parse_json_file(path, encoding="utf-8"):
|
||||
raise Exception("Failed to read the file at %s: %s" % (path, msg))
|
||||
|
||||
try:
|
||||
json_obj = json.load(json_file, encoding)
|
||||
json_str = json_file.read()
|
||||
json_obj = json.loads(minify.json_minify(json_str), encoding)
|
||||
except ValueError, msg:
|
||||
raise Exception("Failed to parse JSON out of file %s: %s" % (path, msg))
|
||||
finally:
|
||||
|
@ -183,7 +183,7 @@ function fetchSchema() {
|
||||
schema = [];
|
||||
|
||||
function onSchemaContent(content) {
|
||||
schema = schema.concat(JSON.parse(content));
|
||||
schema = schema.concat(JSON.parse(JSON.minify(content)));
|
||||
if (++schemas_retrieved < schemas_to_retrieve.length)
|
||||
return;
|
||||
if (pageName.toLowerCase() == 'samples') {
|
||||
@ -204,7 +204,7 @@ function fetchSchema() {
|
||||
function fetchSamples() {
|
||||
// If we're rendering the samples directory, fetch the samples manifest.
|
||||
fetchContent(SAMPLES, function(sampleManifest) {
|
||||
var data = JSON.parse(sampleManifest);
|
||||
var data = JSON.parse(JSON.minify(sampleManifest));
|
||||
samples = data.samples;
|
||||
apiMapping = data.api;
|
||||
renderTemplate();
|
||||
|
@ -17,6 +17,9 @@
|
||||
<script type="text/javascript"
|
||||
src="../../../third_party/jstemplate/jstemplate_compiled.js">
|
||||
</script>
|
||||
<script type="text/javascript"
|
||||
src="../../../../third_party/json_minify/minify-sans-regexp.js">
|
||||
</script>
|
||||
<script type="text/javascript" src="js/api_page_generator.js"></script>
|
||||
<script type="text/javascript" src="js/bootstrap.js"></script>
|
||||
<script type="text/javascript" src="js/sidebar.js"></script>
|
||||
|
35
third_party/json_minify/README
vendored
Normal file
35
third_party/json_minify/README
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
/*! JSON.minify()
|
||||
v0.1 (c) Kyle Simpson
|
||||
MIT License
|
||||
*/
|
||||
|
||||
JSON.minify() minifies blocks of JSON-like content into valid JSON by removing all
|
||||
whitespace *and* comments.
|
||||
|
||||
JSON parsers (like JavaScript's JSON.parse() parser) generally don't consider JSON
|
||||
with comments to be valid and parseable. So, the intended usage is to minify
|
||||
development-friendly JSON (with comments) to valid JSON before parsing, such as:
|
||||
|
||||
JSON.parse(JSON.minify(str));
|
||||
|
||||
Now you can maintain development-friendly JSON documents, but minify them before
|
||||
parsing or before transmitting them over-the-wire.
|
||||
|
||||
Though comments are not officially part of the JSON standard, this post from
|
||||
Douglas Crockford back in late 2005 helps explain the motivation behind this project.
|
||||
|
||||
http://tech.groups.yahoo.com/group/json/message/152
|
||||
|
||||
"A JSON encoder MUST NOT output comments. A JSON decoder MAY accept and ignore comments."
|
||||
|
||||
Basically, comments are not in the JSON *generation* standard, but that doesn't mean
|
||||
that a parser can't be taught to ignore them. Which is exactly what JSON.minify()
|
||||
is for.
|
||||
|
||||
The first implementation of JSON.minify() is in JavaScript, but the intent is to
|
||||
port the implementation to as many other environments as possible/practical.
|
||||
|
||||
NOTE: As transmitting bloated (ie, with comments/whitespace) JSON would be wasteful
|
||||
and silly, this JSON.minify() is intended for use in server-side processing
|
||||
environments where you can strip comments/whitespace from JSON before parsing
|
||||
a JSON document, or before transmitting such over-the-wire from server to browser.
|
17
third_party/json_minify/README.chromium
vendored
Normal file
17
third_party/json_minify/README.chromium
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
Name: JSON.minify
|
||||
URL: https://github.com/getify/JSON.minify
|
||||
and also https://github.com/kitcambridge/JSON.minify
|
||||
Version: 0.1
|
||||
License: MIT License
|
||||
License file: https://github.com/getify/JSON.minify/blob/master/README.txt
|
||||
(README has license info)
|
||||
Security Critical: no
|
||||
|
||||
Description:
|
||||
A set of scripts that remove comments and whitespace from JSON files.
|
||||
|
||||
Local Modifications:
|
||||
- Added the __init__.py file for easier imports
|
||||
- Got the (much faster) json-minify-sans-regexp.js file from the second
|
||||
URL listed
|
||||
- Small change to minify_json.py to pass license tests
|
5
third_party/json_minify/__init__.py
vendored
Normal file
5
third_party/json_minify/__init__.py
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
from minify_json import json_minify
|
91
third_party/json_minify/minify-sans-regexp.js
vendored
Normal file
91
third_party/json_minify/minify-sans-regexp.js
vendored
Normal file
@ -0,0 +1,91 @@
|
||||
/*!
|
||||
* `JSON.minify()`
|
||||
* This version does not use regular expressions.
|
||||
*
|
||||
* Copyright 2011, Kyle Simpson.
|
||||
* Copyright 2012, Kit Cambridge.
|
||||
*
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
|
||||
;(function () {
|
||||
var JSON = this.JSON;
|
||||
|
||||
// Create the global JSON object if it doesn't exist.
|
||||
if (Object(JSON) !== JSON) {
|
||||
JSON = this.JSON = {};
|
||||
}
|
||||
|
||||
JSON.minify = function (source) {
|
||||
var index = 0, length = source.length, result = "", symbol, position;
|
||||
while (index < length) {
|
||||
symbol = source.charAt(index);
|
||||
switch (symbol) {
|
||||
// Ignore whitespace tokens. According to ES 5.1 section 15.12.1.1,
|
||||
// whitespace tokens include tabs, carriage returns, line feeds, and
|
||||
// space characters.
|
||||
// -----------------------------------------------------------------
|
||||
case "\t":
|
||||
case "\r":
|
||||
case "\n":
|
||||
case " ":
|
||||
index += 1;
|
||||
break;
|
||||
// Ignore line and block comments.
|
||||
// -------------------------------
|
||||
case "/":
|
||||
symbol = source.charAt(index += 1);
|
||||
switch (symbol) {
|
||||
// Line comments.
|
||||
// -------------
|
||||
case "/":
|
||||
position = source.indexOf("\n", index);
|
||||
if (position < 0) {
|
||||
// Check for CR-style line endings.
|
||||
position = source.indexOf("\r", index);
|
||||
}
|
||||
index = position > -1 ? position : length;
|
||||
break;
|
||||
// Block comments.
|
||||
// ---------------
|
||||
case "*":
|
||||
position = source.indexOf("*/", index);
|
||||
if (position > -1) {
|
||||
// Advance the scanner's position past the end of the comment.
|
||||
index = position += 2;
|
||||
break;
|
||||
}
|
||||
throw SyntaxError("Unterminated block comment.");
|
||||
default:
|
||||
throw SyntaxError("Invalid comment.");
|
||||
}
|
||||
break;
|
||||
// Parse strings separately to ensure that any whitespace characters and
|
||||
// JavaScript-style comments within them are preserved.
|
||||
// ---------------------------------------------------------------------
|
||||
case '"':
|
||||
position = index;
|
||||
while (index < length) {
|
||||
symbol = source.charAt(index += 1);
|
||||
if (symbol == "\\") {
|
||||
// Skip past escaped characters.
|
||||
index += 1;
|
||||
} else if (symbol == '"') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (source.charAt(index) == '"') {
|
||||
result += source.slice(position, index += 1);
|
||||
break;
|
||||
}
|
||||
throw SyntaxError("Unterminated string.");
|
||||
// Preserve all other characters.
|
||||
// ------------------------------
|
||||
default:
|
||||
result += symbol;
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}).call(this);
|
113
third_party/json_minify/minify_json.py
vendored
Normal file
113
third_party/json_minify/minify_json.py
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
# Use of this source code is governed by a BSD-style license (MIT)
|
||||
'''
|
||||
Created on 20/01/2011
|
||||
|
||||
v0.1 (C) Gerald Storer
|
||||
MIT License
|
||||
|
||||
Based on JSON.minify.js:
|
||||
https://github.com/getify/JSON.minify
|
||||
'''
|
||||
|
||||
import re
|
||||
|
||||
def json_minify(json,strip_space=True):
|
||||
tokenizer=re.compile('"|(/\*)|(\*/)|(//)|\n|\r')
|
||||
in_string = False
|
||||
in_multiline_comment = False
|
||||
in_singleline_comment = False
|
||||
|
||||
new_str = []
|
||||
from_index = 0 # from is a keyword in Python
|
||||
|
||||
for match in re.finditer(tokenizer,json):
|
||||
|
||||
if not in_multiline_comment and not in_singleline_comment:
|
||||
tmp2 = json[from_index:match.start()]
|
||||
if not in_string and strip_space:
|
||||
tmp2 = re.sub('[ \t\n\r]*','',tmp2) # replace only white space defined in standard
|
||||
new_str.append(tmp2)
|
||||
|
||||
from_index = match.end()
|
||||
|
||||
if match.group() == '"' and not in_multiline_comment and not in_singleline_comment:
|
||||
escaped = re.search('(\\\\)*$',json[:match.start()])
|
||||
if not in_string or escaped is None or len(escaped.group()) % 2 == 0:
|
||||
# start of string with ", or unescaped " character found to end string
|
||||
in_string = not in_string
|
||||
from_index -= 1 # include " character in next catch
|
||||
|
||||
elif match.group() == '/*' and not in_string and not in_multiline_comment and not in_singleline_comment:
|
||||
in_multiline_comment = True
|
||||
elif match.group() == '*/' and not in_string and in_multiline_comment and not in_singleline_comment:
|
||||
in_multiline_comment = False
|
||||
elif match.group() == '//' and not in_string and not in_multiline_comment and not in_singleline_comment:
|
||||
in_singleline_comment = True
|
||||
elif (match.group() == '\n' or match.group() == '\r') and not in_string and not in_multiline_comment and in_singleline_comment:
|
||||
in_singleline_comment = False
|
||||
elif not in_multiline_comment and not in_singleline_comment and (
|
||||
match.group() not in ['\n','\r',' ','\t'] or not strip_space):
|
||||
new_str.append(match.group())
|
||||
|
||||
new_str.append(json[from_index:])
|
||||
return ''.join(new_str)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import json # requires Python 2.6+ to run tests
|
||||
|
||||
def test_json(s):
|
||||
return json.loads(json_minify(s))
|
||||
|
||||
test1 = '''// this is a JSON file with comments
|
||||
{
|
||||
"foo": "bar", // this is cool
|
||||
"bar": [
|
||||
"baz", "bum", "zam"
|
||||
],
|
||||
/* the rest of this document is just fluff
|
||||
in case you are interested. */
|
||||
"something": 10,
|
||||
"else": 20
|
||||
}
|
||||
|
||||
/* NOTE: You can easily strip the whitespace and comments
|
||||
from such a file with the JSON.minify() project hosted
|
||||
here on github at http://github.com/getify/JSON.minify
|
||||
*/
|
||||
'''
|
||||
|
||||
test1_res = '''{"foo":"bar","bar":["baz","bum","zam"],"something":10,"else":20}'''
|
||||
|
||||
test2 = '''
|
||||
{"/*":"*/","//":"",/*"//"*/"/*/"://
|
||||
"//"}
|
||||
|
||||
'''
|
||||
test2_res = '''{"/*":"*/","//":"","/*/":"//"}'''
|
||||
|
||||
test3 = r'''/*
|
||||
this is a
|
||||
multi line comment */{
|
||||
|
||||
"foo"
|
||||
:
|
||||
"bar/*"// something
|
||||
, "b\"az":/*
|
||||
something else */"blah"
|
||||
|
||||
}
|
||||
'''
|
||||
test3_res = r'''{"foo":"bar/*","b\"az":"blah"}'''
|
||||
|
||||
test4 = r'''{"foo": "ba\"r//", "bar\\": "b\\\"a/*z",
|
||||
"baz\\\\": /* yay */ "fo\\\\\"*/o"
|
||||
}
|
||||
'''
|
||||
test4_res = r'''{"foo":"ba\"r//","bar\\":"b\\\"a/*z","baz\\\\":"fo\\\\\"*/o"}'''
|
||||
|
||||
assert test_json(test1) == json.loads(test1_res),'Failed test 1'
|
||||
assert test_json(test2) == json.loads(test2_res),'Failed test 2'
|
||||
assert test_json(test3) == json.loads(test3_res),'Failed test 3'
|
||||
assert test_json(test4) == json.loads(test4_res),'Failed test 4'
|
||||
if __debug__: # Don't print passed message if the asserts didn't run
|
||||
print 'Passed all tests'
|
@ -19,7 +19,7 @@ Usage example:
|
||||
import cc_generator
|
||||
import cpp_type_generator
|
||||
import h_generator
|
||||
import json
|
||||
from json_schema import LoadJSON
|
||||
import model
|
||||
import optparse
|
||||
import os.path
|
||||
@ -49,8 +49,7 @@ if __name__ == '__main__':
|
||||
|
||||
|
||||
# Actually generate for source file.
|
||||
with open(schema, 'r') as schema_file:
|
||||
api_defs = json.loads(schema_file.read())
|
||||
api_defs = LoadJSON(schema)
|
||||
|
||||
for target_namespace in api_defs:
|
||||
referenced_schemas = target_namespace.get('dependencies', [])
|
||||
@ -58,8 +57,7 @@ if __name__ == '__main__':
|
||||
for referenced_schema in referenced_schemas:
|
||||
referenced_schema_path = os.path.join(
|
||||
os.path.dirname(schema), referenced_schema + '.json')
|
||||
with open(referenced_schema_path, 'r') as referenced_schema_file:
|
||||
referenced_api_defs = json.loads(referenced_schema_file.read())
|
||||
referenced_api_defs = LoadJSON(referenced_schema_path)
|
||||
|
||||
for namespace in referenced_api_defs:
|
||||
api_model.AddNamespace(namespace,
|
||||
|
@ -3,22 +3,22 @@
|
||||
# found in the LICENSE file.
|
||||
|
||||
from cpp_type_generator import CppTypeGenerator
|
||||
import json
|
||||
from json_schema import LoadJSON
|
||||
import model
|
||||
import unittest
|
||||
|
||||
class CppTypeGeneratorTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.model = model.Model()
|
||||
self.permissions_json = json.loads(open('test/permissions.json').read())
|
||||
self.permissions_json = LoadJSON('test/permissions.json')
|
||||
self.model.AddNamespace(self.permissions_json[0],
|
||||
'path/to/permissions.json')
|
||||
self.permissions = self.model.namespaces.get('permissions')
|
||||
self.windows_json = json.loads(open('test/windows.json').read())
|
||||
self.windows_json = LoadJSON('test/windows.json')
|
||||
self.model.AddNamespace(self.windows_json[0],
|
||||
'path/to/window.json')
|
||||
self.windows = self.model.namespaces.get('windows')
|
||||
self.tabs_json = json.loads(open('test/tabs.json').read())
|
||||
self.tabs_json = LoadJSON('test/tabs.json')
|
||||
self.model.AddNamespace(self.tabs_json[0],
|
||||
'path/to/tabs.json')
|
||||
self.tabs = self.model.namespaces.get('tabs')
|
||||
|
19
tools/json_schema_compiler/json_schema.py
Normal file
19
tools/json_schema_compiler/json_schema.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import json
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
# 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.join(os.path.dirname(os.path.realpath(__file__)),
|
||||
os.pardir, os.pardir, 'third_party/')
|
||||
if third_party_path not in sys.path:
|
||||
sys.path.insert(0, third_party_path)
|
||||
import json_minify as minify
|
||||
|
||||
def LoadJSON(filename):
|
||||
with open(filename, 'r') as handle:
|
||||
return json.loads(minify.json_minify(handle.read()))
|
@ -2,22 +2,22 @@
|
||||
# Use of this source code is governed by a BSD-style license that can be
|
||||
# found in the LICENSE file.
|
||||
|
||||
import json
|
||||
from json_schema import LoadJSON
|
||||
import model
|
||||
import unittest
|
||||
|
||||
class ModelTest(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.model = model.Model()
|
||||
self.permissions_json = json.loads(open('test/permissions.json').read())
|
||||
self.permissions_json = LoadJSON('test/permissions.json')
|
||||
self.model.AddNamespace(self.permissions_json[0],
|
||||
'path/to/permissions.json')
|
||||
self.permissions = self.model.namespaces.get('permissions')
|
||||
self.windows_json = json.loads(open('test/windows.json').read())
|
||||
self.windows_json = LoadJSON('test/windows.json')
|
||||
self.model.AddNamespace(self.windows_json[0],
|
||||
'path/to/window.json')
|
||||
self.windows = self.model.namespaces.get('windows')
|
||||
self.tabs_json = json.loads(open('test/tabs.json').read())
|
||||
self.tabs_json = LoadJSON('test/tabs.json')
|
||||
self.model.AddNamespace(self.tabs_json[0],
|
||||
'path/to/tabs.json')
|
||||
self.tabs = self.model.namespaces.get('tabs')
|
||||
|
@ -11,7 +11,7 @@ import code
|
||||
import cpp_type_generator
|
||||
import cpp_util
|
||||
import h_generator
|
||||
import json
|
||||
from json_schema import LoadJSON
|
||||
import model
|
||||
import optparse
|
||||
import os
|
||||
@ -188,8 +188,7 @@ updateEverything();
|
||||
|
||||
try:
|
||||
# Get main json file
|
||||
with open(json_file_path) as json_file:
|
||||
api_defs = json.loads(json_file.read())
|
||||
api_defs = LoadJSON(json_file_path)
|
||||
namespace = api_model.AddNamespace(api_defs[0], json_file_path)
|
||||
if not namespace:
|
||||
body.Append("<pre>Target file %s is marked nocompile</pre>" %
|
||||
@ -201,8 +200,7 @@ updateEverything();
|
||||
# Get json file depedencies
|
||||
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 = LoadJSON(json_file_path)
|
||||
referenced_namespace = api_model.AddNamespace(api_defs[0],
|
||||
json_file_path)
|
||||
if referenced_namespace:
|
||||
|
Reference in New Issue
Block a user