Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
rictic committed Apr 26, 2018
1 parent 5e625c8 commit e17f9dd
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"postinstall": "bower install; gulp",
"deploy": "scripts/deploy.sh",
"test": "(cd dist; python test_runner.py ${CLOUD_SDK-~/google-cloud-sdk} ../tests/)",
"generate-api-docs": "cd scripts && node generate_api_docs_2.js",
"generate-api-docs-2": "cd scripts && node generate_api_docs_2.js",
"generate-api-docs-1": "cd scripts && node generate_api_docs_1.js",
"generate-api-docs-3": "cd scripts && node generate_api_docs_3.js"
},
Expand Down
16 changes: 15 additions & 1 deletion scripts/gen_and_summarize.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/**
* @license
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/

// @ts-check

const {Analyzer, FsUrlLoader, PackageUrlResolver, generateAnalysis} =
Expand Down Expand Up @@ -27,7 +41,7 @@ async function main() {

if (require.main === module) {
main().catch((e) => {
console.error(e ? e.stack || e.message || e: `Unknown error`);
console.error(e ? (e.stack || e.message || e) : `Unknown error`);
process.exitCode = 1;
});
}
14 changes: 14 additions & 0 deletions scripts/generate_api_docs_1.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/

/**
* Run from `npm run generate-api-docs`
*/
Expand Down
14 changes: 14 additions & 0 deletions scripts/generate_api_docs_2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
/**
* @license
* Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/

/**
* Run from `npm run generate-api-docs`
*/

Expand Down
25 changes: 23 additions & 2 deletions scripts/generate_api_docs_3.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/**
* @license
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/

/**
* Run from `npm run generate-api-docs-3`
*
Expand Down Expand Up @@ -224,6 +238,8 @@ function getIndexPageSubsection(subsection, filenamesIn, featureIndex) {
`
}

// TODO: generate these from source. See tracking bug at
// https://github.com/Polymer/tools/issues/241
const hardcodedDescriptions = new Map([
['lib/elements/array-selector.js', `
Module providing tools for maintaining a mapping between a master
Expand Down Expand Up @@ -353,7 +369,12 @@ function getFilenameDescription(filename, featureIndex) {
const [feature] = features;
description = feature.summary;
}
description = description || hardcodedDescriptions.get(filename) || `TODO(write me): ${filename}`;
description = description || hardcodedDescriptions.get(filename);
if (!description) {
throw new Error(
`Unable to get a summary for ${filename}, may need to add it ` +
`to hardcodedDescriptions.`);
}

return `
<section>
Expand Down Expand Up @@ -495,7 +516,7 @@ function getFilename(feature) {

if (require.main === module) {
main().catch((e) => {
console.error(e ? e.stack || e.message || e: `Unknown error`);
console.error(e ? (e.stack || e.message || e) : `Unknown error`);
process.exitCode = 1;
});
}
22 changes: 20 additions & 2 deletions scripts/summarize-analysis.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/**
* @license
* Copyright (c) 2018 The Polymer Project Authors. All rights reserved.
* This code may only be used under the BSD style license found at
* http://polymer.github.io/LICENSE.txt
* The complete set of authors may be found at
* http://polymer.github.io/AUTHORS.txt
* The complete set of contributors may be found at
* http://polymer.github.io/CONTRIBUTORS.txt
* Code distributed by Google as part of the polymer project is also
* subject to an additional IP rights grant found at
* http://polymer.github.io/PATENTS.txt
*/

// @ts-check
const fs = require('fs');
const analyzer = require('polymer-analyzer');
Expand Down Expand Up @@ -32,7 +46,11 @@ function summarizeByFile(analysis) {
const map = new Map();
/** @param {analysisFormat.Element|analysisFormat.Class|analysisFormat.Function} feature */
function index(feature) {
const filename = getFilename(feature) || '???';
const filename = getFilename(feature);
if (!filename) {
throw new Error(
`Could not get filename for feature: ${util.inspect(feature)}`);
}
let arr = map.get(filename);
if (arr === undefined) {
arr = [];
Expand Down Expand Up @@ -139,7 +157,7 @@ async function main() {

if (require.main === module) {
main().catch((e) => {
console.error(e ? e.stack || e.message || e: `Unknown error`);
console.error(e ? (e.stack || e.message || e) : `Unknown error`);
process.exitCode = 1;
});
}

0 comments on commit e17f9dd

Please sign in to comment.