diff --git a/packages/bigtable/src/instance.js b/packages/bigtable/src/instance.js index bedfe0877f8..bc5c2d8f1ab 100644 --- a/packages/bigtable/src/instance.js +++ b/packages/bigtable/src/instance.js @@ -87,7 +87,7 @@ function Instance(bigtable, name) { * instance.create().then(function(data) { * var instance = data[0]; * var operation = data[1]; - * var apiResponse = data[2] + * var apiResponse = data[2]; * }); */ create: true, diff --git a/packages/bigtable/src/row.js b/packages/bigtable/src/row.js index b431c794b2e..3de6da8124e 100644 --- a/packages/bigtable/src/row.js +++ b/packages/bigtable/src/row.js @@ -744,7 +744,7 @@ Row.prototype.getMetadata = function(options, callback) { * } * }; * - * row.increment('follows:gwashington', callback) + * row.increment('follows:gwashington', callback); * * //- * // Specify a custom amount to increment the column by. diff --git a/packages/bigtable/src/table.js b/packages/bigtable/src/table.js index c98800c5381..7cc541e5435 100644 --- a/packages/bigtable/src/table.js +++ b/packages/bigtable/src/table.js @@ -792,7 +792,7 @@ Table.prototype.insert = function(entries, callback) { * } * ]; * - * table.mutate(entries, callback) + * table.mutate(entries, callback); * * //- * // Delete entities. See {module:bigtable/row#deleteCells} diff --git a/packages/compute/src/instance-group.js b/packages/compute/src/instance-group.js index 4603db1accd..c582da69344 100644 --- a/packages/compute/src/instance-group.js +++ b/packages/compute/src/instance-group.js @@ -70,7 +70,7 @@ function InstanceGroup(zone, name) { * instanceGroup.create().then(function(data) { * var instanceGroup = data[0]; * var operation = data[1]; - * var apiResponse = data[2] + * var apiResponse = data[2]; * }); */ create: true, diff --git a/packages/datastore/src/request.js b/packages/datastore/src/request.js index 91465b2eaa2..8e707e4d128 100644 --- a/packages/datastore/src/request.js +++ b/packages/datastore/src/request.js @@ -750,7 +750,7 @@ DatastoreRequest.prototype.runQueryStream = function(query, options) { * name: 'DonutShack', * rating: 8 * } - * } + * }; * * datastore.save(entity, function(err) { * console.log(key.path); // ['Company', 'donutshack'] diff --git a/scripts/docs/builder.js b/scripts/docs/builder.js index 5526f2c160d..5769aa35d4e 100644 --- a/scripts/docs/builder.js +++ b/scripts/docs/builder.js @@ -56,7 +56,7 @@ function Builder(name, version, cwd) { this.version = version || config.DEFAULT_VERSION; this.dir = path.join(cwd || '', DOCS_ROOT, name, this.version); this.isUmbrella = name === UMBRELLA_PACKAGE; - this.isMaster = this.version === config.DEFAULT_VERSION; + this.isRelease = !!semver.valid(this.version); } /** @@ -112,7 +112,7 @@ Builder.prototype.build = function() { * var tagName = builder.getTagName(); // bigtable-0.2.0 */ Builder.prototype.getTagName = function() { - if (this.isMaster) { + if (!semver.valid(this.version)) { return this.version; } @@ -233,7 +233,7 @@ function Bundler(builder) { * Bundler.updateDep(builder); */ Bundler.updateDep = function(builder) { - if (builder.isMaster) { + if (!builder.isRelease) { throw new Error('Must supply valid version to update bundles with.'); } @@ -252,7 +252,7 @@ Bundler.updateDep = function(builder) { bundleTag = bundler.builder.getTagName(); git.checkout(bundleTag); - dep = findWhere(bundler.getDeps(), { name: builder.name }); + dep = findWhere(bundler.getDeps(), { name: builder.name }) || {}; git.checkout('-'); if (semver.maxSatisfying(versions, dep.version) !== builder.version) { @@ -440,10 +440,13 @@ function build(name, version) { git.checkout(builder.getTagName()); builder.build(); git.checkout('-'); - builder.updateManifest(); - if (!builder.isUmbrella && !builder.isMaster) { - Bundler.updateDep(builder); + if (builder.isRelease) { + builder.updateManifest(); + + if (!builder.isUmbrella) { + Bundler.updateDep(builder); + } } } @@ -456,13 +459,14 @@ module.exports.build = build; * builder.buildAll(); */ function buildAll() { + var currentBranch = git.branch.current; var modules = globby.sync('*', { cwd: PACKAGES_ROOT, ignore: config.IGNORE }); modules.forEach(function(name) { - build(name, config.DEFAULT_VERSION); + build(name, currentBranch); }); } diff --git a/test/docs.js b/test/docs.js index db0949f06c2..a14b74ce586 100644 --- a/test/docs.js +++ b/test/docs.js @@ -20,6 +20,7 @@ var createErrorClass = require('create-error-class'); var format = require('string-format-obj'); var fs = require('fs'); var glob = require('glob'); +var jshint = require('jshint').JSHINT; var mitm = require('mitm'); var multiline = require('multiline'); var overviews = require('../scripts/docs/config').OVERVIEW; @@ -41,7 +42,19 @@ var DocsError = createErrorClass('DocsError', function(err, code) { }) .join('\n'); - this.message = '\n' + lines + '\n\n' + err.message; + this.message = format('\n{lines}\n\n{message}', { + lines: lines, + message: err.message + }); +}); + +var JSHintError = createErrorClass('JSHintError', function(err) { + this.message = format('"{evidence}" - {reason}', { + evidence: err.evidence.trim(), + reason: err.reason + }); + + this.code = err.code; }); var FakeConsole = Object.keys(console) @@ -144,6 +157,21 @@ modules.forEach(function(mod) { var snippet = createSnippet(mod, moduleInstantationCode, method); it('should run ' + name + ' examples without errors', function() { + jshint(snippet, { + // in several snippets we give an example as to how to access + // a property (like metadata) without doing anything with it + // e.g. `list[0].metadata` + expr: true, + + // this allows us to redefine variables, generally it's bad, buuut + // for copy/paste purposes this is desirable within the docs + shadow: true + }); + + if (jshint.errors.length) { + throw new JSHintError(jshint.errors[0]); + } + runCodeInSandbox(snippet, sandbox); }); }); @@ -153,7 +181,7 @@ modules.forEach(function(mod) { function getDocs(mod) { return glob - .sync('docs/json/' + mod + '/master/*.json', { + .sync('docs/json/' + mod + '/*/*.json', { ignore: [ '**/toc.json', '**/types.json'