Browse Source

Add JS-based tooling to generate RELEASES.rst

pull/2284/head
Sami Vaarala 5 years ago
parent
commit
83156de4ea
  1. 1361
      releases/releases.yaml
  2. 28
      src-tools/lib/command/generate_releases_rst.js
  3. 15
      src-tools/lib/duktool/main.js
  4. 61
      src-tools/lib/website/releases_rst.js

1361
releases/releases.yaml

File diff suppressed because it is too large

28
src-tools/lib/command/generate_releases_rst.js

@ -0,0 +1,28 @@
'use strict';
const { writeFileUtf8 } = require('../util/fs');
const { createBareObject } = require('../util/bare');
const { releasesYamlToRst } = require('../website/releases_rst');
const generateReleasesRstCommandSpec = createBareObject({
description: 'Generate RELEASES.rst from releases metadata',
options: createBareObject({
'input': { type: 'path', short: 'i', default: void 0, required: true, description: 'input releases.yaml file' },
'output': { type: 'path', short: 'o', default: void 0, description: 'output RELEASES.rst file (dump to stdout if missing)' }
})
});
exports.generateReleasesRstCommandSpec = generateReleasesRstCommandSpec;
function generateReleasesRstCommand(cmdline, autoDuktapeRoot) {
void autoDuktapeRoot;
var opts = cmdline.commandOpts;
var inputFile = opts['input'];
var outputFile = opts['output'];
var rstData = releasesYamlToRst(inputFile);
if (outputFile) {
writeFileUtf8(outputFile, rstData);
} else {
console.log(rstData);
}
}
exports.generateReleasesRstCommand = generateReleasesRstCommand;

15
src-tools/lib/duktool/main.js

@ -12,6 +12,7 @@ const { configureCommand, configureCommandSpec } = require('../command/configure
const { distCommand, distCommandSpec } = require('../command/dist'); const { distCommand, distCommandSpec } = require('../command/dist');
const { decodeBytecodeCommand, decodeBytecodeCommandSpec } = require('../command/decode_bytecode'); const { decodeBytecodeCommand, decodeBytecodeCommandSpec } = require('../command/decode_bytecode');
const { dumpBytecodeCommand, dumpBytecodeCommandSpec } = require('../command/dump_bytecode'); const { dumpBytecodeCommand, dumpBytecodeCommandSpec } = require('../command/dump_bytecode');
const { generateReleasesRstCommand, generateReleasesRstCommandSpec } = require('../command/generate_releases_rst');
// Command line parsing spec. // Command line parsing spec.
@ -19,10 +20,11 @@ const commandSpec = {
options: createBareObject({ options: createBareObject({
}), }),
commands: createBareObject({ commands: createBareObject({
configure: configureCommandSpec, ['configure']: configureCommandSpec,
dist: distCommandSpec, ['dist']: distCommandSpec,
['decode-bytecode']: decodeBytecodeCommandSpec, ['decode-bytecode']: decodeBytecodeCommandSpec,
['dump-bytecode']: dumpBytecodeCommandSpec ['dump-bytecode']: dumpBytecodeCommandSpec,
['generate-releases-rst']: generateReleasesRstCommandSpec
}) })
}; };
@ -72,10 +74,10 @@ function main() {
// Commands. // Commands.
var commandMap = createBareObject({ var commandMap = createBareObject({
// Main commands: configure and prepare sources, dist. // Main commands: configure and prepare sources, dist.
configure: () => { ['configure']: () => {
configureCommand(cmdline, autoDuktapeRoot); configureCommand(cmdline, autoDuktapeRoot);
}, },
dist: () => { ['dist']: () => {
distCommand(cmdline, autoDuktapeRoot); distCommand(cmdline, autoDuktapeRoot);
}, },
['decode-bytecode']: () => { ['decode-bytecode']: () => {
@ -83,6 +85,9 @@ function main() {
}, },
['dump-bytecode']: () => { ['dump-bytecode']: () => {
dumpBytecodeCommand(cmdline, autoDuktapeRoot); dumpBytecodeCommand(cmdline, autoDuktapeRoot);
},
['generate-releases-rst']: () => {
generateReleasesRstCommand(cmdline, autoDuktapeRoot);
} }
}); });

61
src-tools/lib/website/releases_rst.js

@ -0,0 +1,61 @@
'use strict';
const { readFileYaml } = require('../util/fs');
function releasesYamlToRst(fn) {
var doc = readFileYaml(fn);
var res = [];
res.push('================');
res.push('Duktape releases');
res.push('================');
function rstEscape(x) {
x = x.replace(/\\/g, () => { return '\\\\'; });
x = x.replace(/\*/g, () => { return '\\*'; });
return x;
}
function emitChange(change) {
let changeDesc = typeof change === 'string' ? change : change.description;
res.push('');
res.push('* ' + rstEscape(changeDesc));
}
function emitReleases(released) {
doc.duktape_releases.forEach((rel) => {
let isReleased = !!rel.release_date;
if (released !== isReleased) {
return;
}
let relTitle = rel.version + ' (' + (rel.release_date || 'XXXX-XX-XX') + ')';
res.push('');
res.push(relTitle);
res.push(('-').repeat(relTitle.length));
//res.push('');
//res.push('* DESCRIPTION: ' + rel.description + (rel.maintained === false ? ' (no longer maintained)' : ''));
if (rel.changes_sections) {
rel.changes_sections.forEach((section) => {
let sectionTitle = section.title + ':';
res.push('');
res.push(sectionTitle);
section.changes.forEach(emitChange);
});
} else {
rel.changes.forEach(emitChange);
}
});
}
res.push('');
res.push('Released');
res.push('========');
emitReleases(true);
res.push('');
res.push('Planned');
res.push('=======');
emitReleases(false);
return res.join('\n') + '\n';
}
exports.releasesYamlToRst = releasesYamlToRst;
Loading…
Cancel
Save