'use strict'; // Build all.html by combining the generated toc and apicontent from each // of the generated html files. const fs = require('fs'); const source = `${__dirname}/../../out/doc/api`; // Get a list of generated API documents. const htmlFiles = fs.readdirSync(source, 'utf8') .filter((name) => name.includes('.html') && name !== 'all.html'); // Read the table of contents. const toc = fs.readFileSync(source + '/index.html', 'utf8'); // Extract (and concatenate) the toc and apicontent from each document. let contents = ''; let apicontent = ''; // Identify files that should be skipped. As files are processed, they // are added to this list to prevent dupes. const seen = { 'all.html': true, 'index.html': true }; for (const link of toc.match(//g)) { const href = /href="(.*?)"/.exec(link)[1]; if (!htmlFiles.includes(href) || seen[href]) continue; const data = fs.readFileSync(source + '/' + href, 'utf8'); // Split the doc. const match = /(<\/ul>\s*)?<\/div>\s*
/.exec(data); contents += data.slice(0, match.index) .replace(/[\s\S]*?