Skip to content

Commit e9c7fa2

Browse files
committed
Merge pull request #532 from jgeewax/view-code-directive
Moved docs link to an Angular directive.
2 parents e45ddd7 + bb61f14 commit e9c7fa2

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

docs/site/components/docs/docs-directives.js

+14
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,18 @@ angular.module('gcloud.docs')
99
}, true);
1010
}
1111
};
12+
})
13+
14+
.directive('docsCodeLink', function($compile) {
15+
'use strict';
16+
17+
var GITHUB_BASE = 'https://github.com/GoogleCloudPlatform/gcloud-node/blob/';
18+
19+
return {
20+
template: '<a href="' + GITHUB_BASE + '{{version}}/lib/' +
21+
'{{module ? module + \'/\' : \'\'}}{{class}}.js' +
22+
'{{method.lineNumLink}}">' +
23+
'(code on GitHub)' +
24+
'</a>'
25+
};
1226
});

docs/site/components/docs/docs.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ <h4>ACLs</h4>
120120
ng-hide="singleMethod && method.name !== singleMethod">
121121
<h2 ng-if="method.name[0].toUpperCase() === method.name[0]">
122122
{{method.name}}
123+
<span class="view-code-link" docs-code-link></span>
123124
</h2>
124125
<h3
125126
class="method-heading"
@@ -128,6 +129,7 @@ <h2 ng-if="method.name[0].toUpperCase() === method.name[0]">
128129
class="permalink"
129130
ng-href="{{activeUrl + '?method=' + method.name}}">#</a>
130131
{{method.name}}
132+
<span class="view-code-link" docs-code-link></span>
131133
</h3>
132134
<p ng-if="method.description" ng-bind-html="method.description"></p>
133135
<h4 ng-show="method.params">Parameters</h4>
@@ -147,8 +149,6 @@ <h4 ng-show="method.returns">Returns</h4>
147149
<h4 ng-show="method.example">Example</h4>
148150
<div docs-example ng-repeat-end
149151
ng-show="method.example" ng-bind-html="method.example"></div>
150-
<div class="view-code-link">View the code
151-
<a href="https://github.com/GoogleCloudPlatform/gcloud-node/blob/{{version}}/lib/{{module ? module + '/' : ''}}{{class}}.js{{method.lineNumLink}}">on GitHub</a>.</div>
152152
<hr ng-if="$index < methods.length - 1">
153153
</article>
154154
</article>

docs/site/css/main.css

+2-1
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,8 @@ ul {
732732
background: #F8F8F8;
733733
}
734734

735-
.view-code-link {
735+
.view-code-link > a {
736+
font-size: 80%;
736737
color: #888;
737738
}
738739

0 commit comments

Comments
 (0)