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

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>© !YEAR! !CONTRIBUTORS!</p>

lib/Spec.js

+39-13
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

+1-1
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

+1
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

+4-1
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

+1-1
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

+4-1
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

+4-1
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

+4-1
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

+4-1
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>

test/eqn.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<link rel=stylesheet href="./css/elements.css">
2-
<pre class=metadata>toc: false</pre>
2+
<pre class=metadata>
3+
toc: false
4+
copyright: false
5+
</pre>
36
<emu-clause id="sec-example">
47
<h1>Header</h1>
58
<p>Can refer to eqns inside paragraph text via autolinking: DateValue.</p>

test/escaping.html

+4-1
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-clause id="blah">
36
<h1>blah</h1>
47
<p>U+200C (ZERO WIDTH NON-JOINER) is abbreviated "&lt;ZWNJ&gt;"</p>

test/example.html

+4-1
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
<p>Examples outside of clauses aren't processed specially.</p>
36
<emu-example>
47
This is an example.

test/figure.html

+4-1
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
<link rel="stylesheet" href="css/elements.css">
36
<emu-figure id="figure-1">
47
this is a figure!

test/imports.html

+4-1
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-import href="imports/import1.html"></emu-import>
36
<emu-import href="imports/import2.html"></emu-import>
47

test/notes.html

+4-1
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-note>This is a note. Since it is outside a clause it is unstyled.</emu-note>
36

47
<emu-clause id="sec-this">

test/proposal-copyright.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<pre class=metadata>
2+
title: test title!
3+
toc: false
4+
date: 2014-09-26
5+
contributors: Brian Terlson, Ecma International
6+
</pre>
7+

test/proposal-copyright.html.baseline

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!doctype html>
2+
<head><title>test title!</title><meta charset="utf-8"></head><body><h1 class="version">Stage 0 Draft / September 26, 2014</h1><h1 class="title">test title!</h1>
3+
4+
<emu-annex id="sec-copyright-and-software-license">
5+
<h1><span class="secnum">A</span>Copyright &amp; Software License<span class="utils"><span class="anchor"><a href="#sec-copyright-and-software-license">#</a></span></span></h1>
6+
<h2>Copyright Notice</h2>
7+
<p>© 2014 Brian Terlson, Ecma International</p>
8+
9+
<h2>Software License</h2>
10+
<p>All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT http://www.ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.</p>
11+
12+
<p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>
13+
14+
<ol>
15+
<li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li>
16+
<li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li>
17+
<li>Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.</li>
18+
</ol>
19+
20+
<p>THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
21+
22+
</emu-annex></body>

test/xref.html

+4-1
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="./xrefTestBiblio.json"></emu-biblio>
36
<emu-clause id="sec-clause-id">
47
<h1>Clause Title</h1>

0 commit comments

Comments
 (0)