Skip to content

Commit

Permalink
Add boilerplate to IDL files with spec info
Browse files Browse the repository at this point in the history
See: w3c/webref#3 (comment)

Boilerplate is:

// GENERATED CONTENT - DO NOT EDIT
// Content of this file was automatically extracted from the
// "{spec title}" spec.
// See: {crawled url}

Note that we could also easily add the spec date to the boilerplate, but doing
so would mean that IDL files will be updated in GitHub whenever the spec
changes, even when the changes do not touch on the IDL defined in the spec.
  • Loading branch information
tidoust committed May 19, 2018
1 parent aab4994 commit f5f6dfe
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/cli/crawl-specs.js
Expand Up @@ -374,9 +374,20 @@ function saveResults(crawlInfo, crawlOptions, data, folder) {
.then(idlFolder => Promise.all(data.map(spec =>
new Promise((resolve, reject) => {
if (spec.idl.idl) {
fs.writeFile(path.join(idlFolder, getShortname(spec) + '.idl'),
spec.idl.idl,
err => { if (err) return console.log(err); return resolve();});
let idl = `
// GENERATED CONTENT - DO NOT EDIT
// Content of this file was automatically extracted from the
// "${spec.title}" spec.
// See: ${spec.crawled}`;
idl = idl.replace(/^\s+/gm, '').trim();
idl += `\n\n${spec.idl.idl.trim()}`;
fs.writeFile(
path.join(idlFolder, getShortname(spec) + '.idl'),
idl,
err => {
if (err) console.log(err);
return resolve();
});
delete spec.idl.idl;
} else resolve();
}))).then(_ => new Promise((resolve, reject) => {
Expand Down

0 comments on commit f5f6dfe

Please sign in to comment.