Skip to content

Commit

Permalink
Always show static methods when present. (#170)
Browse files Browse the repository at this point in the history
Fixes #169
  • Loading branch information
aomarks authored Jan 3, 2018
1 parent 17a2a1a commit 1ba899a
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 4 deletions.
18 changes: 15 additions & 3 deletions iron-doc-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ <h2>
</template>
</section>

<section anchor-id$="[[fragmentPrefix]]methods"
hidden$="[[!_anyVisible(descriptor.methods)]]">
<section id="methods"
anchor-id$="[[fragmentPrefix]]methods"
hidden$="[[!_hasMethods]]">
<h2>
<a href$="#[[fragmentPrefix]]methods" class="deeplink">Methods</a>
</h2>
Expand Down Expand Up @@ -151,13 +152,19 @@ <h2>
behaviors: [Polymer.IronDocViewerBehavior],

properties: {
descriptor: Object,

_showProtectedProperties: Boolean,
_showProtectedMethods: Boolean,
_showProtectedEvents: Boolean,

_staticMethods: {
computed: '_computeStaticMethods(descriptor)'
}
},

_hasMethods: {
computed: '_computeHasMethods(descriptor)'
},
},

_anyVisible: function(items) {
Expand Down Expand Up @@ -203,6 +210,11 @@ <h2>
_computeStaticMethods: function(descriptor) {
return descriptor.staticMethods || [];
},

_computeHasMethods: function(descriptor) {
return (descriptor.methods && descriptor.methods.length > 0) ||
(descriptor.staticMethods && descriptor.staticMethods.length > 0);
},
});
})();
</script>
Expand Down
5 changes: 4 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@
'iron-doc-viewer.html?wc-shadydom=true&wc-ce=true',

'iron-doc-nav.html?dom=shadow',
'iron-doc-nav.html?wc-shadydom=true&wc-ce=true'
'iron-doc-nav.html?wc-shadydom=true&wc-ce=true',

'iron-doc-api.html?dom=shadow',
'iron-doc-api.html?wc-shadydom=true&wc-ce=true'
]);
</script>
</body>
Expand Down
62 changes: 62 additions & 0 deletions test/iron-doc-api.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!doctype html>
<!--
@license
Copyright (c) 2018 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
-->
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
<title>iron-doc-api tests</title>

<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>

<link rel="import" href="../../polymer/polymer.html">
<link rel="import" href="../../test-fixture/test-fixture.html">

<link rel="import" href="../iron-doc-api.html">
</head>
<body>

<test-fixture id="iron-doc-api-fixture">
<template>
<iron-doc-api></iron-doc-api>
</template>
</test-fixture>

<script>
describe('<iron-doc-api>', function() {
var api;
beforeEach(function() {
api = fixture('iron-doc-api-fixture');
});

it('shows static methods even when no regular methods', function() {
api.descriptor = {
"staticMethods": [
{
"name": "foo"
},
{
"name": "bar"
}
]
};
Polymer.dom.flush();
expect(api.$$('#methods').hidden).to.be.false;
var methods =
Polymer.dom(api.root).querySelectorAll('iron-doc-function');
expect(methods.length).equals(2);
});
});
</script>

</body>
</html>

0 comments on commit 1ba899a

Please sign in to comment.