Skip to content

Commit 2423211

Browse files
ryanseysstephenplusplus
authored andcommitted
Refactor Transaction and Dataset
1 parent bee6ed1 commit 2423211

File tree

13 files changed

+1875
-684
lines changed

13 files changed

+1875
-684
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
angular.module('gcloud.docs')
2+
.directive('docsExample', function($compile) {
3+
'use strict';
4+
5+
return {
6+
link: function(scope, element, attr) {
7+
scope.$watch(attr.ngBindHtml, function() {
8+
$compile(element.contents())(scope);
9+
}, true);
10+
}
11+
};
12+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
angular.module('gcloud.docs')
2+
.factory('getLinks', function(pages) {
3+
'use strict';
4+
5+
return function(version) {
6+
var baseUrl = '#/docs/' + version;
7+
var VERSIONS = pages.VERSIONS;
8+
var versions;
9+
var match;
10+
if (!version || version === 'master') {
11+
versions = Object.keys(VERSIONS);
12+
match = versions[versions.length - 1];
13+
} else {
14+
match = Object.keys(VERSIONS).filter(semver.satisfies.bind(null, version))[0];
15+
}
16+
return VERSIONS[match]
17+
.map(function(module) {
18+
if (pages[module]._url) {
19+
pages[module].url = pages[module]._url.replace('{baseUrl}', baseUrl);
20+
}
21+
return pages[module];
22+
});
23+
};
24+
});
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
angular.module('gcloud.docs')
2+
.value('pages', {
3+
gcloud: {
4+
title: 'gcloud',
5+
_url: '{baseUrl}'
6+
},
7+
8+
datastore: {
9+
title: 'Datastore',
10+
_url: '{baseUrl}/datastore',
11+
pages: [
12+
{
13+
title: 'Dataset',
14+
url: '/dataset'
15+
},
16+
{
17+
title: 'Query',
18+
url: '/query'
19+
}
20+
]
21+
},
22+
23+
datastoreWithTransaction: {
24+
title: 'Datastore',
25+
_url: '{baseUrl}/datastore',
26+
pages: [
27+
{
28+
title: 'Dataset',
29+
url: '/dataset'
30+
},
31+
{
32+
title: 'Transaction',
33+
url: '/transaction'
34+
},
35+
{
36+
title: 'Query',
37+
url: '/query'
38+
}
39+
]
40+
},
41+
42+
storage: {
43+
title: 'Storage',
44+
_url: '{baseUrl}/storage'
45+
},
46+
47+
VERSIONS: {
48+
// Give a version with/without a comparator, anything semver:
49+
// https://github.com/npm/node-semver#versions
50+
// List should be in ascending order.
51+
'<=0.7.1': ['gcloud', 'datastore', 'storage'],
52+
'>0.7.1': ['gcloud', 'datastoreWithTransaction', 'storage']
53+
}
54+
});

docs/components/docs/docs.html

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ <h3 class="sub-heading">
4545
However, if you're running your app elsewhere, you will need to provide this information.
4646
</p>
4747
<div hljs>
48-
// App Engine and Compute Engine
49-
var gcloud = require('gcloud');
48+
// App Engine and Compute Engine
49+
var gcloud = require('gcloud');
5050

51-
// Elsewhere
52-
var gcloud = require('gcloud')({
53-
keyFilename: '/path/to/keyfile.json'
54-
});</div>
51+
// Elsewhere
52+
var gcloud = require('gcloud')({
53+
keyFilename: '/path/to/keyfile.json'
54+
});</div>
5555
<p>
5656
In any environment, you are free to provide these and other default properties, which eventually will be passed to the <code>gcloud</code> sub-modules (Datastore, Storage, etc.).
5757
</p>
@@ -98,8 +98,7 @@ <h2 ng-if="method.name[0].toUpperCase() === method.name[0]">
9898
ng-if="method.name[0].toUpperCase() !== method.name[0]">
9999
<a
100100
class="permalink"
101-
ng-if="!noPermalink"
102-
ng-href="{{activeUrl + '/' + method.name}}">#</a>
101+
ng-href="{{activeUrl + '?method=' + method.name}}">#</a>
103102
{{method.name}}
104103
</h3>
105104
<p ng-if="method.description" ng-bind-html="method.description"></p>
@@ -118,9 +117,8 @@ <h4 ng-show="method.params">Parameters</h4>
118117
<h4 ng-show="method.returns">Returns</h4>
119118
<p ng-show="method.returns" ng-bind-html="method.returns"></p>
120119
<h4 ng-show="method.example">Example</h4>
121-
<div ng-repeat-end
122-
ng-show="method.example"
123-
hljs source="method.example" language="js"></div>
120+
<div docs-example ng-repeat-end
121+
ng-show="method.example" ng-bind-html="method.example"></div>
124122
<hr ng-if="$index < methods.length - 1">
125123
</article>
126124
</article>
@@ -135,7 +133,7 @@ <h4 ng-show="method.example">Example</h4>
135133

136134
<nav class="side-nav">
137135
<ul class="page-sections" ng-show="showReference">
138-
<li ng-repeat="page in pages">
136+
<li ng-repeat="page in links">
139137
<a
140138
ng-class="{ current: isActiveUrl(page.url) }"
141139
ng-href="{{page.url}}">

0 commit comments

Comments
 (0)