Skip to content

Commit

Permalink
Merge pull request #532 from jgeewax/view-code-directive
Browse files Browse the repository at this point in the history
Moved docs link to an Angular directive.
  • Loading branch information
ryanseys committed May 6, 2015
2 parents e45ddd7 + bb61f14 commit e9c7fa2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
14 changes: 14 additions & 0 deletions docs/site/components/docs/docs-directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,18 @@ angular.module('gcloud.docs')
}, true);
}
};
})

.directive('docsCodeLink', function($compile) {
'use strict';

var GITHUB_BASE = 'https://github.com/GoogleCloudPlatform/gcloud-node/blob/';

return {
template: '<a href="' + GITHUB_BASE + '{{version}}/lib/' +
'{{module ? module + \'/\' : \'\'}}{{class}}.js' +
'{{method.lineNumLink}}">' +
'(code on GitHub)' +
'</a>'
};
});
4 changes: 2 additions & 2 deletions docs/site/components/docs/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ <h4>ACLs</h4>
ng-hide="singleMethod && method.name !== singleMethod">
<h2 ng-if="method.name[0].toUpperCase() === method.name[0]">
{{method.name}}
<span class="view-code-link" docs-code-link></span>
</h2>
<h3
class="method-heading"
Expand All @@ -128,6 +129,7 @@ <h2 ng-if="method.name[0].toUpperCase() === method.name[0]">
class="permalink"
ng-href="{{activeUrl + '?method=' + method.name}}">#</a>
{{method.name}}
<span class="view-code-link" docs-code-link></span>
</h3>
<p ng-if="method.description" ng-bind-html="method.description"></p>
<h4 ng-show="method.params">Parameters</h4>
Expand All @@ -147,8 +149,6 @@ <h4 ng-show="method.returns">Returns</h4>
<h4 ng-show="method.example">Example</h4>
<div docs-example ng-repeat-end
ng-show="method.example" ng-bind-html="method.example"></div>
<div class="view-code-link">View the code
<a href="https://github.com/GoogleCloudPlatform/gcloud-node/blob/{{version}}/lib/{{module ? module + '/' : ''}}{{class}}.js{{method.lineNumLink}}">on GitHub</a>.</div>
<hr ng-if="$index < methods.length - 1">
</article>
</article>
Expand Down
3 changes: 2 additions & 1 deletion docs/site/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,8 @@ ul {
background: #F8F8F8;
}

.view-code-link {
.view-code-link > a {
font-size: 80%;
color: #888;
}

Expand Down

0 comments on commit e9c7fa2

Please sign in to comment.