| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview This file is the controller for generating extension | 6 * @fileoverview This file is the controller for generating extension |
| 7 * doc pages. | 7 * doc pages. |
| 8 * | 8 * |
| 9 * It expects to have available via XHR (relative path): | 9 * It expects to have available via XHR (relative path): |
| 10 * 1) API_TEMPLATE which is the main template for the api pages. | 10 * 1) API_TEMPLATE which is the main template for the api pages. |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 } catch(e) { | 253 } catch(e) { |
| 254 console.log('ex: ' + e); | 254 console.log('ex: ' + e); |
| 255 console.error('exception: ' + e); | 255 console.error('exception: ' + e); |
| 256 handleError(); | 256 handleError(); |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 | 259 |
| 260 function renderTemplate() { | 260 function renderTemplate() { |
| 261 schema.forEach(function(mod) { | 261 schema.forEach(function(mod) { |
| 262 if (mod.namespace == pageBase) { | 262 if (mod.namespace == pageBase) { |
| 263 // Do not render page for modules which are marked as "nodoc": true. | 263 // Do not render page for modules which have documentation disabled. |
| 264 if (mod.nodoc) { | 264 if (disableDocs(mod)) |
| 265 return; | 265 return; |
| 266 } | |
| 267 // This page is an api page. Setup types and apiDefinition. | 266 // This page is an api page. Setup types and apiDefinition. |
| 268 module = mod; | 267 module = mod; |
| 269 apiModuleName = API_MODULE_PREFIX + module.namespace; | 268 apiModuleName = API_MODULE_PREFIX + module.namespace; |
| 270 pageData.apiDefinition = module; | 269 pageData.apiDefinition = module; |
| 271 } | 270 } |
| 272 | 271 |
| 273 if (mod.types) { | 272 if (mod.types) { |
| 274 mod.types.forEach(function(type) { | 273 mod.types.forEach(function(type) { |
| 275 typeModule[type.id] = mod; | 274 typeModule[type.id] = mod; |
| 276 }); | 275 }); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 417 } |
| 419 | 418 |
| 420 /* | 419 /* |
| 421 * Template Callout Functions | 420 * Template Callout Functions |
| 422 * The jstProcess() will call out to these functions from within the page | 421 * The jstProcess() will call out to these functions from within the page |
| 423 * template | 422 * template |
| 424 */ | 423 */ |
| 425 | 424 |
| 426 function stableAPIs() { | 425 function stableAPIs() { |
| 427 return schema.filter(function(module) { | 426 return schema.filter(function(module) { |
| 428 return !module.nodoc && module.namespace.indexOf('experimental') < 0; | 427 return !disableDocs(module) && |
| 428 module.namespace.indexOf('experimental') < 0; |
| 429 }).map(function(module) { | 429 }).map(function(module) { |
| 430 return module.namespace; | 430 return module.namespace; |
| 431 }).sort(); | 431 }).sort(); |
| 432 } | 432 } |
| 433 | 433 |
| 434 function experimentalAPIs() { | 434 function experimentalAPIs() { |
| 435 return schema.filter(function(module) { | 435 return schema.filter(function(module) { |
| 436 return !module.nodoc && module.namespace.indexOf('experimental') == 0; | 436 return !disableDocs(module) && |
| 437 module.namespace.indexOf('experimental') == 0; |
| 437 }).map(function(module) { | 438 }).map(function(module) { |
| 438 return module.namespace; | 439 return module.namespace; |
| 439 }).sort(); | 440 }).sort(); |
| 440 } | |
| 441 | |
| 442 function devtoolsAPIs() { | |
| 443 return schema.filter(function(module) { | |
| 444 return !module.nodoc && module.namespace.indexOf('devtools.') === 0; | |
| 445 }).map(function(module) { | |
| 446 return module.namespace; | |
| 447 }).sort(); | |
| 448 } | 441 } |
| 449 | 442 |
| 450 function getDataFromPageHTML(id) { | 443 function getDataFromPageHTML(id) { |
| 451 var node = document.getElementById(id); | 444 var node = document.getElementById(id); |
| 452 if (!node) | 445 if (!node) |
| 453 return; | 446 return; |
| 454 return node.innerHTML; | 447 return node.innerHTML; |
| 455 } | 448 } |
| 456 | 449 |
| 457 function isArray(type) { | 450 function isArray(type) { |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 } | 589 } |
| 597 | 590 |
| 598 function getPropertyListFromObject(object) { | 591 function getPropertyListFromObject(object) { |
| 599 var propertyList = []; | 592 var propertyList = []; |
| 600 var properties = object.properties; | 593 var properties = object.properties; |
| 601 if (!properties && object.type === 'array' && object.items) { | 594 if (!properties && object.type === 'array' && object.items) { |
| 602 properties = object.items.properties; | 595 properties = object.items.properties; |
| 603 } | 596 } |
| 604 for (var p in properties) { | 597 for (var p in properties) { |
| 605 var prop = properties[p]; | 598 var prop = properties[p]; |
| 606 // Do not render properties marked as "nodoc": true. | 599 // Do not render properties with documentation disabled. |
| 607 if (prop.nodoc) { | 600 if (disableDocs(prop)) { |
| 608 continue; | 601 continue; |
| 609 } | 602 } |
| 610 prop.name = p; | 603 prop.name = p; |
| 611 propertyList.push(prop); | 604 propertyList.push(prop); |
| 612 } | 605 } |
| 613 return propertyList; | 606 return propertyList; |
| 614 } | 607 } |
| 615 | 608 |
| 616 function getTypeName(schema) { | 609 function getTypeName(schema) { |
| 617 if (schema.$ref) | 610 if (schema.$ref) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 665 | 658 |
| 666 function sortByName(a, b) { | 659 function sortByName(a, b) { |
| 667 if (a.name < b.name) { | 660 if (a.name < b.name) { |
| 668 return -1; | 661 return -1; |
| 669 } | 662 } |
| 670 if (a.name > b.name) { | 663 if (a.name > b.name) { |
| 671 return 1; | 664 return 1; |
| 672 } | 665 } |
| 673 return 0; | 666 return 0; |
| 674 } | 667 } |
| 668 |
| 669 function disableDocs(obj) { |
| 670 return !!obj.nodoc || !!obj.internal; |
| 671 } |
| OLD | NEW |