Skip to content

Commit 905e1c0

Browse files
pubsub refactor
1 parent 4e6f384 commit 905e1c0

File tree

17 files changed

+3128
-626
lines changed

17 files changed

+3128
-626
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
angular.module('gcloud.docs')
2+
.factory('getLinks', function(pages, versions) {
3+
return function(version) {
4+
var baseUrl = '#/docs/' + version;
5+
var VERSIONS = pages.VERSIONS;
6+
if (!version || version === 'master') {
7+
var versions = Object.keys(VERSIONS);
8+
match = versions[versions.length - 1];
9+
} else {
10+
match = Object.keys(VERSIONS).filter(semver.satisfies.bind(null, version))[0];
11+
}
12+
return VERSIONS[match]
13+
.map(function(module) {
14+
if (pages[module]._url) {
15+
pages[module].url = pages[module]._url.replace('{baseUrl}', baseUrl);
16+
}
17+
return pages[module];
18+
});
19+
};
20+
});
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
pubsub: {
24+
title: 'PubSub',
25+
_url: '{baseUrl}/pubsub',
26+
pages: [
27+
{
28+
title: 'Topic',
29+
url: '/topic'
30+
},
31+
{
32+
title: 'Subscription',
33+
url: '/subscription'
34+
}
35+
]
36+
},
37+
38+
storage: {
39+
title: 'Storage',
40+
_url: '{baseUrl}/storage'
41+
},
42+
43+
VERSIONS: {
44+
// Give a version with/without a comparator, anything semver:
45+
// https://github.com/npm/node-semver#versions
46+
// List should be in ascending order.
47+
'<=0.7.1': ['gcloud', 'datastore', 'storage'],
48+
'>0.7.1': ['gcloud', 'datastore', 'pubsub', 'storage']
49+
}
50+
});

docs/components/docs/docs.html

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,21 @@ <h3>Datastore Overview</h3>
7373
</p>
7474
</article>
7575

76+
<article ng-if="isActiveDoc('pubsub')">
77+
<h3>Pub/Sub Overview</h3>
78+
<p>
79+
The <code>gcloud.pubsub</code> method will return a <code>pubsub</code> object, allowing you to create topics, publish messages, subscribe to topics, and more. See the <a href="https://developers.google.com/pubsub/overview">Google Cloud Pub/Sub overview</a> for more information.
80+
</p>
81+
<div hljs>
82+
var pubsub = gcloud.pubsub({
83+
projectId: 'myProject',
84+
keyFilename: '/path/to/keyfile.json'
85+
});</div>
86+
<p>
87+
See the examples below, which demonstrate everything from creating a topic to subscribing to messages on a topic.
88+
</p>
89+
</article>
90+
7691
<article ng-if="isActiveDoc('storage')">
7792
<h3>Storage Overview</h3>
7893
<p>
@@ -98,8 +113,7 @@ <h2 ng-if="method.name[0].toUpperCase() === method.name[0]">
98113
ng-if="method.name[0].toUpperCase() !== method.name[0]">
99114
<a
100115
class="permalink"
101-
ng-if="!noPermalink"
102-
ng-href="{{activeUrl + '/' + method.name}}">#</a>
116+
ng-href="{{activeUrl + '?method=' + method.name}}">#</a>
103117
{{method.name}}
104118
</h3>
105119
<p ng-if="method.description" ng-bind-html="method.description"></p>
@@ -118,9 +132,8 @@ <h4 ng-show="method.params">Parameters</h4>
118132
<h4 ng-show="method.returns">Returns</h4>
119133
<p ng-show="method.returns" ng-bind-html="method.returns"></p>
120134
<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>
135+
<div docs-example ng-repeat-end
136+
ng-show="method.example" ng-bind-html="method.example"></div>
124137
<hr ng-if="$index < methods.length - 1">
125138
</article>
126139
</article>
@@ -135,7 +148,7 @@ <h4 ng-show="method.example">Example</h4>
135148

136149
<nav class="side-nav">
137150
<ul class="page-sections" ng-show="showReference">
138-
<li ng-repeat="page in pages">
151+
<li ng-repeat="page in links">
139152
<a
140153
ng-class="{ current: isActiveUrl(page.url) }"
141154
ng-href="{{page.url}}">

0 commit comments

Comments
 (0)