| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 @license | |
| 3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
| 4 This code may only be used under the BSD style license found at http://polym
er.github.io/LICENSE.txt | |
| 5 The complete set of authors may be found at http://polymer.github.io/AUTHORS
.txt | |
| 6 The complete set of contributors may be found at http://polymer.github.io/CO
NTRIBUTORS.txt | |
| 7 Code distributed by Google as part of the polymer project is also | |
| 8 subject to an additional IP rights grant found at http://polymer.github.io/P
ATENTS.txt | |
| 9 --> | |
| 10 <link rel="import" href="elements/core-doc-page.html"> | |
| 11 <link rel="import" href="elements/core-doc-toc.html"> | |
| 12 <link rel="import" href="../core-icon/core-icon.html"> | |
| 13 | |
| 14 <!-- | |
| 15 Displays formatted source documentation scraped from input urls. | |
| 16 | |
| 17 Documentation can be encoded into html comments (<!-- ... -->) or using Js
Doc notation (/** ... */). | |
| 18 | |
| 19 When using JsDoc notation, remember that the left-margin includes an asterisk an
d a single space. | |
| 20 This is important for markdown constructs that count spaces. Code blocks for exa
mple, must be | |
| 21 five spaces from the first asterisk. | |
| 22 | |
| 23 ## Markdown | |
| 24 | |
| 25 Markdown format is supported. | |
| 26 | |
| 27 ### Links | |
| 28 | |
| 29 Arbitrary links can be encoded using [standard markdown format](http://daringfir
eball.net/projects/markdown/syntax). | |
| 30 [GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-mark
down) is also supported. | |
| 31 | |
| 32 Links to other topics can be made with hash-links [core-doc-viewer](#core-doc-vi
ewer). | |
| 33 | |
| 34 ### Code | |
| 35 | |
| 36 Example | |
| 37 | |
| 38 Four space indents indicate code blocks. | |
| 39 | |
| 40 <code>blocks are syntax highlighted</code> | |
| 41 | |
| 42 <script> | |
| 43 while(true) { | |
| 44 javascript('is highlighted also'); | |
| 45 } | |
| 46 </script> | |
| 47 | |
| 48 ### Blockquote | |
| 49 | |
| 50 > Blockquote is supported for long text that needs to wrap with a common left s
ide indent. | |
| 51 > Blockquote is supported for long text that needs to wrap with a common left s
ide indent. | |
| 52 | |
| 53 ### Lists | |
| 54 | |
| 55 1. enumerated | |
| 56 1. lists | |
| 57 | |
| 58 Use - or + for bullet points: | |
| 59 | |
| 60 - bullet | |
| 61 - lists | |
| 62 | |
| 63 ### Tables | |
| 64 | |
| 65 | First Header | Second Header | | |
| 66 | ------------- | ------------- | | |
| 67 | Content Cell | Content Cell | | |
| 68 | Content Cell | Content Cell | | |
| 69 | |
| 70 ### HTML | |
| 71 | |
| 72 Arbitrary HTML is also supported | |
| 73 | |
| 74 <input><button>Button</button><hr/> | |
| 75 | |
| 76 @class core-doc-viewer | |
| 77 @homepage github.io | |
| 78 --> | |
| 79 | |
| 80 <polymer-element name="core-doc-viewer" attributes="sources route url" horizonta
l layout> | |
| 81 | |
| 82 <template> | |
| 83 | |
| 84 <style> | |
| 85 | |
| 86 core-doc-toc { | |
| 87 display: none; | |
| 88 width: 332px; | |
| 89 overflow-x: hidden; | |
| 90 } | |
| 91 | |
| 92 </style> | |
| 93 | |
| 94 <context-free-parser url="{{url}}" on-data-ready="{{parserDataReady}}"></con
text-free-parser> | |
| 95 | |
| 96 <template repeat="{{sources}}"> | |
| 97 <context-free-parser url="{{}}" on-data-ready="{{parserDataReady}}"></cont
ext-free-parser> | |
| 98 </template> | |
| 99 | |
| 100 <core-doc-toc id="toc" data="{{classes}}" selected="{{selected}}"></core-doc
-toc> | |
| 101 <core-doc-page flex data="{{data}}"></core-doc-page> | |
| 102 | |
| 103 </template> | |
| 104 | |
| 105 <script> | |
| 106 | |
| 107 Polymer('core-doc-viewer', { | |
| 108 /** | |
| 109 * A single file to parse for docs | |
| 110 * | |
| 111 * @attribute url | |
| 112 * @type String | |
| 113 * @default '' | |
| 114 */ | |
| 115 | |
| 116 /** | |
| 117 * Class documentation extracted from the parser | |
| 118 * | |
| 119 * @property classes | |
| 120 * @type Array | |
| 121 * @default [] | |
| 122 */ | |
| 123 classes: [], | |
| 124 | |
| 125 /** | |
| 126 * Files to parse for docs | |
| 127 * | |
| 128 * @attribute sources | |
| 129 * @type Array | |
| 130 * @default [] | |
| 131 */ | |
| 132 sources: [], | |
| 133 | |
| 134 ready: function() { | |
| 135 window.addEventListener('hashchange', this.parseLocationHash.bind(this))
; | |
| 136 this.parseLocationHash(); | |
| 137 }, | |
| 138 | |
| 139 parseLocationHash: function() { | |
| 140 this.route = window.location.hash.slice(1); | |
| 141 }, | |
| 142 | |
| 143 routeChanged: function() { | |
| 144 this.validateRoute(); | |
| 145 }, | |
| 146 | |
| 147 validateRoute: function() { | |
| 148 if (this.route) { | |
| 149 this.classes.some(function(c) { | |
| 150 // The URL fragment might be just a class name, | |
| 151 // or it might be a class name followed by a '.' and then | |
| 152 // a section of the page. | |
| 153 // We want to match on class names here, so split on '.'. | |
| 154 // E.g.: 'core-ajax.properties.xhrArgs' -> 'core-ajax' | |
| 155 // 'core-xhr' -> 'core-xhr' | |
| 156 if (c.name === this.route.split('.')[0]) { | |
| 157 this.data = c; | |
| 158 this.route = ''; | |
| 159 return; | |
| 160 } | |
| 161 }, this); | |
| 162 } | |
| 163 }, | |
| 164 | |
| 165 selectedChanged: function() { | |
| 166 this.data = this.classes[this.selected]; | |
| 167 }, | |
| 168 | |
| 169 parserDataReady: function(event) { | |
| 170 this.assimilateData(event.target.data); | |
| 171 }, | |
| 172 | |
| 173 assimilateData: function(data) { | |
| 174 this.classes = this.classes.concat(data.classes); | |
| 175 this.classes.sort(function(a, b) { | |
| 176 var na = a && a.name.toLowerCase(), nb = b && b.name.toLowerCase(); | |
| 177 return (na < nb) ? -1 : (na == nb) ? 0 : 1; | |
| 178 }); | |
| 179 if (!this.data && !this.route && this.classes.length) { | |
| 180 this.data = this.classes[0]; | |
| 181 } | |
| 182 if (this.classes.length > 1) { | |
| 183 this.$.toc.style.display = 'block'; | |
| 184 } | |
| 185 this.validateRoute(); | |
| 186 } | |
| 187 | |
| 188 }); | |
| 189 | |
| 190 </script> | |
| 191 | |
| 192 </polymer-element> | |
| OLD | NEW |