]> source.dussan.org Git - vaadin-core.git/commitdiff
Adding apidoc component
authorManolo Carrasco <manolo@apache.org>
Mon, 14 Sep 2015 16:59:00 +0000 (18:59 +0200)
committerManolo Carrasco <manolo@apache.org>
Mon, 14 Sep 2015 16:59:00 +0000 (18:59 +0200)
apidoc/index.html [new file with mode: 0644]
bower.json
tasks/cdn.js

diff --git a/apidoc/index.html b/apidoc/index.html
new file mode 100644 (file)
index 0000000..a5a0f70
--- /dev/null
@@ -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>
index 34708e902e80a239d7dd22c2f8044314d43ff9ee..f4b07a058ba928608c2268ca6ebc819b01e3a374 100644 (file)
   "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"
   }
index e5aaeed12e744d8092868fd0536a94500699ccb7..badaff0436efc65659ef11cd2b46b320352df055 100644 (file)
@@ -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']);