mirror of https://github.com/svaarala/duktape.git
Sami Vaarala
5 years ago
4 changed files with 1460 additions and 5 deletions
File diff suppressed because it is too large
@ -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; |
@ -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…
Reference in new issue