Skip to content

Commit 5257bfe

Browse files
committed
Switch to js for doc assembly
1 parent 93718b7 commit 5257bfe

File tree

8 files changed

+88
-567
lines changed

8 files changed

+88
-567
lines changed

docs/package-lock.json

+8-552
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/package.json

+9-7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "Rob Dodson",
1212
"license": "MIT",
1313
"devDependencies": {
14-
"clean-css-cli": "5.6.2",
14+
"clean-css": "^5.3.3",
1515
"handlebars": "4.7.8",
1616
"marked": "9.1.3"
1717
},
@@ -26,12 +26,13 @@
2626
"build-css": {
2727
"files": [
2828
"styles/third_party/bulma.css",
29-
"styles/site.css"
29+
"styles/site.css",
30+
"scripts/build-css.js"
3031
],
3132
"commentedOut-output": [
3233
"../out/styles/bundle.css"
3334
],
34-
"command": "mkdir -p ../out/styles; cat ./styles/third_party/bulma.css ./styles/site.css | cleancss -o ../out/styles/bundle.css"
35+
"command": "node ./scripts/build-css.js"
3536
},
3637
"build-html": {
3738
"dependencies": [
@@ -40,13 +41,13 @@
4041
"files": [
4142
"libraries",
4243
"index.handlebars",
43-
"index.js",
44+
"scripts/build-html.js",
4445
"partials"
4546
],
4647
"commentedOut-output": [
4748
"../out/index.html"
4849
],
49-
"command": "mkdir -p ../out; node index.js > ../out/index.html"
50+
"command": "node ./scripts/build-html.js"
5051
},
5152
"copy": {
5253
"dependencies": [
@@ -57,7 +58,8 @@
5758
"CNAME",
5859
"robots.txt",
5960
"images",
60-
"libraries"
61+
"libraries",
62+
"scripts/copy.js"
6163
],
6264
"commentedOut-output": [
6365
"../out/404.html",
@@ -66,7 +68,7 @@
6668
"../out/images",
6769
"../out/libraries"
6870
],
69-
"command": "cp 404.html CNAME robots.txt ../out && cp -r images ../out && cp -r libraries ../out"
71+
"command": "node ./scripts/copy.js"
7072
}
7173
}
7274
}

docs/scripts/build-css.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @license
3+
* Copyright 2017 Google Inc. All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
const fs = require('fs');
19+
const path = require('path');
20+
const CleanCSS = require('clean-css');
21+
22+
const bulma = fs.readFileSync(path.resolve(__dirname, '../styles/third_party/bulma.css'), 'utf-8');
23+
const site = fs.readFileSync(path.resolve(__dirname, '../styles/site.css'));
24+
25+
fs.mkdirSync(path.resolve(__dirname, '../../out/styles'), {recursive: true});
26+
fs.writeFileSync(path.resolve(__dirname, '../../out/styles/bundle.css'), new CleanCSS().minify(bulma + site).styles);

docs/index.js renamed to docs/scripts/build-html.js

+8-5
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const libraries = Object.keys(libraryMap);
5151

5252
hbs.registerPartial(
5353
"octocat",
54-
fs.readFileSync(path.join(__dirname, "/partials/octocat.handlebars"), "utf8")
54+
fs.readFileSync(path.join(__dirname, "..", "partials", "octocat.handlebars"), "utf8")
5555
);
5656

5757
// Helper to color progress bar based on test scores
@@ -66,14 +66,15 @@ hbs.registerHelper("warning-level", function (score) {
6666
}
6767
});
6868

69-
const tmpl = fs.readFileSync(path.join(__dirname, "index.handlebars"), "utf8");
69+
const tmpl = fs.readFileSync(path.join(__dirname, "..","index.handlebars"), "utf8");
7070
const render = hbs.compile(tmpl);
7171
const out = render({ libraries: buildContext(libraries) });
7272

7373
function buildContext(libraries) {
7474
return libraries.map(library => {
7575
const repo = require(path.resolve(
7676
__dirname,
77+
"..",
7778
"libraries",
7879
library,
7980
"results/repo.json"
@@ -97,6 +98,7 @@ function buildContext(libraries) {
9798
function getTestResults(library) {
9899
const json = require(path.resolve(
99100
__dirname,
101+
"..",
100102
"libraries",
101103
library,
102104
"results/results.json"
@@ -111,6 +113,7 @@ function getTestResults(library) {
111113
function getIssues(library) {
112114
return require(path.resolve(
113115
__dirname,
116+
"..",
114117
"libraries",
115118
library,
116119
"meta/issues.json"
@@ -120,13 +123,13 @@ function getIssues(library) {
120123
// Collect markdown summary of library, process markdown, and return as string.
121124
function getSummary(library) {
122125
const md = fs.readFileSync(
123-
path.resolve(__dirname, "libraries", library, "meta/summary.md"),
126+
path.resolve(__dirname, "..", "libraries", library, "meta/summary.md"),
124127
"utf8"
125128
);
126129
const content = marked.parse(md);
127130

128131
return { content };
129132
}
130133

131-
// npm build script writes this output to index.html
132-
console.log(out);
134+
fs.mkdirSync(path.resolve(__dirname, '../../out'), {recursive: true});
135+
fs.writeFileSync(path.resolve(__dirname, '../../out/index.html'), out);

docs/scripts/copy.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @license
3+
* Copyright 2017 Google Inc. All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
const fs = require('fs');
19+
const path = require('path');
20+
21+
const docs = path.resolve(__dirname, '..');
22+
const out = path.join(docs, '..', 'out');
23+
24+
const files = [
25+
'404.html',
26+
'CNAME',
27+
'robots.txt',
28+
'images',
29+
'libraries',
30+
]
31+
32+
for (const file of files) {
33+
fs.cpSync(path.join(docs, file), path.join(out, file), { recursive: true });
34+
}

libraries/lwc/meta/expectedResults.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
"failed": 8,
1717
"passed": 8
1818
}
19-
}
19+
}

libraries/solid/meta/expectedResults.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
"failed": 0,
1717
"passed": 16
1818
}
19-
}
19+
}

libraries/svelte/meta/expectedResults.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
"failed": 0,
1717
"passed": 16
1818
}
19-
}
19+
}

0 commit comments

Comments
 (0)