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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 * The jstProcess() will call out to these functions from within the page | 496 * The jstProcess() will call out to these functions from within the page |
497 * template | 497 * template |
498 */ | 498 */ |
499 | 499 |
500 function filterDocumented(things) { | 500 function filterDocumented(things) { |
501 return !things ? [] : things.filter(function(thing) { | 501 return !things ? [] : things.filter(function(thing) { |
502 return !disableDocs(thing); | 502 return !disableDocs(thing); |
503 }); | 503 }); |
504 } | 504 } |
505 | 505 |
506 function stableAPIs() { | 506 function listChromeAPIs(packageType, includeExperimental) { |
| 507 // Super ghetto to use a synchronous XHR here, but this only runs during |
| 508 // generation of docs, so I guess it's ok. |
| 509 var req = new XMLHttpRequest(); |
| 510 req.open('GET', '../../api/_permission_features.json', false); |
| 511 req.send(null); |
| 512 |
| 513 var permissionFeatures = JSON.parse(JSON.minify(req.responseText)); |
| 514 |
507 return schema.filter(function(module) { | 515 return schema.filter(function(module) { |
508 return !disableDocs(module) && | 516 if (disableDocs(module)) |
509 module.namespace.indexOf('experimental') < 0; | 517 return false; |
| 518 |
| 519 if ((module.namespace.indexOf('experimental') > -1) != |
| 520 includeExperimental) { |
| 521 return false; |
| 522 } |
| 523 |
| 524 var feature = permissionFeatures[module.namespace]; |
| 525 if (feature && feature.extension_types.indexOf(packageType) == -1) |
| 526 return false; |
| 527 |
| 528 return true; |
510 }).map(function(module) { | 529 }).map(function(module) { |
511 return module.namespace; | 530 return module.namespace; |
512 }).sort(); | 531 }).sort(); |
513 } | |
514 | |
515 function experimentalAPIs() { | |
516 return schema.filter(function(module) { | |
517 return !disableDocs(module) && | |
518 module.namespace.indexOf('experimental') == 0; | |
519 }).map(function(module) { | |
520 return module.namespace; | |
521 }).sort(); | |
522 } | 532 } |
523 | 533 |
524 function getDataFromPageHTML(id) { | 534 function getDataFromPageHTML(id) { |
525 var node = document.getElementById(id); | 535 var node = document.getElementById(id); |
526 if (!node) | 536 if (!node) |
527 return; | 537 return; |
528 return node.innerHTML; | 538 return node.innerHTML; |
529 } | 539 } |
530 | 540 |
531 function isArray(type) { | 541 function isArray(type) { |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 } | 826 } |
817 if (a.name > b.name) { | 827 if (a.name > b.name) { |
818 return 1; | 828 return 1; |
819 } | 829 } |
820 return 0; | 830 return 0; |
821 } | 831 } |
822 | 832 |
823 function disableDocs(obj) { | 833 function disableDocs(obj) { |
824 return !!obj.nodoc; | 834 return !!obj.nodoc; |
825 } | 835 } |
OLD | NEW |