Skip to content

Commit 818e2c9

Browse files
committed
Add copyright boilerplate generation for proposals
1 parent cba78a9 commit 818e2c9

19 files changed

+120
-27
lines changed

boilerplate/proposal-copyright.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>© !YEAR! !CONTRIBUTORS!</p>

lib/Spec.js

Lines changed: 39 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ module.exports = class Spec {
8989
if (!this.opts.date) {
9090
this.opts.date = new Date();
9191
}
92+
93+
if (this.opts.stage) {
94+
this.opts.stage = String(this.opts.stage);
95+
} else if (this.opts.status === 'proposal') {
96+
this.opts.stage = '0';
97+
} else {
98+
this.opts.stage = null;
99+
}
92100
}
93101

94102
buildAll(selector, Builder, opts) {
@@ -246,11 +254,16 @@ module.exports = class Spec {
246254
const version = this.opts.version;
247255
const title = this.opts.title;
248256
const shortname = this.opts.shortname;
249-
const stage = this.opts.stage === undefined ? null : String(this.opts.stage);
257+
const stage = this.opts.stage;
250258

251-
if (this.opts.copyright && (status === 'draft' || status === 'standard')) {
252-
this.buildCopyrightBoilerplate();
259+
if (this.opts.copyright) {
260+
if (status !== 'draft' && status !== 'standard' && !this.opts.contributors) {
261+
utils.logWarning('Contributors not specified, skipping copyright boilerplate. Specify contributors in your frontmatter metadata.');
262+
} else {
263+
this.buildCopyrightBoilerplate();
264+
}
253265
}
266+
254267
// no title boilerplate generated if title not specified
255268
if (!title) return;
256269

@@ -305,16 +318,34 @@ module.exports = class Spec {
305318
copyright = fs.readFileSync('boilerplate/draft-copyright.html', 'utf8');
306319
} else if (this.opts.status === 'standard') {
307320
copyright = fs.readFileSync('boilerplate/standard-copyright.html', 'utf8');
321+
} else {
322+
copyright = fs.readFileSync('boilerplate/proposal-copyright.html', 'utf8');
323+
}
324+
325+
copyright = copyright.replace(/!YEAR!/g, this.opts.date.getFullYear());
326+
327+
if (this.opts.contributors) {
328+
copyright = copyright.replace(/!CONTRIBUTORS!/g, this.opts.contributors);
308329
}
309330

310331
const softwareLicense = fs.readFileSync('boilerplate/software-license.html', 'utf8');
311332

312-
let lastAnnex = this.doc.querySelector('body > emu-annex:last-child');
313-
let lastClause = this.doc.querySelector('body > emu-clause:last-child');
314-
const last = lastAnnex || lastClause;
333+
let copyrightClause = this.doc.querySelector('.copyright-and-software-license');
334+
if (!copyrightClause) {
335+
let lastAnnex = this.doc.querySelector('body > emu-annex:last-child');
336+
let lastClause = this.doc.querySelector('body > emu-clause:last-child');
337+
const last = lastAnnex || lastClause;
338+
339+
copyrightClause = this.doc.createElement('emu-annex');
340+
copyrightClause.setAttribute('id', 'sec-copyright-and-software-license');
341+
342+
if (last) {
343+
last.parentNode.insertBefore(copyrightClause, last.previousSibling);
344+
} else {
345+
this.doc.body.appendChild(copyrightClause);
346+
}
347+
}
315348

316-
const copyrightClause = this.doc.createElement('emu-annex');
317-
copyrightClause.setAttribute('id', 'sec-copyright-and-software-license');
318349
copyrightClause.innerHTML = `
319350
<h1>Copyright &amp; Software License</h1>
320351
<h2>Copyright Notice</h2>
@@ -323,11 +354,6 @@ module.exports = class Spec {
323354
${softwareLicense}
324355
`;
325356

326-
if (last) {
327-
last.parentNode.insertBefore(copyrightClause, last.previousSibling);
328-
} else {
329-
this.doc.body.appendChild(copyrightClause);
330-
}
331357
}
332358

333359
autolink() {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ecmarkup",
3-
"version": "2.3.0",
3+
"version": "2.4.0",
44
"description": "Custom element definitions and core utilities for markup that specifies ECMAScript and related technologies.",
55
"main": "lib/ecmarkup.js",
66
"scripts": {

spec/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ <h1>Useful Options</h1>
6060
<tr><td>shortname</td><td>Shortname of specification, for example `ECMA-262` or `ECMA-402`.</td></tr>
6161
<tr><td>location</td><td>URL of this specification. Use in conjunction with the biblio file to enable external specs to reference this one.</td></tr>
6262
<tr><td>copyright</td><td>Emit copyright and software license information. Boolean, default true.</td></tr>
63+
<tr><td>contributors</td><td>Contributors to this specification, ie. those who own the copyright. If your proposal includes text from any Ecma specification, you should include "Ecma International" in this list.</td></tr>
6364
<tr><td>toc</td><td>Emit table of contents. Boolean, default true.</td></tr>
6465
<tr><td>old-toc</td><td>Emit the old style of table of contents. Boolean, default false.</td></tr>
6566
</table>

test/algorithms.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<pre class=metadata>toc: false</pre>
1+
<pre class=metadata>
2+
toc: false
3+
copyright: false
4+
</pre>
25
<emu-biblio href="./algorithmsBiblio.json"></emu-biblio>
36
<emu-alg>
47
1. Can call abstract operations in this spec: Internal();

test/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const Promise = require('bluebird');
44

55
const build = require('../lib/ecmarkup').build;
66

7-
const doc = '<!doctype html><pre class=metadata>toc: false</pre><emu-clause><h1>hi</h1></emu-clause>';
7+
const doc = '<!doctype html><pre class=metadata>toc: false\ncopyright: false</pre><emu-clause><h1>hi</h1></emu-clause>';
88
const out = '<!doctype html>\n<head><meta charset="utf-8"></head><body><emu-clause><h1><span class="secnum">1</span>hi<span class="utils"><span class="anchor"><a href="#">#</a></span></span></h1></emu-clause></body>';
99
function fetch(file) {
1010
if (file.match(/\.json$/)) {

test/charset-absent.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
<pre class=metadata>toc: false</pre>
1+
<pre class=metadata>
2+
toc: false
3+
copyright: false
4+
</pre>

test/charset-present.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
<meta charset="ascii">
2-
<pre class=metadata>toc: false</pre>
2+
<pre class=metadata>
3+
toc: false
4+
copyright: false
5+
</pre>
36

test/clauses.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<pre class=metadata>oldToc: true</pre>
1+
<pre class=metadata>
2+
oldToc: true
3+
copyright: false
4+
</pre>
25
<emu-intro>
36
<h1>Intro</h1>
47
<emu-intro>

test/dfn.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
<pre class=metadata>toc: false</pre>
1+
<pre class=metadata>
2+
toc: false
3+
copyright: false
4+
</pre>
25
<emu-intro id="sec-intro">
36
<h1>Intro</h1>
47
<p>Forward references to dfn work.</p>

0 commit comments

Comments
 (0)