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

Windows support - switch to js for doc assembly #2475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
560 changes: 8 additions & 552 deletions docs/package-lock.json

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "Rob Dodson",
"license": "MIT",
"devDependencies": {
"clean-css-cli": "5.6.2",
"clean-css": "^5.3.3",
"handlebars": "4.7.8",
"marked": "9.1.3"
},
Expand All @@ -26,12 +26,13 @@
"build-css": {
"files": [
"styles/third_party/bulma.css",
"styles/site.css"
"styles/site.css",
"scripts/build-css.js"
],
"commentedOut-output": [
"../out/styles/bundle.css"
],
"command": "mkdir -p ../out/styles; cat ./styles/third_party/bulma.css ./styles/site.css | cleancss -o ../out/styles/bundle.css"
"command": "node ./scripts/build-css.js"
},
"build-html": {
"dependencies": [
Expand All @@ -40,13 +41,13 @@
"files": [
"libraries",
"index.handlebars",
"index.js",
"scripts/build-html.js",
"partials"
],
"commentedOut-output": [
"../out/index.html"
],
"command": "mkdir -p ../out; node index.js > ../out/index.html"
"command": "node ./scripts/build-html.js"
},
"copy": {
"dependencies": [
Expand All @@ -57,7 +58,8 @@
"CNAME",
"robots.txt",
"images",
"libraries"
"libraries",
"scripts/copy.js"
],
"commentedOut-output": [
"../out/404.html",
Expand All @@ -66,7 +68,7 @@
"../out/images",
"../out/libraries"
],
"command": "cp 404.html CNAME robots.txt ../out && cp -r images ../out && cp -r libraries ../out"
"command": "node ./scripts/copy.js"
}
}
}
26 changes: 26 additions & 0 deletions docs/scripts/build-css.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @license
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const fs = require('fs');
const path = require('path');
const CleanCSS = require('clean-css');

const bulma = fs.readFileSync(path.resolve(__dirname, '../styles/third_party/bulma.css'), 'utf-8');
const site = fs.readFileSync(path.resolve(__dirname, '../styles/site.css'));

fs.mkdirSync(path.resolve(__dirname, '../../out/styles'), {recursive: true});
fs.writeFileSync(path.resolve(__dirname, '../../out/styles/bundle.css'), new CleanCSS().minify(bulma + site).styles);
13 changes: 8 additions & 5 deletions docs/index.js → docs/scripts/build-html.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const libraries = Object.keys(libraryMap);

hbs.registerPartial(
"octocat",
fs.readFileSync(path.join(__dirname, "/partials/octocat.handlebars"), "utf8")
fs.readFileSync(path.join(__dirname, "..", "partials", "octocat.handlebars"), "utf8")
);

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

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

function buildContext(libraries) {
return libraries.map(library => {
const repo = require(path.resolve(
__dirname,
"..",
"libraries",
library,
"results/repo.json"
Expand All @@ -97,6 +98,7 @@ function buildContext(libraries) {
function getTestResults(library) {
const json = require(path.resolve(
__dirname,
"..",
"libraries",
library,
"results/results.json"
Expand All @@ -111,6 +113,7 @@ function getTestResults(library) {
function getIssues(library) {
return require(path.resolve(
__dirname,
"..",
"libraries",
library,
"meta/issues.json"
Expand All @@ -120,13 +123,13 @@ function getIssues(library) {
// Collect markdown summary of library, process markdown, and return as string.
function getSummary(library) {
const md = fs.readFileSync(
path.resolve(__dirname, "libraries", library, "meta/summary.md"),
path.resolve(__dirname, "..", "libraries", library, "meta/summary.md"),
"utf8"
);
const content = marked.parse(md);

return { content };
}

// npm build script writes this output to index.html
console.log(out);
fs.mkdirSync(path.resolve(__dirname, '../../out'), {recursive: true});
fs.writeFileSync(path.resolve(__dirname, '../../out/index.html'), out);
34 changes: 34 additions & 0 deletions docs/scripts/copy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* @license
* Copyright 2017 Google Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const fs = require('fs');
const path = require('path');

const docs = path.resolve(__dirname, '..');
const out = path.join(docs, '..', 'out');

const files = [
'404.html',
'CNAME',
'robots.txt',
'images',
'libraries',
]

for (const file of files) {
fs.cpSync(path.join(docs, file), path.join(out, file), { recursive: true });
}
2 changes: 1 addition & 1 deletion libraries/lwc/meta/expectedResults.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"failed": 8,
"passed": 8
}
}
}
2 changes: 1 addition & 1 deletion libraries/solid/meta/expectedResults.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"failed": 0,
"passed": 16
}
}
}
2 changes: 1 addition & 1 deletion libraries/svelte/meta/expectedResults.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"failed": 0,
"passed": 16
}
}
}
Loading