Skip to content

Commit

Permalink
build: check broken links in generated docs (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkwlui authored and JustinBeckwith committed Jan 15, 2019
1 parent f839e58 commit 70ea500
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .jsdoc.js
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
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
121 changes: 51 additions & 70 deletions README.md
Expand Up @@ -8,97 +8,65 @@
[![npm version](https://img.shields.io/npm/v/@google-cloud/datastore.svg)](https://www.npmjs.org/package/@google-cloud/datastore)
[![codecov](https://img.shields.io/codecov/c/github/googleapis/nodejs-datastore/master.svg?style=flat)](https://codecov.io/gh/googleapis/nodejs-datastore)

> Node.js idiomatic client for [Cloud Datastore][product-docs].
[Cloud Datastore](https://cloud.google.com/datastore/docs) is a NoSQL document database built for automatic scaling, high performance, and ease of application development. While the Cloud Datastore interface has many of the same features as traditional databases, as a NoSQL database it differs from them in the way it describes relationships between data objects.


* [Cloud Datastore Node.js Client API Reference][client-docs]
* [github.com/googleapis/nodejs-datastore](https://github.com/googleapis/nodejs-datastore)
* [Cloud Datastore Documentation][product-docs]

Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in [Client Libraries Explained][explained].

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

**Table of contents:**

* [Quickstart](#quickstart)
* [Before you begin](#before-you-begin)
* [Installing the client library](#installing-the-client-library)
* [Using the client library](#using-the-client-library)
* [Using the client library](#using-the-client-library)
* [Samples](#samples)
* [Versioning](#versioning)
* [Contributing](#contributing)
* [License](#license)

## Quickstart

### Before you begin

1. Select or create a Cloud Platform project.

[Go to the projects page][projects]

1. Enable billing for your project.
## Using the client library

[Enable billing][billing]
1. [Select or create a Cloud Platform project][projects].

1. Enable the Google Cloud Datastore API.
1. [Enable billing for your project][billing].

[Enable the API][enable_api]
1. [Enable the Google Cloud Datastore API][enable_api].

1. [Set up authentication with a service account][auth] so you can access the
API from your local workstation.

[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=datastore.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started
1. Install the client library:

### Installing the client library
npm install --save @google-cloud/datastore

npm install --save @google-cloud/datastore

### Using the client library
1. Try an example:

```javascript
// Imports the Google Cloud client library
const {Datastore} = require('@google-cloud/datastore');

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

// Creates a client
const datastore = new Datastore({
projectId: projectId,
});

// The kind for the new entity
const kind = 'Task';
// The name/ID for the new entity
const name = 'sampletask1';
// The Cloud Datastore key for the new entity
const taskKey = datastore.key([kind, name]);

// Prepares the new entity
const task = {
key: taskKey,
data: {
description: 'Buy milk',
},
};

// Saves the entity
datastore
.save(task)
.then(() => {
console.log(`Saved ${task.key.name}: ${task.data.description}`);
})
.catch(err => {
console.error('ERROR:', err);
async function quickStart() {
// Your Google Cloud Platform project ID
const projectId = 'YOUR_PROJECT_ID';

// Creates a client
const datastore = new Datastore({
projectId: projectId,
});

// The kind for the new entity
const kind = 'Task';
// The name/ID for the new entity
const name = 'sampletask1';
// The Cloud Datastore key for the new entity
const taskKey = datastore.key([kind, name]);

// Prepares the new entity
const task = {
key: taskKey,
data: {
description: 'Buy milk',
},
};

// Saves the entity
await datastore.save(task);
console.log(`Saved ${task.key.name}: ${task.data.description}`);
}
quickStart().catch(console.error);
```

## Samples
Expand All @@ -110,7 +78,6 @@ has instructions for running the samples.
| --------------------------- | --------------------------------- | ------ |
| Tasks | [source code](https://github.com/googleapis/nodejs-datastore/blob/master/samples/tasks.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/tasks.js,samples/README.md) |
| Concepts | [source code](https://github.com/googleapis/nodejs-datastore/blob/master/samples/concepts.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/concepts.js,samples/README.md) |
| Errors and Error Handling | [source code](https://github.com/googleapis/nodejs-datastore/blob/master/samples/error.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-datastore&page=editor&open_in_editor=samples/error.js,samples/README.md) |

The [Cloud Datastore Node.js Client API Reference][client-docs] documentation
also contains samples.
Expand Down Expand Up @@ -139,7 +106,21 @@ Apache Version 2.0

See [LICENSE](https://github.com/googleapis/nodejs-datastore/blob/master/LICENSE)

## What's Next

* [Cloud Datastore Documentation][product-docs]
* [Cloud Datastore Node.js Client API Reference][client-docs]
* [github.com/googleapis/nodejs-datastore](https://github.com/googleapis/nodejs-datastore)

Read more about the client libraries for Cloud APIs, including the older
Google APIs Client Libraries, in [Client Libraries Explained][explained].

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

[client-docs]: https://cloud.google.com/nodejs/docs/reference/datastore/latest/
[product-docs]: https://cloud.google.com/datastore/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=datastore.googleapis.com
[auth]: https://cloud.google.com/docs/authentication/getting-started
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -72,7 +72,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.2.0",
Expand Down

0 comments on commit 70ea500

Please sign in to comment.