Skip to content

Commit 3140dda

Browse files
Create generateDocsIndex.js
1 parent 1729d0e commit 3140dda

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

scripts/generateDocsIndex.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
const fs = require("fs");
2+
const path = require("path");
3+
4+
const DOCS_DIR = path.join(__dirname, "..", "docs");
5+
const OUTPUT_FILE = path.join(__dirname, "..", "docs-index.html");
6+
7+
const RAW_BASE =
8+
"https://raw.githubusercontent.com/DeveloperTryingToCodeLikeOtherOfThem/pxt-hardware-programming-docs/master/docs/";
9+
10+
function generate() {
11+
const files = fs.readdirSync(DOCS_DIR)
12+
.filter(f => f.endsWith(".md"));
13+
14+
const links = files.map(f => {
15+
return `<li><a href="${RAW_BASE}${f}" target="_blank">${f}</a></li>`;
16+
}).join("\n");
17+
18+
const html = `
19+
<html>
20+
<head><title>Docs Index</title></head>
21+
<body>
22+
<h1>Documentation Files</h1>
23+
<ul>
24+
${links}
25+
</ul>
26+
</body>
27+
</html>
28+
`;
29+
30+
fs.writeFileSync(OUTPUT_FILE, html);
31+
console.log("Generated docs-index.html");
32+
}
33+
34+
generate();

0 commit comments

Comments
 (0)