From f00e0e1bbc680d97549c4d20bf560c3807c313d2 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Mon, 13 Sep 2021 18:36:48 -0700 Subject: [PATCH] use a github action to deploy docs, instead of commiting files (#361) --- .gitattributes | 1 - .github/workflows/check.yml | 7 +- .github/workflows/update-docs.yml | 30 + .gitignore | 1 + docs/ecmarkup.js | 1138 ---------------------------- docs/elements.css | 1177 ----------------------------- docs/index.html | 621 --------------- package.json | 2 +- scripts/auto-deploy.sh | 17 + 9 files changed, 52 insertions(+), 2942 deletions(-) delete mode 100644 .gitattributes create mode 100644 .github/workflows/update-docs.yml delete mode 100644 docs/ecmarkup.js delete mode 100644 docs/elements.css delete mode 100644 docs/index.html create mode 100755 scripts/auto-deploy.sh diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index ea1ff4f9..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -/docs/* linguist-generated=true diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 3b58be4e..45e1c4b5 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -16,15 +16,14 @@ jobs: - name: Setup node uses: actions/setup-node@v2 + with: + node-version: '16' - name: Install dependencies run: npm ci - name: Build - run: npm run build && npm run build-spec - - - name: Enforce docs build - run: if [ ! -z "$(git status --porcelain)" ]; then echo "repo is dirty; you probably need to 'npm run build-spec' and commit the result"; exit 1; fi + run: npm run build - name: Test run: npm test diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml new file mode 100644 index 00000000..21abf8d5 --- /dev/null +++ b/.github/workflows/update-docs.yml @@ -0,0 +1,30 @@ +name: 'update docs' + +on: + push: + branches: + - main + +jobs: + docs: + name: 'deploy github pages' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: '16' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build && npm run build-spec + + - name: Deploy docs + run: ./scripts/auto-deploy.sh + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 50eed6bd..819ecdc7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ test/baselines/generated-local package ecmarkup-*.tgz .vscode/ +docs/ diff --git a/docs/ecmarkup.js b/docs/ecmarkup.js deleted file mode 100644 index 6ef708f3..00000000 --- a/docs/ecmarkup.js +++ /dev/null @@ -1,1138 +0,0 @@ -'use strict'; -let sdoBox = { - init() { - this.$alternativeId = null; - this.$outer = document.createElement('div'); - this.$outer.classList.add('toolbox-container'); - this.$container = document.createElement('div'); - this.$container.classList.add('toolbox'); - this.$displayLink = document.createElement('a'); - this.$displayLink.setAttribute('href', '#'); - this.$displayLink.textContent = 'Syntax-Directed Operations'; - this.$displayLink.addEventListener('click', e => { - e.preventDefault(); - e.stopPropagation(); - referencePane.showSDOs(sdoMap[this.$alternativeId] || {}, this.$alternativeId); - }); - this.$container.appendChild(this.$displayLink); - this.$outer.appendChild(this.$container); - document.body.appendChild(this.$outer); - }, - - activate(el) { - clearTimeout(this.deactiveTimeout); - Toolbox.deactivate(); - this.$alternativeId = el.id; - let numSdos = Object.keys(sdoMap[this.$alternativeId] || {}).length; - this.$displayLink.textContent = 'Syntax-Directed Operations (' + numSdos + ')'; - this.$outer.classList.add('active'); - let top = el.offsetTop - this.$outer.offsetHeight; - let left = el.offsetLeft + 50 - 10; // 50px = padding-left(=75px) + text-indent(=-25px) - this.$outer.setAttribute('style', 'left: ' + left + 'px; top: ' + top + 'px'); - if (top < document.body.scrollTop) { - this.$container.scrollIntoView(); - } - }, - - deactivate() { - clearTimeout(this.deactiveTimeout); - this.$outer.classList.remove('active'); - }, -}; - -document.addEventListener('DOMContentLoaded', () => { - if (typeof sdoMap == 'undefined') { - console.error('could not find sdo map'); - return; - } - sdoBox.init(); - - let insideTooltip = false; - sdoBox.$outer.addEventListener('pointerenter', () => { - insideTooltip = true; - }); - sdoBox.$outer.addEventListener('pointerleave', () => { - insideTooltip = false; - sdoBox.deactivate(); - }); - - sdoBox.deactiveTimeout = null; - [].forEach.call(document.querySelectorAll('emu-grammar[type=definition] emu-rhs'), node => { - node.addEventListener('pointerenter', function () { - sdoBox.activate(this); - }); - - node.addEventListener('pointerleave', () => { - sdoBox.deactiveTimeout = setTimeout(() => { - if (!insideTooltip) { - sdoBox.deactivate(); - } - }, 500); - }); - }); - - document.addEventListener( - 'keydown', - debounce(e => { - if (e.code === 'Escape') { - sdoBox.deactivate(); - } - }) - ); -}); - -'use strict'; -function Search(menu) { - this.menu = menu; - this.$search = document.getElementById('menu-search'); - this.$searchBox = document.getElementById('menu-search-box'); - this.$searchResults = document.getElementById('menu-search-results'); - - this.loadBiblio(); - - document.addEventListener('keydown', this.documentKeydown.bind(this)); - - this.$searchBox.addEventListener( - 'keydown', - debounce(this.searchBoxKeydown.bind(this), { stopPropagation: true }) - ); - this.$searchBox.addEventListener( - 'keyup', - debounce(this.searchBoxKeyup.bind(this), { stopPropagation: true }) - ); - - // Perform an initial search if the box is not empty. - if (this.$searchBox.value) { - this.search(this.$searchBox.value); - } -} - -Search.prototype.loadBiblio = function () { - if (typeof biblio === 'undefined') { - console.error('could not find biblio'); - this.biblio = { refToClause: {}, entries: [] }; - } else { - this.biblio = biblio; - this.biblio.clauses = this.biblio.entries.filter(e => e.type === 'clause'); - this.biblio.byId = this.biblio.entries.reduce((map, entry) => { - map[entry.id] = entry; - return map; - }, {}); - let refParentClause = Object.create(null); - this.biblio.refParentClause = refParentClause; - let refsByClause = this.biblio.refsByClause; - Object.keys(refsByClause).forEach(clause => { - refsByClause[clause].forEach(ref => { - refParentClause[ref] = clause; - }); - }); - } -}; - -Search.prototype.documentKeydown = function (e) { - if (e.keyCode === 191) { - e.preventDefault(); - e.stopPropagation(); - this.triggerSearch(); - } -}; - -Search.prototype.searchBoxKeydown = function (e) { - e.stopPropagation(); - e.preventDefault(); - if (e.keyCode === 191 && e.target.value.length === 0) { - e.preventDefault(); - } else if (e.keyCode === 13) { - e.preventDefault(); - this.selectResult(); - } -}; - -Search.prototype.searchBoxKeyup = function (e) { - if (e.keyCode === 13 || e.keyCode === 9) { - return; - } - - this.search(e.target.value); -}; - -Search.prototype.triggerSearch = function () { - if (this.menu.isVisible()) { - this._closeAfterSearch = false; - } else { - this._closeAfterSearch = true; - this.menu.show(); - } - - this.$searchBox.focus(); - this.$searchBox.select(); -}; -// bit 12 - Set if the result starts with searchString -// bits 8-11: 8 - number of chunks multiplied by 2 if cases match, otherwise 1. -// bits 1-7: 127 - length of the entry -// General scheme: prefer case sensitive matches with fewer chunks, and otherwise -// prefer shorter matches. -function relevance(result) { - let relevance = 0; - - relevance = Math.max(0, 8 - result.match.chunks) << 7; - - if (result.match.caseMatch) { - relevance *= 2; - } - - if (result.match.prefix) { - relevance += 2048; - } - - relevance += Math.max(0, 255 - result.key.length); - - return relevance; -} - -Search.prototype.search = function (searchString) { - if (searchString === '') { - this.displayResults([]); - this.hideSearch(); - return; - } else { - this.showSearch(); - } - - if (searchString.length === 1) { - this.displayResults([]); - return; - } - - let results; - - if (/^[\d.]*$/.test(searchString)) { - results = this.biblio.clauses - .filter(clause => clause.number.substring(0, searchString.length) === searchString) - .map(clause => ({ entry: clause })); - } else { - results = []; - - for (let i = 0; i < this.biblio.entries.length; i++) { - let entry = this.biblio.entries[i]; - let key = getKey(entry); - if (!key) { - // biblio entries without a key aren't searchable - continue; - } - - let match = fuzzysearch(searchString, key); - if (match) { - results.push({ key, entry, match }); - } - } - - results.forEach(result => { - result.relevance = relevance(result, searchString); - }); - - results = results.sort((a, b) => b.relevance - a.relevance); - } - - if (results.length > 50) { - results = results.slice(0, 50); - } - - this.displayResults(results); -}; -Search.prototype.hideSearch = function () { - this.$search.classList.remove('active'); -}; - -Search.prototype.showSearch = function () { - this.$search.classList.add('active'); -}; - -Search.prototype.selectResult = function () { - let $first = this.$searchResults.querySelector('li:first-child a'); - - if ($first) { - document.location = $first.getAttribute('href'); - } - - this.$searchBox.value = ''; - this.$searchBox.blur(); - this.displayResults([]); - this.hideSearch(); - - if (this._closeAfterSearch) { - this.menu.hide(); - } -}; - -Search.prototype.displayResults = function (results) { - if (results.length > 0) { - this.$searchResults.classList.remove('no-results'); - - let html = ''; - - this.$searchResults.innerHTML = html; - } else { - this.$searchResults.innerHTML = ''; - this.$searchResults.classList.add('no-results'); - } -}; - -function getKey(item) { - if (item.key) { - return item.key; - } - switch (item.type) { - case 'clause': - return item.title || item.titleHTML; - case 'production': - return item.name; - case 'op': - return item.aoid; - case 'term': - return item.term; - case 'table': - case 'figure': - case 'example': - case 'note': - return item.caption; - case 'step': - return item.id; - default: - throw new Error("Can't get key for " + item.type); - } -} - -function Menu() { - this.$toggle = document.getElementById('menu-toggle'); - this.$menu = document.getElementById('menu'); - this.$toc = document.querySelector('menu-toc > ol'); - this.$pins = document.querySelector('#menu-pins'); - this.$pinList = document.getElementById('menu-pins-list'); - this.$toc = document.querySelector('#menu-toc > ol'); - this.$specContainer = document.getElementById('spec-container'); - this.search = new Search(this); - - this._pinnedIds = {}; - this.loadPinEntries(); - - // toggle menu - this.$toggle.addEventListener('click', this.toggle.bind(this)); - - // keydown events for pinned clauses - document.addEventListener('keydown', this.documentKeydown.bind(this)); - - // toc expansion - let tocItems = this.$menu.querySelectorAll('#menu-toc li'); - for (let i = 0; i < tocItems.length; i++) { - let $item = tocItems[i]; - $item.addEventListener('click', event => { - $item.classList.toggle('active'); - event.stopPropagation(); - }); - } - - // close toc on toc item selection - let tocLinks = this.$menu.querySelectorAll('#menu-toc li > a'); - for (let i = 0; i < tocLinks.length; i++) { - let $link = tocLinks[i]; - $link.addEventListener('click', event => { - this.toggle(); - event.stopPropagation(); - }); - } - - // update active clause on scroll - window.addEventListener('scroll', debounce(this.updateActiveClause.bind(this))); - this.updateActiveClause(); - - // prevent menu scrolling from scrolling the body - this.$toc.addEventListener('wheel', e => { - let target = e.currentTarget; - let offTop = e.deltaY < 0 && target.scrollTop === 0; - if (offTop) { - e.preventDefault(); - } - let offBottom = e.deltaY > 0 && target.offsetHeight + target.scrollTop >= target.scrollHeight; - - if (offBottom) { - e.preventDefault(); - } - }); -} - -Menu.prototype.documentKeydown = function (e) { - e.stopPropagation(); - if (e.keyCode === 80) { - this.togglePinEntry(); - } else if (e.keyCode > 48 && e.keyCode < 58) { - this.selectPin(e.keyCode - 49); - } -}; - -Menu.prototype.updateActiveClause = function () { - this.setActiveClause(findActiveClause(this.$specContainer)); -}; - -Menu.prototype.setActiveClause = function (clause) { - this.$activeClause = clause; - this.revealInToc(this.$activeClause); -}; - -Menu.prototype.revealInToc = function (path) { - let current = this.$toc.querySelectorAll('li.revealed'); - for (let i = 0; i < current.length; i++) { - current[i].classList.remove('revealed'); - current[i].classList.remove('revealed-leaf'); - } - - current = this.$toc; - let index = 0; - outer: while (index < path.length) { - let children = current.children; - for (let i = 0; i < children.length; i++) { - if ('#' + path[index].id === children[i].children[1].hash) { - children[i].classList.add('revealed'); - if (index === path.length - 1) { - children[i].classList.add('revealed-leaf'); - let rect = children[i].getBoundingClientRect(); - // this.$toc.getBoundingClientRect().top; - let tocRect = this.$toc.getBoundingClientRect(); - if (rect.top + 10 > tocRect.bottom) { - this.$toc.scrollTop = - this.$toc.scrollTop + (rect.top - tocRect.bottom) + (rect.bottom - rect.top); - } else if (rect.top < tocRect.top) { - this.$toc.scrollTop = this.$toc.scrollTop - (tocRect.top - rect.top); - } - } - current = children[i].querySelector('ol'); - index++; - continue outer; - } - } - console.log('could not find location in table of contents', path); - break; - } -}; - -function findActiveClause(root, path) { - let clauses = getChildClauses(root); - path = path || []; - - for (let $clause of clauses) { - let rect = $clause.getBoundingClientRect(); - let $header = $clause.querySelector('h1'); - let marginTop = Math.max( - parseInt(getComputedStyle($clause)['margin-top']), - parseInt(getComputedStyle($header)['margin-top']) - ); - - if (rect.top - marginTop <= 1 && rect.bottom > 0) { - return findActiveClause($clause, path.concat($clause)) || path; - } - } - - return path; -} - -function* getChildClauses(root) { - for (let el of root.children) { - switch (el.nodeName) { - // descend into - case 'EMU-IMPORT': - yield* getChildClauses(el); - break; - - // accept , , and - case 'EMU-CLAUSE': - case 'EMU-INTRO': - case 'EMU-ANNEX': - yield el; - } - } -} - -Menu.prototype.toggle = function () { - this.$menu.classList.toggle('active'); -}; - -Menu.prototype.show = function () { - this.$menu.classList.add('active'); -}; - -Menu.prototype.hide = function () { - this.$menu.classList.remove('active'); -}; - -Menu.prototype.isVisible = function () { - return this.$menu.classList.contains('active'); -}; - -Menu.prototype.showPins = function () { - this.$pins.classList.add('active'); -}; - -Menu.prototype.hidePins = function () { - this.$pins.classList.remove('active'); -}; - -Menu.prototype.addPinEntry = function (id) { - let entry = this.search.biblio.byId[id]; - if (!entry) { - // id was deleted after pin (or something) so remove it - delete this._pinnedIds[id]; - this.persistPinEntries(); - return; - } - - if (entry.type === 'clause') { - let prefix; - if (entry.number) { - prefix = entry.number + ' '; - } else { - prefix = ''; - } - // prettier-ignore - this.$pinList.innerHTML += `
  • ${prefix}${entry.titleHTML}
  • `; - } else { - this.$pinList.innerHTML += `
  • ${entry.key}
  • `; - } - - if (Object.keys(this._pinnedIds).length === 0) { - this.showPins(); - } - this._pinnedIds[id] = true; - this.persistPinEntries(); -}; - -Menu.prototype.removePinEntry = function (id) { - let item = this.$pinList.querySelector(`a[href="${makeLinkToId(id)}"]`).parentNode; - this.$pinList.removeChild(item); - delete this._pinnedIds[id]; - if (Object.keys(this._pinnedIds).length === 0) { - this.hidePins(); - } - - this.persistPinEntries(); -}; - -Menu.prototype.persistPinEntries = function () { - try { - if (!window.localStorage) return; - } catch (e) { - return; - } - - localStorage.pinEntries = JSON.stringify(Object.keys(this._pinnedIds)); -}; - -Menu.prototype.loadPinEntries = function () { - try { - if (!window.localStorage) return; - } catch (e) { - return; - } - - let pinsString = window.localStorage.pinEntries; - if (!pinsString) return; - let pins = JSON.parse(pinsString); - for (let i = 0; i < pins.length; i++) { - this.addPinEntry(pins[i]); - } -}; - -Menu.prototype.togglePinEntry = function (id) { - if (!id) { - id = this.$activeClause[this.$activeClause.length - 1].id; - } - - if (this._pinnedIds[id]) { - this.removePinEntry(id); - } else { - this.addPinEntry(id); - } -}; - -Menu.prototype.selectPin = function (num) { - document.location = this.$pinList.children[num].children[0].href; -}; - -let menu; - -document.addEventListener('DOMContentLoaded', init); - -function debounce(fn, opts) { - opts = opts || {}; - let timeout; - return function (e) { - if (opts.stopPropagation) { - e.stopPropagation(); - } - let args = arguments; - if (timeout) { - clearTimeout(timeout); - } - timeout = setTimeout(() => { - timeout = null; - fn.apply(this, args); - }, 150); - }; -} - -let CLAUSE_NODES = ['EMU-CLAUSE', 'EMU-INTRO', 'EMU-ANNEX']; -function findContainer($elem) { - let parentClause = $elem.parentNode; - while (parentClause && CLAUSE_NODES.indexOf(parentClause.nodeName) === -1) { - parentClause = parentClause.parentNode; - } - return parentClause; -} - -function findLocalReferences(parentClause, name) { - let vars = parentClause.querySelectorAll('var'); - let references = []; - - for (let i = 0; i < vars.length; i++) { - let $var = vars[i]; - - if ($var.innerHTML === name) { - references.push($var); - } - } - - return references; -} - -let REFERENCED_CLASSES = Array.from({ length: 7 }, (x, i) => `referenced${i}`); -function chooseHighlightIndex(parentClause) { - let counts = REFERENCED_CLASSES.map($class => parentClause.getElementsByClassName($class).length); - // Find the earliest index with the lowest count. - let minCount = Infinity; - let index = null; - for (let i = 0; i < counts.length; i++) { - if (counts[i] < minCount) { - minCount = counts[i]; - index = i; - } - } - return index; -} - -function toggleFindLocalReferences($elem) { - let parentClause = findContainer($elem); - let references = findLocalReferences(parentClause, $elem.innerHTML); - if ($elem.classList.contains('referenced')) { - references.forEach($reference => { - $reference.classList.remove('referenced', ...REFERENCED_CLASSES); - }); - } else { - let index = chooseHighlightIndex(parentClause); - references.forEach($reference => { - $reference.classList.add('referenced', `referenced${index}`); - }); - } -} - -function installFindLocalReferences() { - document.addEventListener('click', e => { - if (e.target.nodeName === 'VAR') { - toggleFindLocalReferences(e.target); - } - }); -} - -document.addEventListener('DOMContentLoaded', installFindLocalReferences); - -// The following license applies to the fuzzysearch function -// The MIT License (MIT) -// Copyright © 2015 Nicolas Bevacqua -// Copyright © 2016 Brian Terlson -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -// the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -function fuzzysearch(searchString, haystack, caseInsensitive) { - let tlen = haystack.length; - let qlen = searchString.length; - let chunks = 1; - let finding = false; - - if (qlen > tlen) { - return false; - } - - if (qlen === tlen) { - if (searchString === haystack) { - return { caseMatch: true, chunks: 1, prefix: true }; - } else if (searchString.toLowerCase() === haystack.toLowerCase()) { - return { caseMatch: false, chunks: 1, prefix: true }; - } else { - return false; - } - } - - let j = 0; - outer: for (let i = 0; i < qlen; i++) { - let nch = searchString[i]; - while (j < tlen) { - let targetChar = haystack[j++]; - if (targetChar === nch) { - finding = true; - continue outer; - } - if (finding) { - chunks++; - finding = false; - } - } - - if (caseInsensitive) { - return false; - } - - return fuzzysearch(searchString.toLowerCase(), haystack.toLowerCase(), true); - } - - return { caseMatch: !caseInsensitive, chunks, prefix: j <= qlen }; -} - -let referencePane = { - init() { - this.$container = document.createElement('div'); - this.$container.setAttribute('id', 'references-pane-container'); - - let $spacer = document.createElement('div'); - $spacer.setAttribute('id', 'references-pane-spacer'); - - this.$pane = document.createElement('div'); - this.$pane.setAttribute('id', 'references-pane'); - - this.$container.appendChild($spacer); - this.$container.appendChild(this.$pane); - - this.$header = document.createElement('div'); - this.$header.classList.add('menu-pane-header'); - this.$headerText = document.createElement('span'); - this.$header.appendChild(this.$headerText); - this.$headerRefId = document.createElement('a'); - this.$header.appendChild(this.$headerRefId); - this.$closeButton = document.createElement('span'); - this.$closeButton.setAttribute('id', 'references-pane-close'); - this.$closeButton.addEventListener('click', () => { - this.deactivate(); - }); - this.$header.appendChild(this.$closeButton); - - this.$pane.appendChild(this.$header); - let tableContainer = document.createElement('div'); - tableContainer.setAttribute('id', 'references-pane-table-container'); - - this.$table = document.createElement('table'); - this.$table.setAttribute('id', 'references-pane-table'); - - this.$tableBody = this.$table.createTBody(); - - tableContainer.appendChild(this.$table); - this.$pane.appendChild(tableContainer); - - menu.$specContainer.appendChild(this.$container); - }, - - activate() { - this.$container.classList.add('active'); - }, - - deactivate() { - this.$container.classList.remove('active'); - this.state = null; - }, - - showReferencesFor(entry) { - this.activate(); - this.state = { type: 'ref', id: entry.id }; - this.$headerText.textContent = 'References to '; - let newBody = document.createElement('tbody'); - let previousId; - let previousCell; - let dupCount = 0; - this.$headerRefId.textContent = '#' + entry.id; - this.$headerRefId.setAttribute('href', makeLinkToId(entry.id)); - this.$headerRefId.style.display = 'inline'; - entry.referencingIds - .map(id => { - let cid = menu.search.biblio.refParentClause[id]; - let clause = menu.search.biblio.byId[cid]; - if (clause == null) { - throw new Error('could not find clause for id ' + cid); - } - return { id, clause }; - }) - .sort((a, b) => sortByClauseNumber(a.clause, b.clause)) - .forEach(record => { - if (previousId === record.clause.id) { - previousCell.innerHTML += ` (${dupCount + 2})`; - dupCount++; - } else { - let row = newBody.insertRow(); - let cell = row.insertCell(); - cell.innerHTML = record.clause.number; - cell = row.insertCell(); - cell.innerHTML = `${record.clause.titleHTML}`; - previousCell = cell; - previousId = record.clause.id; - dupCount = 0; - } - }, this); - this.$table.removeChild(this.$tableBody); - this.$tableBody = newBody; - this.$table.appendChild(this.$tableBody); - }, - - showSDOs(sdos, alternativeId) { - let rhs = document.getElementById(alternativeId); - let parentName = rhs.parentNode.getAttribute('name'); - let colons = rhs.parentNode.querySelector('emu-geq'); - rhs = rhs.cloneNode(true); - rhs.querySelectorAll('emu-params,emu-constraints').forEach(e => { - e.remove(); - }); - rhs.querySelectorAll('[id]').forEach(e => { - e.removeAttribute('id'); - }); - rhs.querySelectorAll('a').forEach(e => { - e.parentNode.replaceChild(document.createTextNode(e.textContent), e); - }); - - // prettier-ignore - this.$headerText.innerHTML = `Syntax-Directed Operations for
    ${parentName} ${colons.outerHTML} `; - this.$headerText.querySelector('a').append(rhs); - this.showSDOsBody(sdos, alternativeId); - }, - - showSDOsBody(sdos, alternativeId) { - this.activate(); - this.state = { type: 'sdo', id: alternativeId, html: this.$headerText.innerHTML }; - this.$headerRefId.style.display = 'none'; - let newBody = document.createElement('tbody'); - Object.keys(sdos).forEach(sdoName => { - let pair = sdos[sdoName]; - let clause = pair.clause; - let ids = pair.ids; - let first = ids[0]; - let row = newBody.insertRow(); - let cell = row.insertCell(); - cell.innerHTML = clause; - cell = row.insertCell(); - let html = '' + sdoName + ''; - for (let i = 1; i < ids.length; ++i) { - html += ' (' + (i + 1) + ')'; - } - cell.innerHTML = html; - }); - this.$table.removeChild(this.$tableBody); - this.$tableBody = newBody; - this.$table.appendChild(this.$tableBody); - }, -}; - -let Toolbox = { - init() { - this.$outer = document.createElement('div'); - this.$outer.classList.add('toolbox-container'); - this.$container = document.createElement('div'); - this.$container.classList.add('toolbox'); - this.$outer.appendChild(this.$container); - this.$permalink = document.createElement('a'); - this.$permalink.textContent = 'Permalink'; - this.$pinLink = document.createElement('a'); - this.$pinLink.textContent = 'Pin'; - this.$pinLink.setAttribute('href', '#'); - this.$pinLink.addEventListener('click', e => { - e.preventDefault(); - e.stopPropagation(); - menu.togglePinEntry(this.entry.id); - }); - - this.$refsLink = document.createElement('a'); - this.$refsLink.setAttribute('href', '#'); - this.$refsLink.addEventListener('click', e => { - e.preventDefault(); - e.stopPropagation(); - referencePane.showReferencesFor(this.entry); - }); - this.$container.appendChild(this.$permalink); - this.$container.appendChild(this.$pinLink); - this.$container.appendChild(this.$refsLink); - document.body.appendChild(this.$outer); - }, - - activate(el, entry, target) { - if (el === this._activeEl) return; - sdoBox.deactivate(); - this.active = true; - this.entry = entry; - this.$outer.classList.add('active'); - this.top = el.offsetTop - this.$outer.offsetHeight; - this.left = el.offsetLeft - 10; - this.$outer.setAttribute('style', 'left: ' + this.left + 'px; top: ' + this.top + 'px'); - this.updatePermalink(); - this.updateReferences(); - this._activeEl = el; - if (this.top < document.body.scrollTop && el === target) { - // don't scroll unless it's a small thing (< 200px) - this.$outer.scrollIntoView(); - } - }, - - updatePermalink() { - this.$permalink.setAttribute('href', makeLinkToId(this.entry.id)); - }, - - updateReferences() { - this.$refsLink.textContent = `References (${this.entry.referencingIds.length})`; - }, - - activateIfMouseOver(e) { - let ref = this.findReferenceUnder(e.target); - if (ref && (!this.active || e.pageY > this._activeEl.offsetTop)) { - let entry = menu.search.biblio.byId[ref.id]; - this.activate(ref.element, entry, e.target); - } else if ( - this.active && - (e.pageY < this.top || e.pageY > this._activeEl.offsetTop + this._activeEl.offsetHeight) - ) { - this.deactivate(); - } - }, - - findReferenceUnder(el) { - while (el) { - let parent = el.parentNode; - if (el.nodeName === 'EMU-RHS' || el.nodeName === 'EMU-PRODUCTION') { - return null; - } - if ( - el.nodeName === 'H1' && - parent.nodeName.match(/EMU-CLAUSE|EMU-ANNEX|EMU-INTRO/) && - parent.id - ) { - return { element: el, id: parent.id }; - } else if (el.nodeName === 'EMU-NT') { - if ( - parent.nodeName === 'EMU-PRODUCTION' && - parent.id && - parent.id[0] !== '_' && - parent.firstElementChild === el - ) { - // return the LHS non-terminal element - return { element: el, id: parent.id }; - } - return null; - } else if ( - el.nodeName.match(/EMU-(?!CLAUSE|XREF|ANNEX|INTRO)|DFN/) && - el.id && - el.id[0] !== '_' - ) { - if ( - el.nodeName === 'EMU-FIGURE' || - el.nodeName === 'EMU-TABLE' || - el.nodeName === 'EMU-EXAMPLE' - ) { - // return the figcaption element - return { element: el.children[0].children[0], id: el.id }; - } else { - return { element: el, id: el.id }; - } - } - el = parent; - } - }, - - deactivate() { - this.$outer.classList.remove('active'); - this._activeEl = null; - this.active = false; - }, -}; - -function sortByClauseNumber(clause1, clause2) { - let c1c = clause1.number.split('.'); - let c2c = clause2.number.split('.'); - - for (let i = 0; i < c1c.length; i++) { - if (i >= c2c.length) { - return 1; - } - - let c1 = c1c[i]; - let c2 = c2c[i]; - let c1cn = Number(c1); - let c2cn = Number(c2); - - if (Number.isNaN(c1cn) && Number.isNaN(c2cn)) { - if (c1 > c2) { - return 1; - } else if (c1 < c2) { - return -1; - } - } else if (!Number.isNaN(c1cn) && Number.isNaN(c2cn)) { - return -1; - } else if (Number.isNaN(c1cn) && !Number.isNaN(c2cn)) { - return 1; - } else if (c1cn > c2cn) { - return 1; - } else if (c1cn < c2cn) { - return -1; - } - } - - if (c1c.length === c2c.length) { - return 0; - } - return -1; -} - -function makeLinkToId(id) { - let hash = '#' + id; - if (typeof idToSection === 'undefined' || !idToSection[id]) { - return hash; - } - let targetSec = idToSection[id]; - return (targetSec === 'index' ? './' : targetSec + '.html') + hash; -} - -function doShortcut(e) { - if (!(e.target instanceof HTMLElement)) { - return; - } - let target = e.target; - let name = target.nodeName.toLowerCase(); - if (name === 'textarea' || name === 'input' || name === 'select' || target.isContentEditable) { - return; - } - if (e.key === 'm' && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey && usesMultipage) { - let pathParts = location.pathname.split('/'); - let hash = location.hash; - if (pathParts[pathParts.length - 2] === 'multipage') { - if (hash === '') { - let sectionName = pathParts[pathParts.length - 1]; - if (sectionName.endsWith('.html')) { - sectionName = sectionName.slice(0, -5); - } - if (idToSection['sec-' + sectionName] !== undefined) { - hash = '#sec-' + sectionName; - } - } - location = pathParts.slice(0, -2).join('/') + '/' + hash; - } else { - location = 'multipage/' + hash; - } - } -} - -function init() { - menu = new Menu(); - let $container = document.getElementById('spec-container'); - $container.addEventListener( - 'mouseover', - debounce(e => { - Toolbox.activateIfMouseOver(e); - }) - ); - document.addEventListener( - 'keydown', - debounce(e => { - if (e.code === 'Escape' && Toolbox.active) { - Toolbox.deactivate(); - } - }) - ); -} - -document.addEventListener('keypress', doShortcut); - -document.addEventListener('DOMContentLoaded', () => { - Toolbox.init(); - referencePane.init(); -}); - -'use strict'; -let decimalBullet = Array.from({ length: 100 }, (a, i) => '' + (i + 1)); -let alphaBullet = Array.from({ length: 26 }, (a, i) => String.fromCharCode('a'.charCodeAt(0) + i)); - -// prettier-ignore -let romanBullet = ['i', 'ii', 'iii', 'iv', 'v', 'vi', 'vii', 'viii', 'ix', 'x', 'xi', 'xii', 'xiii', 'xiv', 'xv', 'xvi', 'xvii', 'xviii', 'xix', 'xx', 'xxi', 'xxii', 'xxiii', 'xxiv', 'xxv']; -// prettier-ignore -let bullets = [decimalBullet, alphaBullet, romanBullet, decimalBullet, alphaBullet, romanBullet]; - -function addStepNumberText(ol, parentIndex) { - for (let i = 0; i < ol.children.length; ++i) { - let child = ol.children[i]; - let index = parentIndex.concat([i]); - let applicable = bullets[Math.min(index.length - 1, 5)]; - let span = document.createElement('span'); - span.textContent = (applicable[i] || '?') + '. '; - span.style.fontSize = '0'; - span.setAttribute('aria-hidden', 'true'); - child.prepend(span); - let sublist = child.querySelector('ol'); - if (sublist != null) { - addStepNumberText(sublist, index); - } - } -} -document.addEventListener('DOMContentLoaded', () => { - document.querySelectorAll('emu-alg > ol').forEach(ol => { - addStepNumberText(ol, []); - }); -}); - -let sdoMap = JSON.parse(`{}`); -let biblio = JSON.parse(`{"refsByClause":{"editorial-conventions":["_ref_0","_ref_1","_ref_2","_ref_3","_ref_4","_ref_5","_ref_6","_ref_7","_ref_8","_ref_9","_ref_10","_ref_11","_ref_12"],"metadata":["_ref_13","_ref_14"],"emu-alg":["_ref_15","_ref_22"],"emu-xref":["_ref_16","_ref_17","_ref_18","_ref_19"],"definitions":["_ref_20","_ref_21"],"emu-not-ref":["_ref_23"],"grammar":["_ref_24","_ref_25"]},"entries":[{"type":"clause","id":"intro","aoid":null,"titleHTML":"Ecmarkup","number":"","referencingIds":[]},{"type":"clause","id":"getting-started","aoid":null,"titleHTML":"Getting Started","number":"1","referencingIds":[]},{"type":"table","id":"build-options","node":{},"number":1,"caption":"Table 1: Build options","referencingIds":["_ref_13"]},{"type":"table","id":"document-options","node":{},"number":2,"caption":"Table 2: Document options","referencingIds":["_ref_14"]},{"type":"clause","id":"useful-options","aoid":null,"titleHTML":"Options","number":"2","referencingIds":[]},{"type":"clause","id":"stylesheets-and-scripts","aoid":null,"titleHTML":"Stylesheets and Scripts","number":"3","referencingIds":[]},{"type":"table","id":"emd-overview","node":{},"number":4,"caption":"Table 4: Inline styles/conventions","referencingIds":["_ref_4"]},{"type":"clause","id":"editorial-conventions","aoid":null,"titleHTML":"Editorial Conventions","number":"4","referencingIds":[]},{"type":"clause","id":"metadata","aoid":null,"titleHTML":"Metadata","number":"5","referencingIds":[]},{"type":"clause","id":"emu-intro","aoid":null,"titleHTML":"emu-intro","number":"6.1","referencingIds":["_ref_1"]},{"type":"clause","id":"example-normative-optional","aoid":null,"titleHTML":"Example Normative Optional Clause","number":"6.2.1","referencingIds":[]},{"type":"clause","id":"emu-clause","aoid":null,"titleHTML":"emu-clause","number":"6.2","referencingIds":["_ref_0","_ref_16"]},{"type":"clause","id":"emu-annex","aoid":null,"titleHTML":"emu-annex","number":"6.3","referencingIds":["_ref_2"]},{"type":"clause","id":"clauses","aoid":null,"titleHTML":"Clauses","number":"6","referencingIds":[]},{"type":"term","term":"swordfish","refId":"definitions","id":"swordfish","referencingIds":["_ref_20","_ref_21"]},{"type":"clause","id":"definitions","aoid":null,"titleHTML":"Definitions","number":"7","referencingIds":[]},{"type":"step","id":"replace-me","stepNumbers":[2,1],"referencingIds":["_ref_15"]},{"type":"op","aoid":"EmuAlg","refId":"emu-alg","referencingIds":[]},{"type":"clause","id":"emu-alg","aoid":"EmuAlg","titleHTML":"emu-alg","number":"8","referencingIds":["_ref_3","_ref_22"]},{"type":"clause","id":"emu-eqn","aoid":null,"titleHTML":"emu-eqn","number":"9","referencingIds":["_ref_5"]},{"type":"clause","id":"emu-note","aoid":null,"titleHTML":"emu-note","number":"10","referencingIds":["_ref_6","_ref_17"]},{"type":"step","id":"example-step-label","stepNumbers":[1],"referencingIds":["_ref_19"]},{"type":"clause","id":"emu-xref","aoid":null,"titleHTML":"emu-xref","number":"11","referencingIds":["_ref_12"]},{"type":"clause","id":"emu-not-ref","aoid":null,"titleHTML":"emu-not-ref","number":"12","referencingIds":["_ref_23"]},{"type":"clause","id":"emu-figure","aoid":null,"titleHTML":"emu-figure","number":"13","referencingIds":["_ref_7"]},{"type":"clause","id":"emu-table","aoid":null,"titleHTML":"emu-table","number":"14","referencingIds":["_ref_8"]},{"type":"clause","id":"emu-example","aoid":null,"titleHTML":"emu-example","number":"15","referencingIds":["_ref_9"]},{"type":"clause","id":"emu-biblio","aoid":null,"titleHTML":"emu-biblio","number":"16","referencingIds":["_ref_18"]},{"type":"production","id":"prod-WhileStatement","name":"WhileStatement","referencingIds":[]},{"type":"production","id":"prod-ArgumentList","name":"ArgumentList","referencingIds":["_ref_24"]},{"type":"production","id":"prod-IterationStatement","name":"IterationStatement","referencingIds":[]},{"type":"production","id":"prod-Identifier","name":"Identifier","referencingIds":[]},{"type":"production","id":"prod-SourceCharacter","name":"SourceCharacter","referencingIds":[]},{"type":"production","id":"prod-ExpressionStatement","name":"ExpressionStatement","referencingIds":["_ref_25"]},{"type":"production","id":"prod-DecimalDigit","name":"DecimalDigit","referencingIds":[]},{"type":"production","id":"prod-StatementList","name":"StatementList","referencingIds":[]},{"type":"clause","id":"emu-grammar","aoid":null,"titleHTML":"emu-grammar","number":"17.1","referencingIds":["_ref_10"]},{"type":"clause","id":"emu-production","aoid":null,"titleHTML":"emu-production","number":"17.2","referencingIds":["_ref_11"]},{"type":"clause","id":"emu-rhs","aoid":null,"titleHTML":"emu-rhs","number":"17.3","referencingIds":[]},{"type":"clause","id":"emu-nt","aoid":null,"titleHTML":"emu-nt","number":"17.4","referencingIds":[]},{"type":"clause","id":"emu-t","aoid":null,"titleHTML":"emu-t","number":"17.5","referencingIds":[]},{"type":"clause","id":"emu-gmod","aoid":null,"titleHTML":"emu-gmod","number":"17.6","referencingIds":[]},{"type":"clause","id":"emu-gann","aoid":null,"titleHTML":"emu-gann","number":"17.7","referencingIds":[]},{"type":"clause","id":"emu-gprose","aoid":null,"titleHTML":"emu-gprose","number":"17.8","referencingIds":[]},{"type":"clause","id":"emu-prodref","aoid":null,"titleHTML":"emu-prodref","number":"17.9","referencingIds":[]},{"type":"clause","id":"grammar","aoid":null,"titleHTML":"Specifying Grammar","number":"17","referencingIds":[]},{"type":"clause","id":"imports","aoid":null,"titleHTML":"Imports","number":"18","referencingIds":[]},{"type":"clause","id":"oldids","aoid":null,"titleHTML":"Old IDs","number":"19.1","referencingIds":[]},{"type":"clause","id":"ins-del","aoid":null,"title":"ins & del","titleHTML":"ins & del","number":"19.2","referencingIds":[]},{"type":"clause","id":"pre-code","aoid":null,"titleHTML":"Code Listings","number":"19.3","referencingIds":[]},{"type":"clause","id":"css","aoid":null,"title":"Other Styles & Conventions","titleHTML":"Other Styles & Conventions","number":"19","referencingIds":[]},{"type":"term","term":"example","refId":"emu-not-ref","referencingIds":[]}]}`); -;let usesMultipage = false \ No newline at end of file diff --git a/docs/elements.css b/docs/elements.css deleted file mode 100644 index 183c1af7..00000000 --- a/docs/elements.css +++ /dev/null @@ -1,1177 +0,0 @@ -body { - display: flex; - font-size: 18px; - line-height: 1.5; - font-family: Cambria, Palatino Linotype, Palatino, Liberation Serif, serif; - padding: 0; - margin: 0; - color: #111; -} - -#spec-container { - padding: 0 20px; - flex-grow: 1; - flex-basis: 66%; - box-sizing: border-box; - overflow: hidden; - padding-bottom: 1em; -} - -body.oldtoc { - margin: 0 auto; -} - -a { - text-decoration: none; - color: #206ca7; -} - -a:visited { - color: #206ca7; -} - -a:hover { - text-decoration: underline; - color: #239dee; -} - -code { - font-weight: bold; - font-family: Consolas, Monaco, monospace; - white-space: pre; -} - -pre code { - font-weight: inherit; -} - -pre code.hljs { - background-color: #fff; - margin: 0; - padding: 0; -} - -ol.toc { - list-style: none; - padding-left: 0; -} - -ol.toc ol.toc { - padding-left: 2ex; - list-style: none; -} - -var { - color: #2aa198; - transition: background-color 0.25s ease; - cursor: pointer; -} - -var.referenced0 { - color: inherit; - background-color: #ffff33; - box-shadow: 0 0 0 2px #ffff33; -} -var.referenced1 { - color: inherit; - background-color: #ff87a2; - box-shadow: 0 0 0 2px #ff87a2; -} -var.referenced2 { - color: inherit; - background-color: #96e885; - box-shadow: 0 0 0 2px #96e885; -} -var.referenced3 { - color: inherit; - background-color: #3eeed2; - box-shadow: 0 0 0 2px #3eeed2; -} -var.referenced4 { - color: inherit; - background-color: #eacfb6; - box-shadow: 0 0 0 2px #eacfb6; -} -var.referenced5 { - color: inherit; - background-color: #82ddff; - box-shadow: 0 0 0 2px #82ddff; -} -var.referenced6 { - color: inherit; - background-color: #ffbcf2; - box-shadow: 0 0 0 2px #ffbcf2; -} - -emu-const { - font-family: sans-serif; -} - -emu-val { - font-weight: bold; -} - -/* depth 1 */ -emu-alg ol, -/* depth 4 */ -emu-alg ol ol ol ol, -emu-alg ol.nested-thrice, -emu-alg ol.nested-twice ol, -emu-alg ol.nested-once ol ol { - list-style-type: decimal; -} - -/* depth 2 */ -emu-alg ol ol, -emu-alg ol.nested-once, -/* depth 5 */ -emu-alg ol ol ol ol ol, -emu-alg ol.nested-four-times, -emu-alg ol.nested-thrice ol, -emu-alg ol.nested-twice ol ol, -emu-alg ol.nested-once ol ol ol { - list-style-type: lower-alpha; -} - -/* depth 3 */ -emu-alg ol ol ol, -emu-alg ol.nested-twice, -emu-alg ol.nested-once ol, -/* depth 6 */ -emu-alg ol ol ol ol ol ol, -emu-alg ol.nested-lots, -emu-alg ol.nested-four-times ol, -emu-alg ol.nested-thrice ol ol, -emu-alg ol.nested-twice ol ol ol, -emu-alg ol.nested-once ol ol ol ol, -/* depth 7+ */ -emu-alg ol.nested-lots ol { - list-style-type: lower-roman; -} - -emu-eqn { - display: block; - margin-left: 4em; -} - -emu-eqn.inline { - display: inline; - margin: 0; -} - -emu-eqn div:first-child { - margin-left: -2em; -} - -emu-note { - margin: 1em 0; - display: flex; - flex-direction: row; - color: inherit; - border-left: 5px solid #52e052; - background: #e9fbe9; - padding: 10px 10px 10px 0; -} - -emu-note > span.note { - flex-basis: 100px; - min-width: 100px; - flex-grow: 0; - flex-shrink: 1; - text-transform: uppercase; - padding-left: 5px; -} - -emu-note[type='editor'] { - border-left-color: #faa; -} - -emu-note > div.note-contents { - flex-grow: 1; - flex-shrink: 1; - overflow: auto; -} - -emu-note > div.note-contents > p:first-of-type { - margin-top: 0; -} - -emu-note > div.note-contents > p:last-of-type { - margin-bottom: 0; -} - -emu-table td code { - white-space: normal; -} - -emu-figure { - display: block; -} - -emu-example { - display: block; - margin: 1em 3em; -} - -emu-example figure figcaption { - margin-top: 0.5em; - text-align: left; -} - -emu-figure figure, -emu-example figure, -emu-table figure { - display: flex; - flex-direction: column; - align-items: center; -} - -emu-production { - display: block; -} - -emu-grammar[type='example'] emu-production, -emu-grammar[type='definition'] emu-production { - margin-top: 1em; - margin-bottom: 1em; - margin-left: 5ex; -} - -emu-grammar.inline, -emu-production.inline, -emu-grammar.inline emu-production emu-rhs, -emu-production.inline emu-rhs, -emu-grammar[collapsed] emu-production emu-rhs { - display: inline; - padding-left: 1ex; - margin-left: 0; -} - -emu-production[collapsed] emu-rhs { - display: inline; - padding-left: 0.5ex; - margin-left: 0; -} - -emu-grammar[collapsed] emu-production, -emu-production[collapsed] { - margin: 0; -} - -emu-constraints { - font-size: 0.75em; - margin-right: 0.5ex; -} - -emu-gann { - margin-right: 0.5ex; -} - -emu-gann emu-t:last-child, -emu-gann emu-gprose:last-child, -emu-gann emu-nt:last-child { - margin-right: 0; -} - -emu-geq { - margin-left: 0.5ex; - font-weight: bold; -} - -emu-oneof { - font-weight: bold; - margin-left: 0.5ex; -} - -emu-nt { - display: inline-block; - font-style: italic; - white-space: nowrap; - text-indent: 0; -} - -emu-nt a, -emu-nt a:visited { - color: #333; -} - -emu-rhs emu-nt { - margin-right: 0.5ex; -} - -emu-t { - display: inline-block; - font-family: monospace; - font-weight: bold; - white-space: nowrap; - text-indent: 0; -} - -emu-production emu-t { - margin-right: 0.5ex; -} - -emu-rhs { - display: block; - padding-left: 75px; - text-indent: -25px; -} - -emu-production:not([collapsed]) emu-rhs { - border: 0.2ex dashed transparent; -} - -emu-production:not([collapsed]) emu-rhs:hover { - border-color: #888; - background-color: #f0f0f0; -} - -emu-mods { - font-size: 0.85em; - vertical-align: sub; - font-style: normal; - font-weight: normal; -} - -emu-params, -emu-opt { - margin-right: 1ex; - font-family: monospace; -} - -emu-params, -emu-constraints { - color: #2aa198; -} - -emu-opt { - color: #b58900; -} - -emu-gprose { - font-size: 0.9em; - font-family: Helvetica, Arial, sans-serif; -} - -emu-production emu-gprose { - margin-right: 1ex; -} - -h1.shortname { - color: #f60; - font-size: 1.5em; - margin: 0; -} - -h1.version { - color: #f60; - font-size: 1.5em; -} - -h1.title { - color: #f60; -} - -h1, -h2, -h3, -h4, -h5, -h6 { - position: relative; -} - -h1 .secnum { - text-decoration: none; - margin-right: 5px; -} - -h1 span.title { - order: 2; -} - -h1 { - font-size: 2.67em; - margin-bottom: 0; - line-height: 1em; -} -h2 { - font-size: 2em; -} -h3 { - font-size: 1.56em; -} -h4 { - font-size: 1.25em; -} -h5 { - font-size: 1.11em; -} -h6 { - font-size: 1em; -} - -pre code.hljs { - background: transparent; -} - -emu-clause[id], -emu-annex[id], -emu-intro[id] { - scroll-margin-top: 2ex; -} - -emu-intro h1, -emu-clause h1, -emu-annex h1 { - font-size: 2em; -} -emu-intro h2, -emu-clause h2, -emu-annex h2 { - font-size: 1.56em; -} -emu-intro h3, -emu-clause h3, -emu-annex h3 { - font-size: 1.25em; -} -emu-intro h4, -emu-clause h4, -emu-annex h4 { - font-size: 1.11em; -} -emu-intro h5, -emu-clause h5, -emu-annex h5 { - font-size: 1em; -} -emu-intro h6, -emu-clause h6, -emu-annex h6 { - font-size: 0.9em; -} -emu-intro emu-intro h1, -emu-clause emu-clause h1, -emu-annex emu-annex h1 { - font-size: 1.56em; -} -emu-intro emu-intro h2, -emu-clause emu-clause h2, -emu-annex emu-annex h2 { - font-size: 1.25em; -} -emu-intro emu-intro h3, -emu-clause emu-clause h3, -emu-annex emu-annex h3 { - font-size: 1.11em; -} -emu-intro emu-intro h4, -emu-clause emu-clause h4, -emu-annex emu-annex h4 { - font-size: 1em; -} -emu-intro emu-intro h5, -emu-clause emu-clause h5, -emu-annex emu-annex h5 { - font-size: 0.9em; -} -emu-intro emu-intro emu-intro h1, -emu-clause emu-clause emu-clause h1, -emu-annex emu-annex emu-annex h1 { - font-size: 1.25em; -} -emu-intro emu-intro emu-intro h2, -emu-clause emu-clause emu-clause h2, -emu-annex emu-annex emu-annex h2 { - font-size: 1.11em; -} -emu-intro emu-intro emu-intro h3, -emu-clause emu-clause emu-clause h3, -emu-annex emu-annex emu-annex h3 { - font-size: 1em; -} -emu-intro emu-intro emu-intro h4, -emu-clause emu-clause emu-clause h4, -emu-annex emu-annex emu-annex h4 { - font-size: 0.9em; -} -emu-intro emu-intro emu-intro emu-intro h1, -emu-clause emu-clause emu-clause emu-clause h1, -emu-annex emu-annex emu-annex emu-annex h1 { - font-size: 1.11em; -} -emu-intro emu-intro emu-intro emu-intro h2, -emu-clause emu-clause emu-clause emu-clause h2, -emu-annex emu-annex emu-annex emu-annex h2 { - font-size: 1em; -} -emu-intro emu-intro emu-intro emu-intro h3, -emu-clause emu-clause emu-clause emu-clause h3, -emu-annex emu-annex emu-annex emu-annex h3 { - font-size: 0.9em; -} -emu-intro emu-intro emu-intro emu-intro emu-intro h1, -emu-clause emu-clause emu-clause emu-clause emu-clause h1, -emu-annex emu-annex emu-annex emu-annex emu-annex h1 { - font-size: 1em; -} -emu-intro emu-intro emu-intro emu-intro emu-intro h2, -emu-clause emu-clause emu-clause emu-clause emu-clause h2, -emu-annex emu-annex emu-annex emu-annex emu-annex h2 { - font-size: 0.9em; -} -emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro h1, -emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause h1, -emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex h1 { - font-size: 0.9em; -} - -emu-clause, -emu-intro, -emu-annex { - display: block; -} - -/* these values are twice the font-size for the

    titles for clauses */ -emu-intro, -emu-clause, -emu-annex { - margin-top: 4em; -} -emu-intro emu-intro, -emu-clause emu-clause, -emu-annex emu-annex { - margin-top: 3.12em; -} -emu-intro emu-intro emu-intro, -emu-clause emu-clause emu-clause, -emu-annex emu-annex emu-annex { - margin-top: 2.5em; -} -emu-intro emu-intro emu-intro emu-intro, -emu-clause emu-clause emu-clause emu-clause, -emu-annex emu-annex emu-annex emu-annex { - margin-top: 2.22em; -} -emu-intro emu-intro emu-intro emu-intro emu-intro, -emu-clause emu-clause emu-clause emu-clause emu-clause, -emu-annex emu-annex emu-annex emu-annex emu-annex { - margin-top: 2em; -} -emu-intro emu-intro emu-intro emu-intro emu-intro emu-intro, -emu-clause emu-clause emu-clause emu-clause emu-clause emu-clause, -emu-annex emu-annex emu-annex emu-annex emu-annex emu-annex { - margin-top: 1.8em; -} - -#spec-container > emu-intro:first-of-type, -#spec-container > emu-clause:first-of-type, -#spec-container > emu-annex:first-of-type { - margin-top: 0; -} - -/* Figures and tables */ -figure { - display: block; - margin: 1em 0 3em 0; -} -figure object { - display: block; - margin: 0 auto; -} -figure table.real-table { - margin: 0 auto; -} -figure figcaption { - display: block; - color: #555555; - font-weight: bold; - text-align: center; -} - -emu-table table { - margin: 0 auto; -} - -emu-table table, -table.real-table { - border-collapse: collapse; -} - -emu-table td, -emu-table th, -table.real-table td, -table.real-table th { - border: 1px solid black; - padding: 0.4em; - vertical-align: baseline; -} -emu-table th, -emu-table thead td, -table.real-table th { - background-color: #eeeeee; -} - -emu-table td { - background: #fff; -} - -/* Note: the left content edges of table.lightweight-table >tbody >tr >td - and div.display line up. */ -table.lightweight-table { - border-collapse: collapse; - margin: 0 0 0 1.5em; -} -table.lightweight-table td, -table.lightweight-table th { - border: none; - padding: 0 0.5em; - vertical-align: baseline; -} - -/* diff styles */ -ins { - background-color: #e0f8e0; - text-decoration: none; - border-bottom: 1px solid #396; -} - -del { - background-color: #fee; -} - -ins.block, -del.block, -emu-production > ins, -emu-production > del, -emu-grammar > ins, -emu-grammar > del { - display: block; -} -emu-rhs > ins, -emu-rhs > del { - display: inline; -} - -tr.ins > td > ins { - border-bottom: none; -} - -tr.ins > td { - background-color: #e0f8e0; -} - -tr.del > td { - background-color: #fee; -} - -/* Menu Styles */ -#menu-toggle { - font-size: 2em; - - position: fixed; - top: 0; - left: 0; - width: 1.5em; - height: 1.5em; - z-index: 3; - visibility: hidden; - color: #1567a2; - background-color: #fff; - - line-height: 1.5em; - text-align: center; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - - cursor: pointer; -} - -#menu { - display: flex; - flex-direction: column; - width: 33%; - height: 100vh; - max-width: 500px; - box-sizing: border-box; - background-color: #ddd; - overflow: hidden; - transition: opacity 0.1s linear; - padding: 0 5px; - position: fixed; - left: 0; - top: 0; - border-right: 2px solid #bbb; - - z-index: 2; -} - -#menu-spacer { - flex-basis: 33%; - max-width: 500px; - flex-grow: 0; - flex-shrink: 0; -} - -#menu a { - color: #1567a2; -} - -#menu.active { - display: flex; - opacity: 1; - z-index: 2; -} - -#menu-pins { - flex-grow: 1; - display: none; -} - -#menu-pins.active { - display: block; -} - -#menu-pins-list { - margin: 0; - padding: 0; - counter-reset: pins-counter; -} - -#menu-pins-list > li:before { - content: counter(pins-counter); - counter-increment: pins-counter; - display: inline-block; - width: 25px; - text-align: center; - border: 1px solid #bbb; - padding: 2px; - margin: 4px; - box-sizing: border-box; - line-height: 1em; - background-color: #ccc; - border-radius: 4px; -} -#menu-toc > ol { - padding: 0; - flex-grow: 1; -} - -#menu-toc > ol li { - padding: 0; -} - -#menu-toc > ol, -#menu-toc > ol ol { - list-style-type: none; - margin: 0; - padding: 0; -} - -#menu-toc > ol ol { - padding-left: 0.75em; -} - -#menu-toc li { - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; -} - -#menu-toc .item-toggle { - display: inline-block; - transform: rotate(-45deg) translate(-5px, -5px); - transition: transform 0.1s ease; - text-align: center; - width: 20px; - - color: #aab; - - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - - cursor: pointer; -} - -#menu-toc .item-toggle-none { - display: inline-block; - width: 20px; -} - -#menu-toc li.active > .item-toggle { - transform: rotate(45deg) translate(-5px, -5px); -} - -#menu-toc li > ol { - display: none; -} - -#menu-toc li.active > ol { - display: block; -} - -#menu-toc li.revealed > a { - background-color: #bbb; - font-weight: bold; - /* - background-color: #222; - color: #c6d8e4; - */ -} - -#menu-toc li.revealed-leaf > a { - color: #206ca7; - /* - background-color: #222; - color: #c6d8e4; - */ -} - -#menu-toc li.revealed > .item-toggle { - transform: rotate(45deg) translate(-5px, -5px); -} - -#menu-toc li.revealed > ol { - display: block; -} - -#menu-toc li > a { - padding: 2px 5px; -} - -#menu > * { - margin-bottom: 5px; -} - -.menu-pane-header { - padding: 0 5px; - text-transform: uppercase; - background-color: #aaa; - color: #335; - font-weight: bold; - letter-spacing: 2px; - flex-grow: 0; - flex-shrink: 0; - font-size: 0.8em; -} - -.menu-pane-header emu-opt, -.menu-pane-header emu-t, -.menu-pane-header emu-nt { - margin-right: 0px; - display: inline; - color: inherit; -} - -.menu-pane-header emu-rhs { - display: inline; - padding-left: 0px; - text-indent: 0px; -} - -.menu-pane-header emu-geq { - margin-left: 0px; -} - -a.menu-pane-header-production { - color: inherit; -} - -.menu-pane-header-production { - text-transform: none; - letter-spacing: 1.5px; - padding-left: 0.5em; -} - -#menu-toc { - display: flex; - flex-direction: column; - width: 100%; - overflow: hidden; - flex-grow: 1; -} - -#menu-toc ol.toc { - overflow-x: hidden; - overflow-y: auto; -} - -#menu-search { - position: relative; - flex-grow: 0; - flex-shrink: 0; - width: 100%; - - display: flex; - flex-direction: column; - - max-height: 300px; -} - -#menu-trace-list { - display: none; -} - -#menu-search-box { - box-sizing: border-box; - display: block; - width: 100%; - margin: 5px 0 0 0; - font-size: 1em; - padding: 2px; - background-color: #bbb; - border: 1px solid #999; -} - -#menu-search-results { - overflow-x: hidden; - overflow-y: auto; -} - -li.menu-search-result-clause:before { - content: 'clause'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75%; -} -li.menu-search-result-op:before { - content: 'op'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75%; -} - -li.menu-search-result-prod:before { - content: 'prod'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75%; -} - -li.menu-search-result-term:before { - content: 'term'; - width: 40px; - display: inline-block; - text-align: right; - padding-right: 1ex; - color: #666; - font-size: 75%; -} - -#menu-search-results ul { - padding: 0 5px; - margin: 0; -} - -#menu-search-results li { - white-space: nowrap; - text-overflow: ellipsis; -} - -#menu-trace-list { - counter-reset: item; - margin: 0 0 0 20px; - padding: 0; -} -#menu-trace-list li { - display: block; - white-space: nowrap; -} - -#menu-trace-list li .secnum:after { - content: ' '; -} -#menu-trace-list li:before { - content: counter(item) ' '; - background-color: #222; - counter-increment: item; - color: #999; - width: 20px; - height: 20px; - line-height: 20px; - display: inline-block; - text-align: center; - margin: 2px 4px 2px 0; -} - -@media (max-width: 1000px) { - body { - margin: 0; - display: block; - } - - #menu { - display: none; - padding-top: 3em; - width: 450px; - } - - #menu.active { - position: fixed; - height: 100%; - left: 0; - top: 0; - right: 300px; - } - - #menu-toggle { - visibility: visible; - } - - #spec-container { - padding: 0 5px; - } - - #references-pane-spacer { - display: none; - } -} - -@media only screen and (max-width: 800px) { - #menu { - width: 100%; - } - - h1 .secnum:empty { - margin: 0; - padding: 0; - } -} - -/* Toolbox */ -.toolbox-container { - position: absolute; - display: none; - padding-bottom: 7px; -} - -.toolbox-container.active { - display: inline-block; -} - -.toolbox { - position: relative; - background: #ddd; - border: 1px solid #aaa; - color: #eee; - padding: 5px; - border-radius: 3px; -} - -.toolbox a { - text-decoration: none; - padding: 0 5px; -} - -.toolbox a:hover { - text-decoration: underline; -} - -.toolbox:after, -.toolbox:before { - top: 100%; - left: 15px; - border: solid transparent; - content: ' '; - height: 0; - width: 0; - position: absolute; - pointer-events: none; -} - -.toolbox:after { - border-color: rgba(0, 0, 0, 0); - border-top-color: #ddd; - border-width: 10px; - margin-left: -10px; -} -.toolbox:before { - border-color: rgba(204, 204, 204, 0); - border-top-color: #aaa; - border-width: 12px; - margin-left: -12px; -} - -#references-pane-container { - position: fixed; - bottom: 0; - left: 0; - right: 0; - height: 250px; - display: none; - background-color: #ddd; - z-index: 1; -} - -#references-pane-table-container { - overflow-x: hidden; - overflow-y: auto; -} - -#references-pane-spacer { - flex-basis: 33%; - max-width: 500px; -} - -#references-pane { - flex-grow: 1; - overflow: hidden; - display: flex; - flex-direction: column; -} - -#references-pane-container.active { - display: flex; -} - -#references-pane-close:after { - content: '✖'; - float: right; - cursor: pointer; -} - -#references-pane table tr td:first-child { - text-align: right; - padding-right: 5px; -} - -@media print { - #menu-toggle { - display: none; - } -} - -[normative-optional], -[legacy] { - border-left: 5px solid #ff6600; - padding: 0.5em; - display: block; - background: #ffeedd; -} - -.clause-attributes-tag { - text-transform: uppercase; - color: #884400; -} - -.clause-attributes-tag a { - color: #884400; -} diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 138506b4..00000000 --- a/docs/index.html +++ /dev/null @@ -1,621 +0,0 @@ - - -Ecmarkup -
    - - -

    Ecmarkup

    -

    Ecmarkup is a number of custom elements and a toolchain suitable for specifying semantics for ECMAScript and other programming languages.

    -

    Ecmarkup offers the following conveniences (among many others):

    -
      -
    • Ecmarkdown syntax for paragraphs and algorithms
    • -
    • Grammarkdown for specifying grammar
    • -
    • Terse markup for the authoring conventions used in ECMAScript specifications including clauses, notes, examples, figures, tables, and more.
    • -
    • Easy cross-references by element ID to clauses, abstract operations, examples, figures, tables, and etc. in the current document, ES6, and other specs.
    • -
    • Generates table of contents
    • -
    • Generates clause ids based on document position
    • -
    • Auto-links abstract operations and terms based on name with support for external bibliographies for cross-referencing between specs
    • -
    • Source code syntax highlighting inside pre code blocks
    • -
    -

    This document is itself written using Ecmarkup. Its source can be viewed on github.

    -
    - - -

    1 Getting Started

    -
    npm install -g ecmarkup
    -ecmarkup --help
    -ecmarkup spec.html out.html
    -  
    -
    - -

    2 Options

    -

    Build options and document options can be passed in via the command line or specified in the front-matter of your document.

    -
    Table 1: Build options
    - - - - - - - - - - - - -
    OptionDescription
    watchRebuild when files change
    verbosePrint verbose logging info
    biblioEmit a biblio file to the specified location
    assets"none" for no css/js, "inline" for inline css/js
    css-outEmit the Ecmarkup CSS file to the specified location
    js-outEmit the Ecmarkup JS file to the specified location
    lint-specEnforce some style and correctness checks
    lint-formatterThe eslint formatter to be used for printing warnings and errors when using --verbose. Either the name of a built-in eslint formatter or the package name of an installed eslint compatible formatter.
    strictExit with an error if there are warnings. Cannot be used with --watch
    -
    - -
    Table 2: Document options
    - - - - - - - - - - - - - - - -
    OptionDescription
    titleTitle of specification, for example ECMAScript 2016 or Async Functions.
    statusStatus of specification. Can be proposal, draft, or standard. Default is proposal.
    stageStage of proposal. Must be a number if provided, but is optional. Sets version to Stage N Draft, but can be overridden.
    versionVersion of specification, for example 6<sup>th</sup> Edition or Draft 1. Optional.
    dateDate the spec was generated. Used for various pieces of boilerplate that include dates. Defaults to today's date.
    shortnameShortname of specification, for example ECMA-262 or ECMA-402.
    locationURL of this specification. Use in conjunction with the biblio file to enable external specs to reference this one.
    copyrightEmit copyright and software license information. Boolean, default true.
    contributorsContributors 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.
    tocEmit table of contents. Boolean, default true.
    old-tocEmit the old style of table of contents. Boolean, default false.
    ecma-262-biblioLoad the ECMA-262 biblio file. Boolean, default true.
    -
    -
    - - -

    3 Stylesheets and Scripts

    -

    Ecmarkup requires css styles and, if you're using the sidebar table of contents, javascript as well. By default CSS and JS dependencies are inlined into the document. You can override this by setting assets to "none" (for example if you want to manually link to external assets). Passing cssOut and jsOut will write the respective files to disk at the given location.

    -
    - -

    4 Editorial Conventions

    -

    There are a large number of features in Ecmarkup. Detailed documentation can be found in later sections. This section provides a high-level overview of what capabilities are available and when to use them.

    - -
    Table 3: Structuring your Ecmarkup document
    - - - - - - - - - - - -
    Notational ConventionEcmarkup Functionality
    Clausesemu-clause, emu-intro, and emu-annex
    Algorithmsemu-alg with Ecmarkdown (see also Table 4). Equations such as Year Number use emu-eqn
    Notesemu-note
    Figures (such as images)emu-figure and emu-caption
    Tablesemu-table and emu-caption
    Examplesemu-example and emu-caption
    Grammaremu-grammar using Grammarkdown syntax or emu-production and child elements
    Cross-referencesemu-xref (can reference clauses, productions, abstract operations, tables, figuers, and examples)
    -
    - -

    There are also a number of elements and corresponding Ecmarkdown syntax to give inline styles to various parts of your document in accordance with ECMAScript conventions. More detail on Ecmarkdown syntax can be found on its readme.

    -
    Table 4: Inline styles/conventions
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Notational ConventionEcmarkdown SyntaxEcmarkup Functionality
    Variables, such as those in defined in algorithms, parameters in abstract operations, etc._variable_<var>variable</var>
    ECMAScript Language Type Values, eg. undefined, true, 1, "string", TypeError, etc.*TypeError*<emu-val>TypeError</emu-val>
    Specification types and their instances, eg. throw and empty.~throw~<emu-const>throw<emu-const>
    Source Code, eg. Function.prototype.`code`<code>code</code>
    Non-terminal references, eg. as FunctionDeclaration and FunctionExpression.|FunctionExpression|<emu-nt>FunctionExpression</emu-nt>
    -
    -
    - -

    5 Metadata

    -

    There are a number of settings that allow customizations or enable generation of boilerplate. Metadata can be included in the document and passed on the command line, for example --no-toc --title "Document 1". Metadata given on the command line takes precedence.

    -

    To add metadata to your document, use yaml syntax inside a <pre class=metadata> element somewhere in the root of your document.

    -

    All of the command line options can be provided in the metadata block. See Table 1 and Table 2 for a list (or consult --help).

    -

    Example document with metadata

    -
    <pre class=metadata>
    -Title: Document 1
    -toc: false
    -</pre>
    -
    - -

    6 Clauses

    -

    Clauses are referenced using their id and are numbered automatically based on document position. Ecmarkdown syntax can be used in descendent text nodes as well. Text nodes are parsed as Ecmarkdown Fragments.

    - - -

    6.1 emu-intro

    -

    Non-normative introductory information.

    - -

    Attributes

    -

    id: Clause id. Must be unique.

    -

    aoid: Abstract operation ID. A unique name identifying this clause as an abstract operation. Algorithm steps will auto-link calls to this abstract operation to this clause. If left blank, the aoid will be set to the id of this clause.

    -
    - - -

    6.2 emu-clause

    -

    Normative clause.

    - -

    Attributes

    -

    id: Clause id. Must be unique.

    -

    aoid: Abstract operation ID. A unique name identifying this clause as an abstract operation. Algorithm steps will auto-link calls to this abstract operation to this clause. If left blank, the aoid will be set to the id of this clause.

    -

    normative-optional: If present, the clause is Normative Optional.

    - -

    Example

    -

    Element

    -
    <emu-clause id="example-normative-optional" normative-optional>
    -  <h1>Example Normative Optional Clause</h1>
    -  <p>This clause is normative optional.</p>
    -</emu-clause>
    -

    Result

    -
    Normative Optional
    -

    6.2.1 Example Normative Optional Clause

    -

    This clause is normative optional.

    -
    -
    - - -

    6.3 emu-annex

    -

    Annex clause.

    - -

    Attributes

    -

    normative: If present, annex is normative. Default is non-normative.

    -

    id: Clause id. Must be unique.

    -

    aoid: Abstract operation ID. A unique name identifying this clause as an abstract operation. Algorithm steps will auto-link calls to this abstract operation to this clause. If left blank, the aoid will be set to the id of this clause.

    -
    -
    - - -

    7 Definitions

    -

    Terms can be defined using the <dfn> element. Any uses of that term will be automatically linked to the clause containing the definition, or, if the <dfn> element has an id, to the <dfn> itself. This can be suppressed with the emu-not-ref element.

    -

    When the term starts with a lowercase English letter, usages of the term with the first letter capitalized will also link.

    -

    Other variants of the term, such as plural forms, can be provided as a comma-seperated list in the variants attribute on the element.

    - -

    Example

    -
    <p>A <dfn id="swordfish" variants="swordfishes,broadbill,broadbills,Xiphias gladius">swordfish</dfn> is a large fish characterized by a long, pointed bill.</p>
    -<p>The Latin name for swordfishes, <em>Xiphias gladius</em>, comes from the Greek word "ξίφος" (xiphos, "sword") and from the Latin word "gladius" ("sword").</p>
    - - Result -

    A swordfish is large fish characterized by a long, pointed bill.

    -

    The Latin name for swordfishes, Xiphias gladius, comes from the Greek word "ξίφος" (xiphos, "sword") and from the Latin word "gladius" ("sword").

    -
    - - -

    8 emu-alg

    -

    Algorithm steps. Should not contain any HTML. The node's textContent is parsed as an Ecmarkdown document. Additionally, calls to abstract operations inside algorithm steps are automatically linked to their definitions by first checking for any clauses or algorithms with the appropriate "aoid" in the current spec, and afterwards checking any linked bibliography files.

    - -

    Example

    - Note
    The emu-alg clause has an aoid of "EmuAlg".
    -

    Element

    -
    <emu-alg aoid="EmuAlgExample">
    -  1. let _clauseAbstractOp_ be the result of calling EmuAlg()
    -  2. Step 2
    -    1. let _recurse_ be the result of calling EmuAlgExample(`true`)
    -    2. Return the result of evaluating this |NonTerminalProduction|
    -</emu-alg>
    -

    Result

    -
    1. let clauseAbstractOp be the result of calling EmuAlg()
    2. Step 2
      1. let recurse be the result of calling EmuAlgExample(true)
      2. Return the result of evaluating this NonTerminalProduction
    - -

    Replacement algorithms

    -

    Algorithms may be specified to replace a labeled step, in which case the algorithm will adopt the numbering of that step. For example:

    - -

    Element

    -
    <emu-alg>
    -  1. Step.
    -  1. Step 2.
    -    1. [id="replace-me"] Replaced.
    -      1. Substep.
    -</emu-alg>
    -<p>The following is an alernative definition of step <emu-xref href="#replace-me"></emu-xref>.</p>
    -<emu-alg replaces-step="replace-me">
    -  1. Replacement.
    -    1. Substep.
    -</emu-alg>
    -

    Result

    -
    1. Step.
    2. Step 2.
      1. Replaced.
        1. Substep.
    -

    The following is an alernative definition of step 2.a.

    -
    1. Replacement.
      1. Substep.
    -
    - - -

    9 emu-eqn

    -

    An equation, similar to those found in ES6 Year Number.

    - -

    Attributes

    -

    aoid: Required: the abstract operation id that this equation defines.

    -

    id: Optional id. If present, links will go directly to the eqn definition. Otherwise, links go to the parent clause.

    -
    - -

    10 emu-note

    -

    Non-normative explanatory text. Comes in two flavors - regular notes and Editor's notes. Regular notes are intended for the implementers and end users of this specification. Editor's notes are notes to and from the Editors and will generally be removed prior to a specification being finalized and ratified.

    - -

    Attributes

    -

    type: The type of note, either blank or "editor".

    - -

    Example

    -

    For authentication only, servers and clients MUST support SASL Salted Challenge Response Authentication Mechanism [SCRAM].

    - Note
    But we know you won't.
    - Editor's Note
    This joke brought to you by RFC6919.
    -
    - - -

    11 emu-xref

    -

    Cross-reference another clause, production, note, example, abstract operation, or labeled step. If the text content of this element is empty, a suitable default is used. The title attribute controls this default - when present, clauses are referred to using their title rather than number. This also applies to examples which are indexed first by their containing clause and then their example number.

    -

    Cross-references to an id check for clauses, productions, examples, and steps in this order. For each type, the local document is consulted before looking for external sources including the default ES6 biblio.

    - -

    Attributes

    -

    href: Optional: URL of the target clause, production, or example to cross-reference.

    -

    title: Optional: If present, xref will be filled in with the referenced clause's title. Otherwise, the clause's section number is used.

    -

    aoid: Optional: aoid of an abstract operation to reference.

    - -

    One of aoid or href must be specified.

    - -

    Example

    -
    <p>The clause element is specified in <emu-xref href="#emu-clause"></emu-xref>.</p>
    -<p>See <emu-xref href="#emu-note" title></emu-xref> for information on the emu-note element.</p>
    -<p>The <emu-xref href="#emu-biblio">biblio element</emu-xref> supports xref to external specs.</p>
    -<p><emu-xref aoid="Get"></emu-xref> is an abstract operation from ES6</p>
    -<p><emu-alg>1. [id="example-step-label"] Example labeled step.</emu-alg></p>
    -<p>You can reference step <emu-xref href="#example-step-label"></emu-xref> like this</p>
    - - Result -

    The clause element is specified in 6.2.

    -

    See emu-note for information on the emu-note element.

    -

    The biblio element will eventually support xref to external specs.

    -

    Get is an abstract operation from ES6

    -

    1. Example labeled step.

    -

    You can reference step 1 like this

    -
    - - -

    12 emu-not-ref

    -

    Suppresses automatic linking to definitions.

    - -

    Example

    -
    <div id="not-ref-section-1">
    -  <p>An <dfn>example</dfn> is used for illustrative purposes.</p>
    -</div>
    -<div id="not-ref-section-2">
    -  <p>When a word defined in another section (or algorithm step) is used, as in this example, it is normally automatically linked to the section containing the definition.</p>
    -  <p>When such a word should not be automatically linked, for <emu-not-ref>example</emu-not-ref> when using its colloquial definition, it can be wrapped with this tag to surpress the automatic linking.</p>
    -</div>
    - - Result -
    -

    An example is used for illustrative purposes.

    -
    -
    -

    When a word defined in another section (or algorithm step) is used, as in this example, it is normally automatically linked to the section containing the definition.

    -

    When such a word should not be automatically linked, for example when using its colloquial definition, it can be wrapped with this tag to surpress the automatic linking.

    -
    -
    - - -

    13 emu-figure

    -

    Creates a figure that can be xrefed by ID using the emu-xref element. Add a caption using a child emu-caption element.

    -

    Attributes

    -

    informative: Optional: If present, the figure is informative. Otherwise it is normative.

    - -

    Example

    -
    <emu-figure>
    -  <emu-caption>Example figure<emu-caption>
    -  [[insert some awesome graphic here, maybe something like figure 2]]
    -</emu-figure>
    -
    Figure 1: Example figure - [[insert some awesome graphic here, maybe something like figure 2]] -
    -
    -
    - - -

    14 emu-table

    -

    Creates a table that can be xrefed by ID using the emu-xref element. Add a caption using a child emu-caption element.

    -

    Attributes

    -

    caption: Optional: Caption for the example

    -

    informative: Optional: If present, the table is informative. Otherwise it is normative.

    - -

    Example

    -
    <emu-table>
    -  <emu-caption>Example table<emu-caption>
    -  <table>
    -    <tr><th>Column 1</th><th>Column 2</th></tr>
    -    <tr><td>Value</td><td>Value 2</td></tr>
    -    <tr><td>Value</td><td>Value 2</td></tr>
    -    <tr><td>Value</td><td>Value 2</td></tr>
    -    <tr><td>Value</td><td>Value 2</td></tr>
    -  </table>
    -</emu-table>
    -
    Table 5: Example table - - - - - - -
    Column 1Column 2
    ValueValue 2
    ValueValue 2
    ValueValue 2
    ValueValue 2
    -
    -
    -
    - - -

    15 emu-example

    -

    Creates an informative example. Examples are numbered based on how many are present in the example's containing clause. Can be xrefed by ID using emu-xref.

    - -

    Attributes

    -

    caption: Optional: Caption for the example

    - -

    Example

    -
    <emu-example caption="Example Example">
    -  This is an example.
    -</emu-example>
    -
    -<emu-example caption="Another Example Example">
    -  This is also an example.
    -</emu-example>
    -
    Example 1 (Informative): Example Example
    - This is an example. -
    - -
    Example 2 (Informative): Another Example Example
    - This is also an example. -
    -
    - -

    16 emu-biblio

    -

    Links a bibliography file. The bibliography file is a JSON document containing URLs for referenced documents along with any algorithms they define.

    - -

    Attributes

    -

    href: Required: URL to the biblio file.

    - -

    Example

    - biblio.json -
    {
    -  "https://tc39.github.io/ecma262/": [
    -    {
    -      "type": "op",
    -      "id": "sec-returnifabrupt",
    -      "aoid": "ReturnIfAbrupt"
    -    },
    -    {
    -      "type": "op",
    -      "id": "sec-get-o-p",
    -      "aoid": "Get"
    -    }
    -  ]
    -}
    - spec.emu -
    <emu-biblio href="./biblio.json"></emu-biblio>
    -<emu-alg>
    -1. let _res_ be Get(_obj_, _key_).
    -2. ReturnIfAbrupt(_res_)
    -</emu-alg>
    - - Result -
    1. let res be Get(obj, key).
    2. ReturnIfAbrupt(res);
    -
    - - -

    17 Specifying Grammar

    -

    There are two ways to specify grammar in Ecmarkup: using the emu-production element and related elements, or by using the emu-grammar element which allows specifying grammar using a plaintext format.

    - -

    Examples

    - WhileStatement -
    <emu-production name="WhileStatement">
    -  <emu-rhs>while ( <emu-nt>Expression</emu-nt> ) <emu-nt>Statement</emu-nt></emu-rhs>
    -</emu-production>
    - - - WhileStatement : while (Expression )Statement - - - ArgumentList -
    <emu-production name="ArgumentList">
    -  <emu-rhs><emu-nt>AssignmentExpression</emu-nt></emu-rhs>
    -  <emu-rhs><emu-nt>ArgumentList</emu-nt> , <emu-nt>AssignmentExpression</emu-nt></emu-rhs>
    -</emu-production>
    - - - ArgumentList : AssignmentExpression - - ArgumentList,AssignmentExpression - - - IterationStatement -
    <emu-production name="IterationStatement">
    -  <emu-rhs>for ( <emu-nt>LexicalDeclaration</emu-nt> ; <emu-nt optional>Expression</emu-nt> ;
    -  <emu-nt optional>Expression</emu-nt> ) <emu-nt>Statement</emu-nt></emu-rhs>
    -</emu-production>
    - - IterationStatement : for (LexicalDeclaration ;Expressionopt ;Expressionopt )Statement - - - Identifier -
    <emu-production name="Identifier" type="lexical">
    -  <emu-rhs><emu-nt>IdentifierName</emu-nt> <emu-gmod>but not
    -  <emu-nt>ReservedWord</emu-nt></emu-gmod></emu-rhs>
    -</emu-production>
    - - Identifier :: IdentifierName but not - ReservedWord - - - SourceCharacter -
    <emu-production name="SourceCharacter" type="lexical">
    -  <emu-rhs><emu-gprose>any Unicode code point</emu-gprose></emu-rhs>
    -</emu-production>
    - - SourceCharacter :: any Unicode code point - - - ExpressionStatement -
    <emu-production name="ExpressionStatement" params="Yield">
    -  <emu-rhs>
    -    <emu-gann>lookahead ∉ {
    -      <emu-t>{</emu-t>,
    -      <emu-t>function</emu-t>,
    -      <emu-t>class</emu-t>,
    -      <emu-t>let [</emu-t>
    -    }</emu-gann>
    -  </emu-rhs>
    -</emu-production>
    - - ExpressionStatement[Yield] : - [lookahead ∉ { - {, - function, - class, - let [ - }] - - - - DecimalDigit -
    <emu-production name="DecimalDigit" type="lexical" oneof>
    -  <emu-rhs>0 1 2 3 4 5 6 7 8 9</emu-rhs>
    -</emu-production>
    - - DecimalDigit :: one of 0 1 2 3 4 5 6 7 8 9 - - - StatementList -
    <emu-production name="StatementList" params="Return, In">
    -  <emu-rhs constraints="~Return"><emu-nt>ReturnStatement</emu-nt></emu-rhs>
    -  <emu-rhs><emu-nt>ExpressionStatement</emu-nt></emu-rhs>
    -</emu-production>
    - - StatementList[Return, In] : [~Return]ReturnStatement - ExpressionStatement - - - -

    17.1 emu-grammar

    -

    Text inside emu-grammar elements is parsed using Grammarkdown. The syntax is essentially identical to the notational conventions in ECMAScript (minus formatting). See the Grammarkdown readme.

    -

    Grammar will be displayed as an "inline" element flowing with text unless it is the immediate child of an emu-clause-like element.

    -

    Attributes

    -

    collapsed: If present, production is displayed in collapsed format with LHS and RHS on the same line.

    -

    collapsed: If present, production is displayed in collapsed format with LHS and RHS on the same line.

    -
    - - -

    17.2 emu-production

    -

    This is the top level element that contains all grammar productions. Each production MUST include at least one right-hand side (see emu-rhs).

    -

    The production will be displayed as an "inline" element flowing with text unless it is the immediate child of an emu-clause-like element or if its containing emu-grammar element is an immediate child of an emu-clause-like element.

    -

    Attributes

    -

    Attributes

    -

    Name: Required. Name of the production (i.e. the non-terminal on the LHS).

    -

    Params: Parameters for this production. Multiple parameters separated by commas.

    -

    Type: Type of production, either "lexical" or "regexp". Default is blank (normal).

    -

    oneof: If present, production is a one-of production. See DecimalDigit example above.

    -

    collapsed: If present, production is displayed in collapsed format with LHS and RHS on the same line.

    -
    - - -

    17.3 emu-rhs

    -

    Describes one right-hand-side alternative of a production. Text nodes inside of an rhs are split on each space and turned into terminals. For example,

    <emu-rhs>a b c</emu-rhs>
    is semantically equivalent to
    <emu-rhs><emu-t>a</emu-t> <emu-t>b</emu-t> <emu-t>c</emu-t>

    -

    Attributes

    -

    constraints: any constraints for this RHS. Multiple constraints separated by commas. See StatementList example above.

    -

    a: Optional alternative id used to reference a particular RHS via emu-prodref. Must be unique for all emu-rhs elements inside an emu-production. Example might be ``.

    -
    - - -

    17.4 emu-nt

    -

    Non-terminal. Alpha characters only.

    -

    Attributes

    -

    Params: Parameters for this production. Multiple parameters separated by commas.

    -

    oneof: If present, production is a one-of production (see DecimalDigit example above).

    -
    - - -

    17.5 emu-t

    -

    Terminal. No attributes available. Mostly don't need to create these elements manually as they are created automatically inside emu-rhs elements.

    -
    - - -

    17.6 emu-gmod

    - -

    Contains well-known modifiers to a right-hand side of a production. The only well-known modifier at present is the "but not" modifier. See the Identifier example above.

    -
    - - -

    17.7 emu-gann

    - -

    Contains well-known annotations to to a right-hand side of a production. The only well-known modifiers at present are "lookahead" and "empty". See the ExpressionStatement example above. Any text inside a gann element is wrapped in square brackets.

    -
    - - -

    17.8 emu-gprose

    -

    Contains any prose text that describes a production. See SourceCharacter example above.

    -
    - - -

    17.9 emu-prodref

    -

    References a production defined elsewhere in the document. Ecmarkup will insert either the entire production or a particular RHS depending on attributes.

    - -

    Attributes

    -

    name: Required. Name of the production to reference.

    -

    a: Optional. If present, specified a particular alternative ID to reference.

    -
    -
    - - -

    18 Imports

    -

    HTML Imports are treated specially in an ecmarkup document. Every import is inlined into its parent document at the location of the import tag. This is useful for breaking your spec document up into many smaller pieces.

    -
    - - -

    19 Other Styles & Conventions

    - -

    19.1 Old IDs

    -

    Old IDs for any element can be stored as a comma-separated list inside an oldids attribute, allowing links using them to continue working as expected.

    -
    - -

    19.2 ins & del

    -

    The ins and del HTML tags can be used to mark insertions and deletions respectively. When adding or removing block content (such as entire list items, paragrpahs, clauses, grammar RHSes, etc.), use a class of "block".

    - -

    Inline Example:

    -
    ECMAScript <del>6</del><ins>2015</ins> <del>will be ratified</del><ins>was ratified</ins> in June, 2015.
    -

    Result:

    -

    ECMAScript 62015 will be ratifiedwas ratified in June, 2015.

    - -

    Block Example:

    -
    <p>|HoistableDeclaration| is modified as follows:</p>
    -<emu-production name="HoistableDeclaration">
    -  <emu-rhs><emu-nt>FunctionDeclaration</emu-nt></emu-rhs>
    -  <emu-rhs><emu-nt>GeneratorDeclaration</emu-nt></emu-rhs>
    -  <ins class="block"><emu-rhs><emu-nt>AsyncFunctionDeclaration</emu-nt></emu-rhs></ins>
    -</emu-production>
    -

    Result:

    -

    HoistableDeclaration is modified as follows:

    - - HoistableDeclaration : FunctionDeclaration - GeneratorDeclaration - AsyncFunctionDeclaration - -
    - -

    19.3 Code Listings

    -

    Create a code listing using <pre><code>. The code element takes a class of javascript, html, or any other language provided by highlightjs. Ecmarkup will trim any leading blank lines and also normalize the indentation based on the indentation of the first line.

    -
    -
    -
    \ No newline at end of file diff --git a/package.json b/package.json index e8e5ff8a..c16af99e 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "build": "tsc -p src -sourceMap", "build-release": "tsc -p src", - "build-spec": "node bin/ecmarkup.js spec/index.html docs/index.html --no-ecma-262-biblio --css-out docs/elements.css --js-out docs/ecmarkup.js", + "build-spec": "mkdir -p docs && node bin/ecmarkup.js spec/index.html docs/index.html --no-ecma-262-biblio --css-out docs/elements.css --js-out docs/ecmarkup.js", "prepack": "safe-publish-latest && npm run build-release", "test": "mocha", "test-baselines": "mocha test/baselines.js", diff --git a/scripts/auto-deploy.sh b/scripts/auto-deploy.sh new file mode 100755 index 00000000..afd4cbd1 --- /dev/null +++ b/scripts/auto-deploy.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +set -euxo pipefail + +declare -r GH_USER_EMAIL="bot@tc39" +declare -r GH_USER_NAME="Bot" +declare -r COMMIT_MESSAGE="Update gh-pages" + +cd "$(dirname "$BASH_SOURCE")"/../docs + +git config --global user.email "${GH_USER_EMAIL}" +git config --global user.name "${GH_USER_NAME}" +git config --global init.defaultBranch gh-pages +git init +git add -A +git commit --message "${COMMIT_MESSAGE}" +git push --force "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" gh-pages