diff options
author | Manolo Carrasco <manolo@apache.org> | 2015-09-14 18:59:00 +0200 |
---|---|---|
committer | Manolo Carrasco <manolo@apache.org> | 2015-09-14 18:59:00 +0200 |
commit | a0ec6e58b40bcb937a24f86c49405f9fb5f912dc (patch) | |
tree | e973d2cc9e843a440d8332e053b52b7788e738dc | |
parent | bb449f26f3619dee1e58a36986238e46f2c16de6 (diff) | |
download | vaadin-core-a0ec6e58b40bcb937a24f86c49405f9fb5f912dc.tar.gz vaadin-core-a0ec6e58b40bcb937a24f86c49405f9fb5f912dc.zip |
Adding apidoc component
-rw-r--r-- | apidoc/index.html | 122 | ||||
-rw-r--r-- | bower.json | 5 | ||||
-rw-r--r-- | tasks/cdn.js | 13 |
3 files changed, 135 insertions, 5 deletions
diff --git a/apidoc/index.html b/apidoc/index.html new file mode 100644 index 0000000..a5a0f70 --- /dev/null +++ b/apidoc/index.html @@ -0,0 +1,122 @@ +<!DOCTYPE html> +<html> +<head lang="en"> + <meta charset="UTF-8"> + <title></title> + + <script src="../../webcomponentsjs/webcomponents-lite.js"></script> + <script src="../../lodash/lodash.js"></script> + <link rel="import" href="../../polymer/polymer.html"> + <link rel="import" href="../../hydrolysis/hydrolysis-analyzer.html"> + <link rel="import" href="../../iron-doc-viewer/iron-doc-viewer.html"> +</head> +<body> + <div id="container" style="display:none"> + <div id="viewer" style="width: 60%;left: 20%; position: absolute;"> + <iron-doc-viewer></iron-doc-viewer> + </div> + </div> + <script> + window.addEventListener("WebComponentsReady", function() { + var hyd = require('hydrolysis'); + + function hidePrivateToggle() { + document.querySelector('#togglePrivate').setAttribute('style', 'display:none'); + } + + function hideCollapsedToggle() { + var collapsed = document.querySelector('#toggleCollapsed'); + if(collapsed) { + collapsed.setAttribute('style', 'display:none'); + } + } + + function getElementTag() { + var elementTag = window.location.search.replace('?', ''); + if(elementTag === '') { + elementTag = 'vaadin-grid'; + } + + return elementTag; + } + + function getPropertyType(type) { + return type.textContent.replace('Array.<', '').replace('>', ''); + } + + function createLinkElement(type) { + var a = document.createElement('a'); + a.textContent = type.textContent; + a.setAttribute('href', '?' + getPropertyType(type)); + + return a; + } + + function addLinkElementsForDocumentedTypes(result) { + var types = document.querySelectorAll('.type'); + + for(var i=0;i < types.length; i++) { + var type = getPropertyType(types[i]); + + if(result.elementsByTagName[type]) { + var a = createLinkElement(types[i]); + + types[i].textContent = ''; + types[i].appendChild(a); + } + } + + return result; + } + + function hidePropertySetterMethods() { + var propertyNames = _.map(document.querySelector('#properties').querySelectorAll('.name'), function(p) { + return p.textContent; + }); + + var methods = document.querySelector('#methods').querySelectorAll('iron-doc-property'); + + _.forEach(methods, function(m) { + if(_.contains(propertyNames, m.querySelector('.name').textContent)) { + m.setAttribute('style', 'display:none'); + } + }); + } + + function hideDefaultValuesForNonPrimitiveTypes(result) { + function isPrimitiveType(t) { + return /^([Nn]umber|[Bb]oolean|[Ss]tring).*/.test(t); + } + + _.forEach(document.querySelector('#properties').querySelectorAll('iron-doc-property'), function(p) { + if(!isPrimitiveType(p.querySelector('#type').textContent)) { + p.querySelector('#default').setAttribute('style', 'display:none'); + } + }); + + return result; + } + + function showDocViewer() { + document.querySelector('#container').setAttribute('style', 'display:block'); + } + + //*** Main script starts here. ***// + + hidePrivateToggle(); + hideCollapsedToggle(); + + hyd.Analyzer.analyze('../../vaadin-grid/vaadin-grid-doc.html') + .then(function(result) { + document.querySelector('iron-doc-viewer').descriptor = result.elementsByTagName[getElementTag()]; + + return result; + }) + .then(hideDefaultValuesForNonPrimitiveTypes) + .then(addLinkElementsForDocumentedTypes) + .then(hidePropertySetterMethods) + .then(showDocViewer); + }); +</script> +</body> +</html> @@ -20,6 +20,11 @@ "dependencies": { "vaadin-grid": "vaadin/vaadin-grid#master" }, + "devDependencies": { + "iron-doc-viewer": "polymerelements/iron-doc-viewer#~1.0.3", + "hydrolysis": "polymer/hydrolysis#~1.15.1", + "lodash": "~3.9.3" + }, "resolutions": { "polymer": "v1.1.1" } diff --git a/tasks/cdn.js b/tasks/cdn.js index e5aaeed..badaff0 100644 --- a/tasks/cdn.js +++ b/tasks/cdn.js @@ -28,15 +28,18 @@ gulp.task('cdn:stage-bower_components', function() { }); }); -gulp.task('cdn:stage-vaadin-components', ['clean:cdn'], function() { - return gulp.src(['README.md', 'LICENSE.md', 'vaadin-components.html']) +gulp.task('cdn:stage-markdown', function() { + return gulp.src(['README.md', 'LICENSE.md']) .pipe(markdown()) .pipe(gulp.dest(stagingPath + "/vaadin-components")); }); -gulp.task('stage:cdn', - ['cdn:stage-bower_components', - 'cdn:stage-vaadin-components']); +gulp.task('cdn:stage-vaadin-components', ['cdn:stage-markdown'], function() { + return gulp.src(['vaadin-components.html', 'demo/*', 'apidoc/*'], {base:"."}) + .pipe(gulp.dest(stagingPath + "/vaadin-components")); +}); + +gulp.task('stage:cdn', [ 'clean:cdn', 'cdn:stage-bower_components', 'cdn:stage-vaadin-components' ]); gulp.task('deploy:cdn', ['stage:cdn'], function() { common.checkArguments(['cdnUsername', 'cdnDestination']); |