Skip to content

Commit

Permalink
Add custom helpers, obsolete tag support
Browse files Browse the repository at this point in the history
  • Loading branch information
kamranayub committed Jun 8, 2016
1 parent fcca68f commit 8c824b8
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 4 deletions.
2 changes: 1 addition & 1 deletion gruntfile.js
Expand Up @@ -95,7 +95,7 @@ module.exports = function(grunt)
files: [{
expand: true,
cwd: 'src/default',
src: ['**/*.hbs', '**/*.png'],
src: ['**/*.hbs', '**/*.js', '**/*.png'],
dest: 'bin/default'
}]
},
Expand Down
26 changes: 26 additions & 0 deletions src/default/assets/css/elements/_obsolete.sass
@@ -0,0 +1,26 @@
// Displays obsolete notification in tags
//
// <dl class="tsd-comment-tags">
// <dt class="ts-flagObsolete">see</dt>
// <dd class="ts-flagObsolete"><p><a href="#">Dispatcher.EVENT_BEGIN</a></p></dd>
// </dl>
//
dl.tsd-comment-tags

.ts-flagObsolete
border-top: 1px solid #D01717
border-bottom: 1px solid #D01717
border-right: 1px solid #D01717
padding: 5px
margin-bottom: 10px

dd.ts-flagObsolete
color: #D01717

dt.ts-flagObsolete
background-color: #D01717
color: white
border-radius: 0

.tsd-flag.ts-flagObsolete
background-color: #D01717
1 change: 1 addition & 0 deletions src/default/assets/css/main.sass
Expand Up @@ -13,6 +13,7 @@
@import layouts/minimal

@import elements/comment
@import elements/obsolete
@import elements/filter
@import elements/footer
@import elements/hierarchy
Expand Down
28 changes: 28 additions & 0 deletions src/default/helpers/custom.js
@@ -0,0 +1,28 @@
var helpers = {
containsTag: function ( value, declaration, options ) {
// fallback...
var array = [];
if(declaration && declaration.signatures){
declaration.signatures.forEach(function(s){
if(s.comment && s.comment.tags){
array = array.concat(s.comment.tags);
}
});

//if(array) console.log("contains", value, array);
}

array = array.map(function(t){
if (t) {
return t.tagName;
}
return false;
});
return (array.indexOf(value) > -1) ? options.fn( this ) : "";
},

ifEquals: function ( value1, value2, options ) {
return value1 === value2 ? options.fn(this) : "";
}
};
module.exports = helpers;
4 changes: 2 additions & 2 deletions src/default/partials/comment.hbs
Expand Up @@ -12,8 +12,8 @@
{{#if tags}}
<dl class="tsd-comment-tags">
{{#each tags}}
<dt>{{tagName}}</dt>
<dd>{{#markdown}}{{{text}}}{{/markdown}}</dd>
<dt {{#ifEquals "obsolete" tagName}}class="ts-flagObsolete"{{/ifEquals}}>{{tagName}}</dt>
<dd {{#ifEquals "obsolete" tagName}}class="ts-flagObsolete"{{/ifEquals}}>{{#markdown}}{{{text}}}{{/markdown}}</dd>
{{/each}}
</dl>
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion src/default/partials/member.hbs
@@ -1,7 +1,7 @@
<section class="tsd-panel tsd-member {{cssClasses}}">
<a name="{{anchor}}" class="tsd-anchor"></a>
{{#if name}}
<h3>{{#each flags}}<span class="tsd-flag ts-flag{{this}}">{{this}}</span> {{/each}}{{{wbr name}}}</h3>
<h3>{{#containsTag "obsolete" this}}<span class="tsd-flag ts-flagObsolete">Obsolete</span>{{/containsTag}} {{#each flags}}<span class="tsd-flag ts-flag{{this}}">{{this}}</span> {{/each}}{{{wbr name}}}</h3>
{{/if}}

{{#if signatures}}
Expand Down

0 comments on commit 8c824b8

Please sign in to comment.