File tree 1 file changed +34
-7
lines changed
docs/site/components/docs
1 file changed +34
-7
lines changed Original file line number Diff line number Diff line change @@ -11,16 +11,43 @@ angular.module('gcloud.docs')
11
11
} ;
12
12
} )
13
13
14
- . directive ( 'docsCodeLink' , function ( $compile ) {
14
+ . directive ( 'docsCodeLink' , function ( ) {
15
15
'use strict' ;
16
16
17
- var GITHUB_BASE = 'https://github.com/GoogleCloudPlatform/gcloud-node/blob/' ;
17
+ var GITHUB_BASE = 'https://github.com/GoogleCloudPlatform/gcloud-node/blob' ;
18
+
19
+ function getFilenameFromConstructor ( constructor ) {
20
+ switch ( constructor ) {
21
+ case 'DatastoreRequest' :
22
+ return 'request.js' ;
23
+ default :
24
+ return 'index.js' ;
25
+ }
26
+ }
18
27
19
28
return {
20
- template : '<a href="' + GITHUB_BASE + '{{version}}/lib/' +
21
- '{{module ? module + \'/\' : \'\'}}{{class}}.js' +
22
- '{{method.lineNumLink}}">' +
23
- '(code on GitHub)' +
24
- '</a>'
29
+ template : '<a href="{{link}}">(code on GitHub)</a>' ,
30
+
31
+ link : function ( $scope ) {
32
+ var method = $scope . method ;
33
+ var module = $scope . module ;
34
+ var version = $scope . version ;
35
+
36
+ var lineNumLink = method . lineNumLink ;
37
+ var fileName = $scope . class + '.js' ;
38
+
39
+ if ( method . data . ctx . hasOwnProperty ( 'constructor' ) ) {
40
+ fileName = getFilenameFromConstructor ( method . data . ctx . constructor ) ;
41
+ }
42
+
43
+ fileName = fileName . toLowerCase ( ) ;
44
+
45
+ $scope . link =
46
+ GITHUB_BASE +
47
+ '/' + version +
48
+ '/lib' +
49
+ ( module ? '/' + module : '' ) +
50
+ '/' + fileName + lineNumLink ;
51
+ }
25
52
} ;
26
53
} ) ;
You can’t perform that action at this time.
0 commit comments