File tree Expand file tree Collapse file tree
docs/site/components/docs Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,16 +11,43 @@ angular.module('gcloud.docs')
1111 } ;
1212 } )
1313
14- . directive ( 'docsCodeLink' , function ( $compile ) {
14+ . directive ( 'docsCodeLink' , function ( ) {
1515 'use strict' ;
1616
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+ }
1827
1928 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+ }
2552 } ;
2653 } ) ;
You can’t perform that action at this time.
0 commit comments