Added Polymer

This commit is contained in:
Thaum
2014-11-26 10:18:35 +00:00
parent 5eea4714b2
commit 3408ba9e8d
1210 changed files with 394645 additions and 47 deletions

View File

@@ -0,0 +1,27 @@
{
"name": "core-doc-viewer",
"private": true,
"dependencies": {
"core-ajax": "Polymer/core-ajax#^0.5.0",
"core-menu": "Polymer/core-menu#^0.5.0",
"core-item": "Polymer/core-item#^0.5.0",
"core-toolbar": "Polymer/core-toolbar#^0.5.0",
"core-icons": "Polymer/core-icons#^0.5.0",
"core-icon-button": "Polymer/core-icon-button#^0.5.0",
"core-header-panel": "Polymer/core-header-panel#^0.5.0",
"context-free-parser": "Polymer/context-free-parser#^0.5.0",
"marked-element": "PolymerLabs/marked-element#^0.5.0",
"prettify-element": "Polymer/prettify-element#^0.5.0"
},
"version": "0.5.1",
"homepage": "https://github.com/Polymer/core-doc-viewer",
"_release": "0.5.1",
"_resolution": {
"type": "version",
"tag": "0.5.1",
"commit": "4c30c0104ef13b0b45cb3c75729223ec5eb5a9db"
},
"_source": "git://github.com/Polymer/core-doc-viewer.git",
"_target": "^0.5.0",
"_originalSource": "Polymer/core-doc-viewer"
}

View File

