| OLD | NEW |
| 1 /** | 1 /** |
| 2 * @fileoverview This file is the controller for generating extension | 2 * @fileoverview This file is the controller for generating extension |
| 3 * doc pages. | 3 * doc pages. |
| 4 * | 4 * |
| 5 * It expects to have available via XHR (relative path): | 5 * It expects to have available via XHR (relative path): |
| 6 * 1) API_TEMPLATE which is the main template for the api pages. | 6 * 1) API_TEMPLATE which is the main template for the api pages. |
| 7 * 2) A file located at SCHEMA which is shared with the extension system and | 7 * 2) A file located at SCHEMA which is shared with the extension system and |
| 8 * defines the methods and events contained in one api. | 8 * defines the methods and events contained in one api. |
| 9 * 3) (Possibly) A static version of the current page url in /static/. I.e. | 9 * 3) (Possibly) A static version of the current page url in /static/. I.e. |
| 10 * if called as ../foo.html, it will look for ../static/foo.html. | 10 * if called as ../foo.html, it will look for ../static/foo.html. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 function showPageTOC() { | 266 function showPageTOC() { |
| 267 return module || getDataFromPageHTML('pageData-showTOC'); | 267 return module || getDataFromPageHTML('pageData-showTOC'); |
| 268 } | 268 } |
| 269 | 269 |
| 270 function getStaticTOC() { | 270 function getStaticTOC() { |
| 271 var staticHNodes = evalXPathFromId(".//h2|h3", "static"); | 271 var staticHNodes = evalXPathFromId(".//h2|h3", "static"); |
| 272 var retval = []; | 272 var retval = []; |
| 273 var lastH2; | 273 var lastH2; |
| 274 | 274 |
| 275 staticHNodes.each(function(n, i) { | 275 staticHNodes.each(function(n, i) { |
| 276 var anchorName = n.nodeName + "-" + i; | 276 var anchorName = n.id || n.nodeName + "-" + i; |
| 277 var a = document.createElement('a'); | 277 if (!n.id) { |
| 278 a.name = anchorName; | 278 var a = document.createElement('a'); |
| 279 n.parentNode.insertBefore(a, n); | 279 a.name = anchorName; |
| 280 n.parentNode.insertBefore(a, n); |
| 281 } |
| 280 var dataNode = { name: n.innerHTML, href: anchorName }; | 282 var dataNode = { name: n.innerHTML, href: anchorName }; |
| 281 | 283 |
| 282 if (n.nodeName == "H2") { | 284 if (n.nodeName == "H2") { |
| 283 retval.push(dataNode); | 285 retval.push(dataNode); |
| 284 lastH2 = dataNode; | 286 lastH2 = dataNode; |
| 285 lastH2.children = []; | 287 lastH2.children = []; |
| 286 } else { | 288 } else { |
| 287 lastH2.children.push(dataNode); | 289 lastH2.children.push(dataNode); |
| 288 } | 290 } |
| 289 }); | 291 }); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 } | 354 } |
| 353 | 355 |
| 354 function getSignatureString(parameters) { | 356 function getSignatureString(parameters) { |
| 355 var retval = []; | 357 var retval = []; |
| 356 parameters.each(function(param, i) { | 358 parameters.each(function(param, i) { |
| 357 retval.push(getTypeName(param) + " " + param.name); | 359 retval.push(getTypeName(param) + " " + param.name); |
| 358 }); | 360 }); |
| 359 | 361 |
| 360 return retval.join(", "); | 362 return retval.join(", "); |
| 361 } | 363 } |
| 364 |
| 365 function sortByName(a, b) { |
| 366 if (a.name < b.name) { |
| 367 return -1; |
| 368 } |
| 369 if (a.name > b.name) { |
| 370 return 1; |
| 371 } |
| 372 return 0; |
| 373 } |
| OLD | NEW |