Skip to content

Commit 12d018f

Browse files
committed
Merge pull request #229 from stephenplusplus/fix-docs
docs: fix examples, style optionals
2 parents fc15244 + 0311366 commit 12d018f

File tree

4 files changed

+48
-43
lines changed

4 files changed

+48
-43
lines changed

docs/components/docs/docs.html

+28-36
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ <h1 class="page-title">{{pageTitle}}</h1>
2222

2323
<section class="content">
2424
<article ng-show="showReference">
25-
<h1>{{module[0].toUpperCase() + module.substr(1)}}</h1>
26-
<h3 class="sub-heading">
27-
<div class="toggler" ng-click="showGcloudDocs = !showGcloudDocs">
28-
<span class="toggle" ng-hide="showGcloudDocs"></span>
29-
<span class="toggle" ng-show="showGcloudDocs"></span>
30-
</div>
31-
Getting Started with <code>gcloud</code>
32-
</h3>
25+
<h3 class="sub-heading">
26+
<div class="toggler" ng-click="showGcloudDocs = !showGcloudDocs">
27+
<span class="toggle" ng-hide="showGcloudDocs"></span>
28+
<span class="toggle" ng-show="showGcloudDocs"></span>
29+
</div>
30+
Getting Started with <code>gcloud</code>
31+
</h3>
3332
<article ng-if="showGcloudDocs">
34-
<h1>{{module[0].toUpperCase() + module.substr(1)}}</h1>
3533
<p>
3634
First, install <code>gcloud</code> with npm and require it into your project:
3735
</p>
@@ -59,40 +57,32 @@ <h1>{{module[0].toUpperCase() + module.substr(1)}}</h1>
5957
</p>
6058
</article>
6159
<hr>
60+
6261
<article ng-if="isActiveDoc('datastore')">
63-
<h2>Overview</h2>
62+
<h3>Datastore Overview</h3>
6463
<p>
6564
The <code>gcloud.datastore</code> object gives you some convenience methods, as well as exposes a <code>dataset</code> function. This will allow you to create a <code>dataset</code>, which is the object from which you will interact with the Google Cloud Datastore.
6665
</p>
6766
<div hljs>
68-
var datastore = gcloud.datastore;
69-
var dataset = datastore.dataset({
70-
projectId: 'myProject',
71-
keyFilename: '/path/to/keyfile.json'
72-
</div>
73-
<p ng-if="!isActiveUrl('/docs/datastore/dataset')">
74-
See <a href="#/docs/{{version}}/datastore/dataset">the Dataset documentation</a> for examples of how to query the datastore, save entities, run a transaction, and others.
75-
</p>
76-
</article>
77-
78-
<article ng-if="isActiveDoc('storage')">
79-
<p>
80-
The <code>gcloud.storage</code> object contains a <code>Bucket</code> object, which is how you will interact with your Google Cloud Storage bucket.
81-
</p>
82-
<div hljs>
83-
var storage = gcloud.storage;
84-
var bucket = new storage.Bucket({
85-
bucketName: 'MyBucket'
86-
});</div>
67+
var datastore = gcloud.datastore;
68+
var dataset = datastore.dataset({
69+
projectId: 'myProject',
70+
keyFilename: '/path/to/keyfile.json'
71+
});</div>
8772
<p ng-if="!isActiveUrl('/docs/datastore/dataset')">
88-
See <a href="#/docs/datastore/dataset">the Dataset documentation</a> for examples of how to query the datastore, save entities, run a transaction, and others.
73+
See <a href="#/docs/{{version}}/datastore/dataset">the Dataset documentation</a> for examples of how to query the datastore, save entities, run a transaction, and others.
8974
</p>
9075
</article>
76+
9177
<article ng-if="isActiveDoc('storage')">
92-
<h2>Overview</h2>
78+
<h3>Storage Overview</h3>
9379
<p>
9480
The <code>gcloud.storage</code> object contains a <code>bucket</code> object, which is how you will interact with your Google Cloud Storage bucket. See the guide on <a href="https://developers.google.com/storage">Google Cloud Storage</a> to create a bucket.
9581
</p>
82+
<div hljs>
83+
var bucket = gcloud.storage.bucket({
84+
bucketName: 'MyBucket'
85+
});</div>
9686
<p>
9787
See examples below for more on how to access your bucket to upload a file, read its files, create signed URLs, and more.
9888
</p>
@@ -117,10 +107,12 @@ <h2 ng-if="method.name[0].toUpperCase() === method.name[0]">
117107
<h4 ng-show="method.params">Parameters</h4>
118108
<table class="table" ng-show="method.params">
119109
<tbody>
120-
<tr ng-repeat="param in method.params">
110+
<tr
111+
ng-repeat="param in method.params"
112+
ng-class="{ 'param-optional': param.optional }">
121113
<th scope="row">{{param.name}}</th>
122-
<td ng-bind-html="param.types"></td>
123-
<td ng-bind-html="param.description"></td>
114+
<td class="param-types" ng-bind-html="param.types"></td>
115+
<td class="param-description" ng-bind-html="param.description"></td>
124116
</tr>
125117
</tbody>
126118
</table>
@@ -146,14 +138,14 @@ <h4 ng-show="method.example">Example</h4>
146138
<ul class="page-sections" ng-show="showReference">
147139
<li ng-repeat="page in pages">
148140
<a
149-
ng-class="{ current: docs.isActiveUrl(page.url) }"
141+
ng-class="{ current: isActiveUrl(page.url) }"
150142
ng-href="{{page.url}}">
151143
{{page.title}}
152144
</a>
153145
<ul class="sub-sections" ng-if="page.pages">
154146
<li ng-repeat="innerPage in page.pages">
155147
<a
156-
ng-class="{ current: docs.isActiveUrl(page.url + innerPage.url) }"
148+
ng-class="{ current: isActiveUrl(page.url + innerPage.url) }"
157149
ng-href="{{page.url + innerPage.url}}">
158150
{{innerPage.title}}
159151
</a>

docs/components/docs/docs.js

+9-6
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ angular
8080
formatHtml(tag.description.replace(/^- /, '')));
8181
tag.types = $sce.trustAsHtml(tag.types.reduceRight(
8282
reduceModules, []).join(', '));
83+
tag.optional = tag.types.toString().substr(-1) === '=';
8384
return tag;
8485
}),
8586
returns: obj.tags.filter(function(tag) {
@@ -197,15 +198,16 @@ angular
197198
}
198199
});
199200
})
201+
200202
.controller('DocsCtrl', function($location, $scope, $routeParams, methods, $http, versions) {
201203
'use strict';
202204

203205
$scope.isActiveUrl = function(url) {
204-
var current = $location.path().replace('/' + methods.singleMethod, '');
205-
var link = url
206-
.replace(/^#/, '')
207-
.replace('/' + methods.singleMethod, '');
208-
return current === link;
206+
var active = $location.path()
207+
.replace('/' + methods.singleMethod, '')
208+
.replace('/' + $scope.version, '');
209+
url = url.replace('#', '').replace('/' + $scope.version, '');
210+
return active === url;
209211
};
210212

211213
$scope.isActiveDoc = function(doc) {
@@ -252,7 +254,8 @@ angular
252254
}
253255
];
254256
})
255-
.controller("HistoryCtrl", function($scope, versions) {
257+
258+
.controller('HistoryCtrl', function($scope, versions) {
256259
$scope.pageTitle = 'Node.js Docs Versions';
257260
$scope.showHistory = true;
258261
$scope.versions = versions;

docs/components/docs/history.html

Whitespace-only changes.

docs/css/main.css

+11-1
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,16 @@ h2, h3 {
603603
border-bottom: 1px solid rgba(0,0,0,0.05);
604604
}
605605

606+
.param-optional .param-types {
607+
font-style: italic;
608+
}
609+
610+
.param-optional .param-description:before {
611+
content: "optional. ";
612+
color: #aaa;
613+
font-style: italic;
614+
}
615+
606616
.method-heading {
607617
position: relative;
608618
}
@@ -627,7 +637,7 @@ h2, h3 {
627637

628638
.sub-heading {
629639
color: #5d6061;
630-
margin: 0;
640+
margin: 0 !important;
631641
}
632642

633643
.toggler {

0 commit comments

Comments
 (0)