Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: check broken links in generated docs #416

Merged
merged 9 commits into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .cloud-repo-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
"requiresKeyFile": true,
"requiresProjectId": true,
"product": "pubsub",
"client_reference_url": "https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub",
"client_reference_url": "https://cloud.google.com/nodejs/docs/reference/pubsub/latest",
"release_quality": "beta",
"samples": [
{
"id": "subscriptions",
"name": "Subscriptions",
"file": "subscriptions.js",
"docs_link": "https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub/subscription",
"docs_link": "https://cloud.google.com/nodejs/docs/reference/pubsub/latest/Subscription",
"usage": "node subscriptions.js --help"
},
{
"id": "topics",
"name": "Topics",
"file": "topics.js",
"docs_link": "https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub/topic",
"docs_link": "https://cloud.google.com/nodejs/docs/reference/pubsub/latest/Topic",
"usage": "node topics.js --help"
}
]
Expand Down
2 changes: 1 addition & 1 deletion .jsdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
opts: {
readme: './README.md',
package: './package.json',
template: './node_modules/ink-docstrap/template',
template: './node_modules/jsdoc-baseline',
recurse: true,
verbose: true,
destination: './docs/'
Expand Down
8 changes: 8 additions & 0 deletions .kokoro/docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,11 @@ cd $(dirname $0)/..
npm install

npm run docs

# Check broken links
BIN=./node_modules/.bin

npm install broken-link-checker
npm install http-server
$BIN/http-server -p 8080 docs/ &
$BIN/blc -r http://localhost:8080
35 changes: 12 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,17 @@
// Imports the Google Cloud client library
const {PubSub} = require('@google-cloud/pubsub');

// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';

// Instantiates a client
const pubsubClient = new PubSub({
projectId: projectId,
});

// The name for the new topic
const topicName = 'my-new-topic';

// Creates the new topic
pubsubClient
.createTopic(topicName)
.then(results => {
const topic = results[0];
console.log(`Topic ${topic.name} created.`);
})
.catch(err => {
console.error('ERROR:', err);
});
async function quickstart(
projectId = 'your-project-id', // Your Google Cloud Platform project ID
topicName = 'my-topic' // Name for the new topic to create
) {
// Instantiates a client
const pubsub = new PubSub({projectId});

// Creates the new topic
const [topic] = await pubsub.createTopic(topicName);
console.log(`Topic ${topic.name} created.`);
}
```

## Samples
Expand Down Expand Up @@ -108,11 +98,10 @@ Google APIs Client Libraries, in [Client Libraries Explained][explained].

[explained]: https://cloud.google.com/apis/docs/client-libraries-explained

[client-docs]: https://googlecloudplatform.github.io/google-cloud-node/#/docs/pubsub/latest/pubsub
[client-docs]: https://cloud.google.com/nodejs/docs/reference/pubsub/latest
[product-docs]: https://cloud.google.com/pubsub/docs
[shell_img]: https://gstatic.com/cloudssh/images/open-btn.png
[projects]: https://console.cloud.google.com/project
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=pubsub.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"samples-test": "cd samples/ && npm link ../ && npm test && cd ../",
"test": "nyc mocha build/test",
"lint": "eslint '**/*.js' && gts check",
"predocs": "npm run compile",
"docs": "jsdoc -c .jsdoc.js",
"fix": "eslint --fix '**/*.js' && gts fix",
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
Expand Down Expand Up @@ -82,7 +83,7 @@
"eslint-plugin-node": "^8.0.0",
"eslint-plugin-prettier": "^3.0.0",
"gts": "^0.9.0",
"ink-docstrap": "^1.3.2",
"jsdoc-baseline": "git+https://github.com/hegemonic/jsdoc-baseline.git",
"intelli-espower-loader": "^1.0.1",
"jsdoc": "^3.5.5",
"mocha": "^5.0.0",
Expand Down
5 changes: 2 additions & 3 deletions src/iam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ export interface Policy {
* SLA or deprecation policy, and may be subject to backward-incompatible
* changes.*
*
* @constructor Iam
* @mixin
* @class
* @param {PubSub} pubsub PubSub Object.
* @param {string} id The name of the topic or subscription.
*
Expand Down Expand Up @@ -241,7 +240,7 @@ export class IAM {
*
* @throws {Error} If no policy is provided.
*
* @param {object} policy The [policy](https://cloud.google.com/pubsub/docs/reference/rest/Shared.Types/Policy).
* @param {object} policy The [policy](https://cloud.google.com/pubsub/docs/reference/rest/v1/Policy).
* @param {array} [policy.bindings] Bindings associate members with roles.
* @param {Array<object>} [policy.rules] Rules to be applied to the policy.
* @param {string} [policy.etag] Etags are used to perform a read-modify-write.
Expand Down
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
* limitations under the License.
*/

/**
* @namespace google.pubsub.v1
*/
/**
* @namespace google.protobuf
*/

import {paginator} from '@google-cloud/paginator';
import {replaceProjectIdToken} from '@google-cloud/projectify';
import {promisifyAll} from '@google-cloud/promisify';
Expand All @@ -35,7 +42,8 @@ const opts = {} as gax.GrpcClientOptions;
const {grpc} = new gax.GrpcClient(opts);

/**
* @type {string} - Project ID placeholder.
* Project ID placeholder.
* @type {string}
* @private
*/
const PROJECT_ID_PLACEHOLDER = '{{projectId}}';
Expand Down
7 changes: 7 additions & 0 deletions src/lease-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ export class LeaseManager extends EventEmitter {
}
/**
* @type {number}
* @private
*/
get pending(): number {
return this._pending.length;
}
/**
* @type {number}
* @private
*/
get size(): number {
return this._messages.size;
Expand All @@ -91,6 +93,7 @@ export class LeaseManager extends EventEmitter {
* isn't already running.
*
* @param {Message} message The message.
* @private
*/
add(message: Message): void {
const {allowExcessMessages} = this._options;
Expand All @@ -116,6 +119,7 @@ export class LeaseManager extends EventEmitter {
}
/**
* Removes ALL messages from inventory.
* @private
*/
clear(): void {
const wasFull = this.isFull();
Expand All @@ -134,6 +138,7 @@ export class LeaseManager extends EventEmitter {
* Indicates if we're at or over capacity.
*
* @returns {boolean}
* @private
*/
isFull(): boolean {
const {maxBytes, maxMessages} = this._options;
Expand All @@ -146,6 +151,7 @@ export class LeaseManager extends EventEmitter {
* @fires LeaseManager#free
*
* @param {Message} message The message to remove.
* @private
*/
remove(message: Message): void {
if (!this._messages.has(message)) {
Expand Down Expand Up @@ -174,6 +180,7 @@ export class LeaseManager extends EventEmitter {
* Sets options for the LeaseManager.
*
* @param {FlowControlOptions} [options] The options.
* @private
*/
setOptions(options: FlowControlOptions): void {
const defaults: FlowControlOptions = {
Expand Down
5 changes: 5 additions & 0 deletions src/message-queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export abstract class MessageQueue {
* Gets the default buffer time in ms.
*
* @returns {number}
* @private
*/
get maxMilliseconds(): number {
return this._options!.maxMilliseconds!;
Expand All @@ -74,6 +75,7 @@ export abstract class MessageQueue {
*
* @param {Message} message The message to add.
* @param {number} [deadline] The deadline.
* @private
*/
add({ackId}: Message, deadline?: number): void {
const {maxMessages, maxMilliseconds} = this._options;
Expand All @@ -89,6 +91,7 @@ export abstract class MessageQueue {
}
/**
* Sends a batch of messages.
* @private
*/
async flush(): Promise<void> {
if (this._timer) {
Expand Down Expand Up @@ -118,6 +121,7 @@ export abstract class MessageQueue {
* Returns a promise that resolves after the next flush occurs.
*
* @returns {Promise}
* @private
*/
onFlush(): Promise<void> {
if (!this._onFlush) {
Expand All @@ -129,6 +133,7 @@ export abstract class MessageQueue {
* Set the batching options.
*
* @param {BatchOptions} options Batching options.
* @private
*/
setOptions(options): void {
const defaults: BatchOptions = {maxMessages: 3000, maxMilliseconds: 100};
Expand Down
1 change: 1 addition & 0 deletions src/message-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export class MessageStream extends PassThrough {
* Destroys the stream and any underlying streams.
*
* @param {error?} err An error to emit, if any.
* @private
*/
destroy(err?: Error): void {
if (this.destroyed) {
Expand Down
2 changes: 1 addition & 1 deletion src/publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class Publisher {
* The topic of this publisher.
*
* @name Publisher#topic
* @type {Topic} topic
* @type {Topic}
*/
this.topic = topic;
// this object keeps track of all messages scheduled to be published
Expand Down
13 changes: 13 additions & 0 deletions src/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ export class Message {
* The length of the message data.
*
* @type {number}
* @private
*/
get length() {
return this._length;
}
/**
* Acknowledges the message.
* @private
*/
ack(): void {
if (!this._handled) {
Expand All @@ -98,6 +100,7 @@ export class Message {
* Modifies the ack deadline.
*
* @param {number} deadline The number of seconds to extend the deadline.
* @private
*/
modAck(deadline: number): void {
if (!this._handled) {
Expand All @@ -110,6 +113,7 @@ export class Message {
*
* @param {number} [delay=0] The desired time to wait before the
* redelivery occurs.
* @private
*/
nack(delay?: number): void {
if (!this._handled) {
Expand Down Expand Up @@ -186,6 +190,7 @@ export class Subscriber extends EventEmitter {
* The 99th percentile of request latencies.
*
* @type {number}
* @private
*/
get modAckLatency() {
const latency = this._latencies.percentile(99);
Expand All @@ -201,6 +206,7 @@ export class Subscriber extends EventEmitter {
* The full name of the Subscription.
*
* @type {string}
* @private
*/
get name(): string {
if (!this._name) {
Expand All @@ -215,6 +221,7 @@ export class Subscriber extends EventEmitter {
*
* @param {Message} message The message to acknowledge.
* @returns {Promise}
* @private
*/
async ack(message: Message): Promise<void> {
if (!this._isUserSetDeadline) {
Expand All @@ -232,6 +239,7 @@ export class Subscriber extends EventEmitter {
* acks/modAcks are finished.
*
* @returns {Promise}
* @private
*/
async close(): Promise<void> {
if (!this.isOpen) {
Expand All @@ -248,6 +256,7 @@ export class Subscriber extends EventEmitter {
* Gets the subscriber client instance.
*
* @returns {Promise<object>}
* @private
*/
async getClient(): Promise<ClientStub> {
const pubsub = this._subscription.pubsub;
Expand All @@ -263,6 +272,7 @@ export class Subscriber extends EventEmitter {
* @param {Message} message The message to modify.
* @param {number} deadline The deadline.
* @returns {Promise}
* @private
*/
async modAck(message: Message, deadline: number): Promise<void> {
const startTime = Date.now();
Expand All @@ -280,13 +290,15 @@ export class Subscriber extends EventEmitter {
* @param {Message} message The message.
* @param {number} [delay=0] Delay to wait before redelivery.
* @return {Promise}
* @private
*/
async nack(message: Message, delay = 0): Promise<void> {
await this.modAck(message, delay);
this._inventory.remove(message);
}
/**
* Starts pulling messages.
* @private
*/
open(): void {
const {batching, flowControl, streamingOptions} = this._options;
Expand All @@ -308,6 +320,7 @@ export class Subscriber extends EventEmitter {
* Sets subscriber options.
*
* @param {SubscriberOptions} options The options.
* @private
*/
setOptions(options: SubscriberOptions): void {
this._options = options;
Expand Down
6 changes: 2 additions & 4 deletions src/v1/doc/google/protobuf/doc_timestamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@
* 01:30 UTC on January 15, 2017.
*
* In JavaScript, one can convert a Date object to this format using the
* standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString]
* standard [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)
* method. In Python, a standard `datetime.datetime` object can be converted
* to this format using [`strftime`](https://docs.python.org/2/library/time.html#time.strftime)
* with the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one
* can use the Joda Time's [`ISODateTimeFormat.dateTime()`](https://cloud.google.com
* http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--
* ) to obtain a formatter capable of generating timestamps in this format.
* can use the Joda Time's [`ISODateTimeFormat.dateTime()`](https://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime--) to obtain a formatter capable of generating timestamps in this format.
*
* @property {number} seconds
* Represents seconds of UTC time since Unix epoch
Expand Down
Loading