Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit 340c089

Browse files
committed
more API docs
1 parent 9cb30dc commit 340c089

File tree

1 file changed

+69
-4
lines changed

1 file changed

+69
-4
lines changed

polymer-meta.html

+69-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,35 @@
88
* @module Polymer Elements
99
*/
1010
/**
11-
* polymer-meta is used to manage metadata. When an instance of polymer-meta
12-
* is created, it's automatically registered and add to the metaData storage given an id
13-
* is set on the element. Use byId() to retrive a specific polymer-meta and
14-
* the property "list" to retrieve all registered polymer-meta's.
11+
* The `polymer-meta` elements provides a method of constructing a
12+
* self-organizing database. It is useful to collate element meta-data for
13+
* things like catalogs and for sandbox.
14+
*
15+
* Example, an element folder has a `metadata.html` file in it, that contains a
16+
* polymer-meta, something like this:
17+
*
18+
* <polymer-meta id="my-element">
19+
* <property name="color" type="color"></property>
20+
* </polymer-meta>
21+
*
22+
* An application can import as many of these files as it wants, and then use
23+
* polymer-meta again to access the collected data.
24+
*
25+
* <script>
26+
* var meta = document.createElement('polymer-meta');
27+
* console.log(meta.list); // dump a list of all meta-data elements that have been created
28+
* </script>
29+
*
30+
* Use `byId(id)` to retrive a specific polymer-meta.
31+
*
32+
* <script>
33+
* var meta = document.createElement('polymer-meta');
34+
* console.log(meta.byId('my-element'));
35+
* </script>
36+
*
37+
* By default all meta-data are stored in a signle databse. If your meta-data
38+
* have different types and want them to be stored separately, use `type` to
39+
* differentiate them.
1540
*
1641
* @class polymer-meta
1742
*/
@@ -26,6 +51,14 @@
2651

2752
Polymer('polymer-meta', {
2853
alwaysPrepare: true,
54+
/**
55+
* The type of meta-data. All meta-data with the same type with be
56+
* stored together.
57+
*
58+
* @attribute type
59+
* @type string
60+
* @default 'default'
61+
*/
2962
type: 'default',
3063
ready: function() {
3164
this.idChanged();
@@ -58,12 +91,44 @@
5891
this.metaArray.splice(i, 1);
5992
}
6093
},
94+
/**
95+
* Returns a list of all meta-data elements with the same type.
96+
*
97+
* @attribute list
98+
* @type array
99+
* @default []
100+
*/
61101
get list() {
62102
return this.metaArray;
63103
},
104+
/**
105+
* Returns the first `<template>` in the `<polymer-meta>` subtree. This
106+
* is useful to store element example.
107+
*
108+
* <polymer-meta id="polymer-ui-toolbar" label="Polymer Toolbar">
109+
* <template>
110+
* <polymer-ui-toolbar theme="polymer-ui-light-theme">
111+
* <polymer-ui-icon-button icon="menu"></polymer-ui-icon-button>
112+
* <div flex>Title</div>
113+
* <polymer-ui-icon-button icon="add"></polymer-ui-icon-button>
114+
* </polymer-ui-toolbar>
115+
* </template>
116+
* </polymer-meta>
117+
*
118+
* @attribute archetype
119+
* @type node
120+
* @default null
121+
*/
64122
get archetype() {
65123
return this.querySelector('template');
66124
},
125+
/**
126+
* Retrieves meta-data by ID.
127+
*
128+
* @method byId
129+
* @param {String} id The ID of the meta-data to be returned.
130+
* @returns Returns meta-data.
131+
*/
67132
byId: function(id) {
68133
return this.metaData[id];
69134
},

0 commit comments

Comments
 (0)