1 | /**
|
2 | * @license
|
3 | * Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
4 | * This code may only be used under the BSD style license found at
|
5 | * http://polymer.github.io/LICENSE.txt
|
6 | * The complete set of authors may be found at
|
7 | * http://polymer.github.io/AUTHORS.txt
|
8 | * The complete set of contributors may be found at
|
9 | * http://polymer.github.io/CONTRIBUTORS.txt
|
10 | * Code distributed by Google as part of the polymer project is also
|
11 | * subject to an additional IP rights grant found at
|
12 | * http://polymer.github.io/PATENTS.txt
|
13 | */
|
14 | /**
|
15 | * The global namespace of features contained in an analysis.
|
16 | *
|
17 | * Top-level members are unnamespaced, everything else is contained
|
18 | * in a namespace. Often an analysis will contain only one namespace at
|
19 | * the root.
|
20 | */
|
21 | export interface Analysis {
|
22 | schema_version: string;
|
23 | /** All elements found. */
|
24 | elements?: Element[];
|
25 | /** All toplevel functions found. */
|
26 | functions?: Function[];
|
27 | /** All element mixins found. */
|
28 | mixins?: ElementMixin[];
|
29 | /** All toplevel namespaces found. */
|
30 | namespaces?: Namespace[];
|
31 | /**
|
32 | * All toplevel classes found that were not covered by one of the other types.
|
33 | *
|
34 | * e.g. classes that are elements are only found in `elements`
|
35 | */
|
36 | classes?: Class[];
|
37 | /**
|
38 | * An extension point for framework-specific metadata, as well as any
|
39 | * metadata not yet standardized here such as what polyfills are needed,
|
40 | * behaviors and mixins used, the framework that the package was written in,
|
41 | * tags/categories, framework config files, etc.
|
42 | *
|
43 | * Framework-specific metadata should be put into a sub-object with the name
|
44 | * of that framework.
|
45 | */
|
46 | metadata?: any;
|
47 | }
|
48 | /**
|
49 | * The base interface, holding properties common to many nodes.
|
50 | */
|
51 | export interface Feature {
|
52 | /** Where this feature is defined in source code. */
|
53 | sourceRange?: SourceRange;
|
54 | /**
|
55 | * An extension point for framework-specific metadata, as well as any
|
56 | * metadata not yet standardized here such as what polyfills are needed,
|
57 | * behaviors and mixins used, the framework that the element was written in,
|
58 | * tags/categories, links to specs that the element implements, etc.
|
59 | *
|
60 | * Framework-specific metadata should be put into a sub-object with the name
|
61 | * of that framework.
|
62 | */
|
63 | metadata?: any;
|
64 | }
|
65 | export interface SourceRange {
|
66 | /**
|
67 | * Path to the file containing the definition of the feature,
|
68 | * relative to the parent feature, or the package if the feature has no parent
|
69 | * (e.g. elements).
|
70 | *
|
71 | * If blank, the feature is defined in the same file as its parent.
|
72 | */
|
73 | file?: string;
|
74 | start: Position;
|
75 | end: Position;
|
76 | }
|
77 | export interface Position {
|
78 | /** Line number, starting from zero. */
|
79 | line: number;
|
80 | /** Column offset within the line, starting from zero. */
|
81 | column: number;
|
82 | }
|
83 | export declare type Privacy = 'public' | 'private' | 'protected';
|
84 | export interface Function extends Feature {
|
85 | /**
|
86 | * The globally accessible property-path of the namespace. e.q. `Polymer.dom`
|
87 | */
|
88 | name: string;
|
89 | /** A markdown description for the namespace. */
|
90 | description?: string;
|
91 | summary?: string;
|
92 | params?: {
|
93 | name: string;
|
94 | type?: string;
|
95 | }[];
|
96 | return?: {
|
97 | type?: string;
|
98 | desc?: string;
|
99 | };
|
100 | privacy: Privacy;
|
101 | }
|
102 | export interface Namespace extends Feature {
|
103 | /**
|
104 | * The globally accessible property-path of the namespace. e.q. `Polymer.dom`
|
105 | */
|
106 | name: string;
|
107 | /** A markdown description for the namespace. */
|
108 | description?: string;
|
109 | /** A markdown summary for the namespace. */
|
110 | summary?: string;
|
111 | elements?: Element[];
|
112 | functions?: Function[];
|
113 | mixins?: ElementMixin[];
|
114 | namespaces?: Namespace[];
|
115 | classes?: Class[];
|
116 | }
|
117 | export interface Class extends Feature {
|
118 | /** The name of the class. */
|
119 | name?: string;
|
120 | /**
|
121 | * The path, relative to the base directory of the package.
|
122 | *
|
123 | * e.g. `paper-input.html` or `app-toolbar/app-toolbar.html` (given that
|
124 | * app-toolbar lives in the app-layout package).
|
125 | */
|
126 | path: string | undefined;
|
127 | /** A markdown description. */
|
128 | description: string;
|
129 | /** A markdown summary. */
|
130 | summary: string;
|
131 | /**
|
132 | * Paths, relative to the base directory of the package, to demo pages for
|
133 | * this feauture.
|
134 | *
|
135 | * e.g. `[{url: 'demos/index.html', description: 'How it works'}, ...]`
|
136 | */
|
137 | demos: Demo[];
|
138 | /** Names of mixins applied. */
|
139 | mixins?: string[];
|
140 | /** The properties that this feature has. */
|
141 | properties?: Property[];
|
142 | /** The instance methods that this feature has. */
|
143 | methods?: Method[];
|
144 | /** The static, class-level methods that this feature has. */
|
145 | staticMethods?: Method[];
|
146 | privacy: Privacy;
|
147 | /**
|
148 | * The class, if any, that this class extends.
|
149 | */
|
150 | superclass?: string;
|
151 | }
|
152 | export interface ElementLike extends Class {
|
153 | /** The attributes that this element is known to understand. */
|
154 | attributes?: Attribute[];
|
155 | /** The events that this element fires. */
|
156 | events?: Event[];
|
157 | /** The shadow dom content slots that this element accepts. */
|
158 | 'slots': Slot[];
|
159 | /** Information useful for styling the element and its children. */
|
160 | styling: {
|
161 | /** CSS selectors that the element recognizes on itself for styling. */
|
162 | selectors: {
|
163 | /** The CSS selector. e.g. `.bright`, `[height=5]`, `[cascade]`. */
|
164 | value: string;
|
165 | /**
|
166 | * A markdown description of the effect of this selector matching
|
167 | * on the element.
|
168 | */
|
169 | description: string;
|
170 | }[];
|
171 | /** CSS Variables that the element understands. */
|
172 | cssVariables: {
|
173 | /** The name of the variable. e.g. `--header-color`, `--my-element-size`*/
|
174 | name: string;
|
175 | /** The type of the variable. Advisory. e.g. `color`, `size` */
|
176 | type?: string;
|
177 | /** A markdown description of the variable. */
|
178 | description?: string;
|
179 | /**
|
180 | * A markdown description of how the element will fallback if the variable
|
181 | * isn't defined.
|
182 | */
|
183 | fallbackBehavior?: string;
|
184 | }[];
|
185 | /** If true, the element must be given an explicit size by its context. */
|
186 | needsExplicitSize?: boolean;
|
187 | };
|
188 | }
|
189 | export interface Element extends ElementLike {
|
190 | /** The tagname that the element registers itself as. e.g. `paper-input` */
|
191 | tagname?: string;
|
192 | /**
|
193 | * The class name for this element.
|
194 | *
|
195 | * e.g. `MyElement`, `Polymer.PaperInput`
|
196 | */
|
197 | name?: string;
|
198 | /**
|
199 | * The tagname that the element extends, if any. The value of the `extends`
|
200 | * option that's passed into `customElements.define`.
|
201 | *
|
202 | * e.g. `input`, `paper-button`, `my-super-element`
|
203 | */
|
204 | extends?: string;
|
205 | /**
|
206 | * The class that this element extends.
|
207 | *
|
208 | * This is non-optional, as every custom element must have HTMLElement in
|
209 | * its prototype change.
|
210 | *
|
211 | * e.g. `HTMLElement`, `HTMLInputElement`, `MyNamespace.MyBaseElement`
|
212 | */
|
213 | superclass: string;
|
214 | }
|
215 | export interface ElementMixin extends ElementLike {
|
216 | /**
|
217 | * The name for this mixin.
|
218 | *
|
219 | * e.g. `MyMixin`, `Polymer.PaperInputMixin`
|
220 | */
|
221 | name: string;
|
222 | }
|
223 | export interface Attribute extends Feature {
|
224 | /** The name of the attribute. e.g. `value`, `icon`, `should-collapse`. */
|
225 | name: string;
|
226 | /** A markdown description for the attribute. */
|
227 | description?: string;
|
228 | /**
|
229 | * The type that the attribute will be serialized/deserialized as.
|
230 | *
|
231 | * e.g. `string`, `number`, `boolean`, `RegExp`, `Array`, `Object`.
|
232 | */
|
233 | type?: string;
|
234 | /**
|
235 | * The default value of the attribute, if any.
|
236 | *
|
237 | * As attributes are always strings, this is the actual value, not a human
|
238 | * readable description.
|
239 | */
|
240 | defaultValue?: string;
|
241 | /** The identifier of the class or mixin that declared this property. */
|
242 | inheritedFrom?: string;
|
243 | }
|
244 | export interface Property extends Feature {
|
245 | /** The name of the property. e.g. `value`, `icon`, `shouldCollapse`. */
|
246 | name: string;
|
247 | /** A markdown description of the property. */
|
248 | description: string;
|
249 | /**
|
250 | * The javascript type of the property.
|
251 | *
|
252 | * There's no standard here. Common choices are closure compiler syntax
|
253 | * and typescript syntax.
|
254 | */
|
255 | type: string;
|
256 | /**
|
257 | * A string representation of the default value. Intended only to be human
|
258 | * readable, so may be a description, an identifier name, etc.
|
259 | */
|
260 | defaultValue?: string;
|
261 | /** Nested subproperties hanging off of this property. */
|
262 | properties?: Property[];
|
263 | privacy: Privacy;
|
264 | /** The identifier of the class or mixin that declared this property. */
|
265 | inheritedFrom?: string;
|
266 | }
|
267 | export interface Method extends Feature {
|
268 | /** The name of the property. e.g. `value`, `icon`, `shouldCollapse`. */
|
269 | name: string;
|
270 | /** A markdown description of the property. */
|
271 | description: string;
|
272 | /**
|
273 | * An array of data objects describing the method signature. This data may be
|
274 | * incomplete. For example, only argument names can be detected from an
|
275 | * undocumented JavaScript function. Argument types can only be read from
|
276 | * associated JSDoc via @param tags
|
277 | */
|
278 | params?: Parameter[];
|
279 | /**
|
280 | * Data describing the method return type. This data may be incomplete.
|
281 | * For example, the return type can be detected from a documented JavaScript
|
282 | * function with associated JSDoc and a @return tag.
|
283 | */
|
284 | return?: {
|
285 | type?: string;
|
286 | desc?: string;
|
287 | };
|
288 | privacy: Privacy;
|
289 | /** The identifier of the class or mixin that declared this property. */
|
290 | inheritedFrom?: string;
|
291 | }
|
292 | export interface Parameter {
|
293 | name: string;
|
294 | type?: string;
|
295 | description?: string;
|
296 | }
|
297 | export interface Event extends Feature {
|
298 | /** The name of the event. */
|
299 | name: string;
|
300 | /** A markdown description of the event. */
|
301 | description: string;
|
302 | /**
|
303 | * The type of the event object that's fired.
|
304 | *
|
305 | * e.g. `Event`, `CustomEvent`, `KeyboardEvent`, `MyCustomEvent`.
|
306 | */
|
307 | type: string;
|
308 | /** Information about the `detail` field of the event. */
|
309 | detail?: {
|
310 | properties: Property[];
|
311 | };
|
312 | /** The identifier of the class or mixin that declared this property. */
|
313 | inheritedFrom?: string;
|
314 | }
|
315 | export interface Slot extends Feature {
|
316 | /** The name of the slot. e.g. `banner`, `body`, `tooltipContents` */
|
317 | name: string;
|
318 | /** A markdown description of the slot. */
|
319 | description: string;
|
320 | }
|
321 | export interface Demo {
|
322 | /** A markdown description of the demo. */
|
323 | description?: string;
|
324 | /** Relative URL of the demo. */
|
325 | url: string;
|
326 | }
|