@@ -0,0 +1,7 @@
core-doc-viewer
================
See the [component page](http://polymer-project.org/docs/elements/core-elements.html#core-doc-viewer) for more information.
**Note** If you update elements in this repo, you'll need to rebuild `build.sh` in [core-component-page-dev](https://github.com/Polymer/core-component-page-dev) so they're used in the compiled version (core-component-page).

View File

@@ -0,0 +1,17 @@
{
"name": "core-doc-viewer",
"private": true,
"dependencies": {
"core-ajax": "Polymer/core-ajax#^0.5.0",
"core-menu": "Polymer/core-menu#^0.5.0",
"core-item": "Polymer/core-item#^0.5.0",
"core-toolbar": "Polymer/core-toolbar#^0.5.0",
"core-icons": "Polymer/core-icons#^0.5.0",
"core-icon-button": "Polymer/core-icon-button#^0.5.0",
"core-header-panel": "Polymer/core-header-panel#^0.5.0",
"context-free-parser": "Polymer/context-free-parser#^0.5.0",
"marked-element": "PolymerLabs/marked-element#^0.5.0",
"prettify-element": "Polymer/prettify-element#^0.5.0"
},
"version": "0.5.1"
}

View File

@@ -0,0 +1,228 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="elements/core-doc-page.html">
<link rel="import" href="elements/core-doc-toc.html">
<link rel="import" href="../core-icon/core-icon.html">
<!--
Displays formatted source documentation scraped from input urls.
Documentation can be encoded into html comments (&lt;!-- ... --&gt;) or using JsDoc notation (/&#42;&#42; ... &#42;/).
When using JsDoc notation, remember that the left-margin includes an asterisk and a single space.
This is important for markdown constructs that count spaces. Code blocks for example, must be
five spaces from the first asterisk.
## Markdown
Markdown format is supported.
### Links
Arbitrary links can be encoded using [standard markdown format](http://daringfireball.net/projects/markdown/syntax).
[GitHub Flavored Markdown](https://help.github.com/articles/github-flavored-markdown) is also supported.
Links to other topics can be made with hash-links [core-doc-viewer](#core-doc-viewer).
### Code
Example
Four space indents indicate code blocks.
<code>blocks are syntax highlighted</code>
<script>
while(true) {
javascript('is highlighted also');
}
</script>
### Blockquote
> Blockquote is supported for long text that needs to wrap with a common left side indent.
> Blockquote is supported for long text that needs to wrap with a common left side indent.
### Lists
1. enumerated
1. lists
Use - or + for bullet points:
- bullet
- lists
### Tables
| First Header | Second Header |
| ------------- | ------------- |
| Content Cell | Content Cell |
| Content Cell | Content Cell |
### HTML
Arbitrary HTML is also supported
<input><button>Button</button><hr/>
@class core-doc-viewer
@homepage github.io
-->
<polymer-element name="core-doc-viewer" attributes="sources route url" horizontal layout>
<template>
<style>
core-doc-toc {
display: none;
width: 332px;
overflow-x: hidden;
}
</style>
<context-free-parser url="{{url}}" on-data-ready="{{parserDataReady}}"></context-free-parser>
<template repeat="{{sources}}">
<context-free-parser url="{{}}" on-data-ready="{{parserDataReady}}"></context-free-parser>
</template>
<core-doc-toc id="toc" data="{{classes}}" selected="{{selected}}"></core-doc-toc>
<core-doc-page flex data="{{data}}"></core-doc-page>
</template>
<script>
Polymer({
/**
* A single file to parse for docs
*
* @attribute url
* @type String
* @default ''
*/
/**
* Class documentation extracted from the parser
*
* @property classes
* @type Array
* @default []
*/
classes: [],
/**
* Files to parse for docs
*
* @attribute sources
* @type Array
* @default []
*/
sources: [],
ready: function() {
window.addEventListener('hashchange', this.parseLocationHash.bind(this));
this.parseLocationHash();
},
parseLocationHash: function() {
this.route = window.location.hash.slice(1);
},
routeChanged: function() {
this.validateRoute();
},
validateRoute: function() {
if (this.route) {
this.classes.some(function(c) {
// The URL fragment might be just a class name,
// or it might be a class name followed by a '.' and then
// a section of the page.
// We want to match on class names here, so split on '.'.
// E.g.: 'core-ajax.properties.xhrArgs' -> 'core-ajax'
// 'core-xhr' -> 'core-xhr'
if (c.name === this.route.split('.')[0]) {
this.data = c;
this.route = '';
return;
}
}, this);
}
},
selectedChanged: function() {
this.data = this.classes[this.selected];
},
parserDataReady: function(event, detail, sender) {
var path = '';
if (this.sources.length) {
var path = event.target.templateInstance.model;
var idx = path.lastIndexOf('/');
path = idx != -1 ? path.substr(0, idx) : '.';
} else {
var parts = location.pathname.split('/');
parts.pop();
path = parts.join('/');
}
var data = event.target.data;
var xhr = new XMLHttpRequest();
xhr.open('GET', path + '/bower.json');
xhr.onerror = function(e) {
this.assimilateData(data);
}.bind(this);
xhr.onloadend = function(e) {
// Add package version to data.
if (e.target.status == 200) {
var version = JSON.parse(e.target.response).version;
// Assumes all classes (elements) in the list are the same version.
for (var i = 0, c; c = data.classes[i]; ++i) {
c.version = version;
}
}
this.assimilateData(data);
}.bind(this);
xhr.send();
},
assimilateData: function(data) {
this.classes = this.classes.concat(data.classes);
this.classes.sort(function(a, b) {
var na = a && a.name.toLowerCase(), nb = b && b.name.toLowerCase();
return (na < nb) ? -1 : (na == nb) ? 0 : 1;
});
if (!this.data && !this.route && this.classes.length) {
this.data = this.classes[0];
}
if (this.classes.length > 1) {
this.$.toc.style.display = 'block';
}
this.validateRoute();
}
});
</script>
</polymer-element>

View File

@@ -0,0 +1,46 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<!doctype html>
<html>
<head>
<title>core-doc-viewer</title>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="core-doc-viewer.html">
<style>
html, body {
font-family: Arial, sans-serif;
margin: 0;
}
core-doc-viewer {
height: 100vh;
}
</style>
</head>
<body unresolved>
<core-doc-viewer sources='[
"../core-doc-viewer/core-doc-viewer.html",
"../core-ajax/core-ajax.html",
"../core-ajax/core-xhr.html",
"../core-icon/core-icon.html"
]'></core-doc-viewer>
</body>
</html>

View File

@@ -0,0 +1,147 @@
/*
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
:host {
display: block;
}
#info > * {
margin-right: 20px;
}
core-icon {
margin-right: 5px;
}
.main {
padding: 0 72px;
max-width: 832px;
margin: 0 auto;
}
marked-element {
display: block;
}
h1 {
color: #E91E63;
font-size: 52px;
line-height: 60px;
font-weight: inherit;
}
.box {
margin-bottom: 40px;
}
.box:not(.top) .details {
padding: 16px;
}
.box:not(.top) .details .params {
margin-top: 40px;
}
.box:not(.top) h3 {
padding: 16px;
color: white;
font-weight: inherit;
font-size: 20px;
line-height: 48px;
margin: 0;
}
.box:not(.top) pre {
padding: initial;
background-color: transparent;
margin: initial;
font-size: 12px;
}
.box code {
color: currentcolor;
font-weight: 500;
}
.top pre {
background-color: rgb(250, 250, 250);
padding: 16px;
}
pre {
max-width: 832px;
white-space: pre-wrap;
overflow: hidden;
border: none;
}
.attribute-box .details {
background-color: #ffcbbb;
border-bottom: 1px solid rgba(255, 86, 33, 0.5);
}
.attribute-box h3 {
background-color: #ff5621;
}
.property-box .details {
background-color: #fbe7b1;
border-bottom: 1px solid rgba(243, 179, 0, 0.5);
}
.property-box h3 {
background-color: #f3b300;
}
.method-box .details {
background-color: #a6ffea;
border-bottom: 1px solid rgba(0, 190, 164, 0.5);
}
.method-box h3 {
background-color: #00bea4;
}
.event-box .details {
background-color: #c5d9fb;
border-bottom: 1px solid rgba(65, 132, 243, 0.5);
}
.event-box h3 {
background-color: #4184f3;
}
.badge {
color: currentcolor;
}
code, pre {
color: #9f499b;
font-family: "Source Code Pro",Monaco,Menlo,Consolas,"Courier New",monospace;
}
pre .typ,pre .inline,.prettyprint .typ,.prettyprint .inline {
color: #6b499f
}
pre .pun,.prettyprint .pun {
color: #5c6bc0
}
pre .str,pre .string,.prettyprint .str,.prettyprint .string {
color: #ff4081
}
pre .pln,.prettyprint .pln {
color: #7986cb
}
pre .kwd,.prettyprint .kwd {
color: #d61a7f
}
pre .atn,pre .attribute-name,.prettyprint .atn,.prettyprint .attribute-name {
color: #6b499f
}
pre .atv,pre .attribute-value,.prettyprint .atv,.prettyprint .attribute-value {
color: #7986cb
}
pre .com,pre .comment,.prettyprint .com,.prettyprint .comment {
color: #8a8a8a
}

View File

@@ -0,0 +1,187 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../../core-icons/core-icons.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-header-panel/core-header-panel.html">
<link rel="import" href="../../marked-element/marked-element.html">
<link rel="import" href="../../prettify-element/prettify-import.html">
<link rel="import" href="../../context-free-parser/context-free-parser.html">
<!--
Displays formatted source documentation scraped from input urls.
@element core-doc-page
-->
<polymer-element name="core-doc-page" attributes="data" relative>
<template>
<link rel="stylesheet" href="core-doc-page.css">
<core-header-panel id="panel" mode="waterfall" fit>
<!--<core-toolbar>
<span style="margin: 0 72px;">{{data.name}}</span>
</core-toolbar>-->
<div class="main" on-marked-js-highlight="{{hilight}}">
<h1>{{data.name}}</h1>
<p id="info" layout horizontal center>
<span layout horizontal center><core-icon icon="home"></core-icon><a href="{{data | homepageFilter}}">Home Page</a></span>
<span layout horizontal center hidden?="{{!data.version}}"><core-icon icon="info-outline"></core-icon>Version: {{data.version}}</span>
</p>
<template if="{{data.extends}}">
<section class="top">
<h3 id="{{data.name}}.extends">Extends: <a href="#{{data.extends}}">{{data.extends}}</a></h3>
</section>
</template>
<template if="{{data.description}}">
<section class="box top">
<h3 id="{{data.name}}.summary">Summary</h3>
<marked-element text="{{data.description}}"></marked-element>
</section>
</template>
<template if="{{data.attributes.length}}">
<section class="box attribute-box">
<h3 id="{{data.name}}.attributes">Attributes</h3>
<template repeat="{{attribute in data.attributes}}">
<div class="details" horizontal layout>
<div class="details-name" flex id="{{data.name}}.attributes.{{attribute.name}}">
<p><code>{{attribute.name}}</code></p>
</div>
<div class="details-info" flex three>
<p layout horizontal center justified>
<code>&lt;<em>{{attribute.type}}</em>&gt;</code><span class="default" hidden?="{{!attribute.default}}">default: <code>{{attribute.default}}</code></span>
</p>
<marked-element text="{{attribute.description}}"></marked-element>
</div>
</div>
</template>
</section>
</template>
<template if="{{data.properties.length}}">
<section class="box property-box">
<h3 id="{{data.name}}.properties">Properties</h3>
<template repeat="{{property in data.properties}}">
<div class="details" horizontal layout>
<div class="details-name" flex id="{{data.name}}.properties.{{property.name}}">
<p><code>{{property.name}}</code></p>
</div>
<div class="details-info" flex three>
<p layout horizontal center justified>
<code>&lt;<em>{{property.type}}</em>&gt;</code><span class="default" hidden?="{{!property.default}}">default: <code>{{property.default}}</code></span>
</p>
<marked-element text="{{property.description}}"></marked-element>
</div>
</div>
</template>
</section>
</template>
<template if="{{data.events.length}}">
<section class="box event-box">
<h3 id="{{data.name}}.events">Events</h3>
<template repeat="{{event in data.events}}">
<div class="details" horizontal layout>
<div class="details-name" flex id="{{data.name}}.events.{{event.name}}">
<p><code>{{event.name}}</code></p>
</div>
<div class="details-info" flex three>
<marked-element text="{{event.description}}"></marked-element>
<template if="{{event.params.length}}">
<div class="params">
<p>Event details:</p>
<template repeat="{{param in event.params}}">
<p><code>&lt;<em>{{param.type}}</em>&gt; {{param.name}}</code></p>
<p><span>{{param.description}}</span></p>
</template>
</div>
</template>
</div>
</div>
</template>
</section>
</template>
<template if="{{data.methods.length}}">
<section class="box method-box">
<h3 id="{{data.name}}.methods">Methods</h3>
<template repeat="{{method in data.methods}}">
<div class="details" horizontal layout>
<div class="details-name" flex id="{{data.name}}.methods.{{method.name}}">
<p><code>{{method.name}}</code></p>
</div>
<div class="details-info" flex three>
<marked-element text="{{method.description}}"></marked-element>
<template if="{{method.params.length}}">
<div class="params">
<p>Method parameters:</p>
<template repeat="{{param in method.params}}">
<p><code>&lt;<em>{{param.type}}</em>&gt; {{param.name}}</code></p>
<p><span>{{param.description}}</span></p>
</template>
</div>
</template>
</div>
</div>
</template>
</section>
</template>
</div>
</core-header-panel>
</template>
<script>
Polymer('core-doc-page', {
hilight: function(event, detail, sender) {
detail.code = prettyPrintOne((detail.code || '').replace(/</g,'&lt;').replace(/>/g,'&gt;'));
},
homepageFilter: function(data) {
if (!data) {
return '';
}
if (!data.homepage || data.homepage === 'github.io') {
return '//polymer.github.io/' + data.name;
} else {
return data.homepage;
}
},
dataChanged: function() {
// Wrap in async() to delay execution until the next animation frame,
// since the <template> contents won't be stamped at the time this is executed.
this.async(function() {
var elementToFocus = this.shadowRoot.getElementById(window.location.hash.slice(1));
if (elementToFocus) {
elementToFocus.scrollIntoView();
}
});
}
});
</script>
</polymer-element>

View File

@@ -0,0 +1,27 @@
/*
* @license
* Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
:host {
display: block;
position: relative;
border-right: 1px solid silver;
}
core-header-panel {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
}
core-toolbar {
background-color: #eeeeee;
}

View File

@@ -0,0 +1,67 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<link rel="import" href="../../core-toolbar/core-toolbar.html">
<link rel="import" href="../../core-header-panel/core-header-panel.html">
<link rel="import" href="../../core-icon-button/core-icon-button.html">
<link rel="import" href="../../core-menu/core-menu.html">
<link rel="import" href="../../core-item/core-item.html">
<!--
@class core-doc-toc
-->
<polymer-element name="core-doc-toc" attributes="data selected">
<template>
<link rel="stylesheet" href="core-doc-toc.css">
<core-header-panel mode="waterfall">
<!-- <core-toolbar theme="core-light-theme">
<core-icon-button icon="menu"></core-icon-button>
<span core-flex>Topics</span>
<core-icon-button icon="search" on-tap="{{searchAction}}"></core-icon-button>
</core-toolbar>
<core-toolbar id="searchBar" style="background-color: #C2185B; position: absolute; top: 0; left: 0; right: 0; opacity: 0; display: none;" class="seamed" theme="core-dark-theme">
<core-icon-button icon="search"></core-icon-button>
<core-icon-button icon="close" on-tap="{{closeSearchAction}}"></core-icon-button>
</core-toolbar>-->
<core-menu selected="{{selected}}">
<template repeat="{{data}}">
<core-item><a href="#{{name}}">{{name}}</a></core-item>
</template>
</core-menu>
</core-header-panel>
</template>
<script>
Polymer('core-doc-toc', {
searchAction: function() {
this.$.searchBar.style.opacity = 1;
this.$.searchBar.style.display = '';
},
closeSearchAction: function() {
this.$.searchBar.style.opacity = 0;
this.$.searchBar.style.display = 'none';
}
});
</script>
</polymer-element>

View File

@@ -0,0 +1,22 @@
<!doctype html>
<!--
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
The complete set of authors may be found at http://polymer.github.io/AUTHORS
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
-->
<html>
<head>
<script src="../webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../core-component-page/core-component-page.html">
</head>
<body unresolved>
<core-component-page></core-component-page>
</body>
</html>