Skip to content

Commit

Permalink
Merge branch 'develop' into gh-pages
Browse files Browse the repository at this point in the history
* develop:
  v19.0.2
  ally: don't announce body changed
  fix: dont announce highlights (closes #1456)
  docs(README): combine buttons on one line
  docs(README): add link to developer guide
  chore(package): update mocha to version 5.0.0
  fix(package): update command-line-args to version 5.0.0
  chore(package): update http-server to version 0.11.0
  refactor(ui): rearrange/reword menu items
  fix(ui/dfn-list): broken fragments
  style(core/ui): prettier + cleanup
  refactor(core/remove-respec): remove redudant module
  refactor(js/profile-w3c-common): use async/await
  refactor(core/base-runner): fold in core/remove-respec
  refactor(core/highlight): remove redundant things
  chore(package): update karma to version 2.0.0
  • Loading branch information
marcoscaceres committed Jan 30, 2018
2 parents 55b2ada + 584a852 commit ba3fd63
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 156 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# ReSpec

[![Greenkeeper badge](https://badges.greenkeeper.io/w3c/respec.svg)](https://greenkeeper.io/)

[![Build Status](https://travis-ci.org/w3c/respec.svg?branch=develop)](https://travis-ci.org/w3c/respec)
[![Known Vulnerabilities](https://snyk.io/test/github/w3c/respec/badge.svg)](https://snyk.io/test/github/w3c/respec)
[![Greenkeeper badge](https://badges.greenkeeper.io/w3c/respec.svg)](https://greenkeeper.io/) [![Build Status](https://travis-ci.org/w3c/respec.svg?branch=develop)](https://travis-ci.org/w3c/respec) [![Known Vulnerabilities](https://snyk.io/test/github/w3c/respec/badge.svg)](https://snyk.io/test/github/w3c/respec)

ReSpec is a JS library that makes it easier to write technical specifications, or documents
that tend to be technical in nature in general. It was originally designed for the purpose
Expand Down Expand Up @@ -46,4 +43,7 @@ Bibliographical references have been moved out of ReSpec. You want to use
[Documentation for ReSpec](https://github.com/w3c/respec/wiki) is available in our wiki.

## Contribute

Please see our [developer guide](https://github.com/w3c/respec/wiki/Developers-Guide).

Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
12 changes: 6 additions & 6 deletions builds/respec-w3c-common.build.js.map

Large diffs are not rendered by default.

90 changes: 45 additions & 45 deletions builds/respec-w3c-common.js

Large diffs are not rendered by default.

33 changes: 13 additions & 20 deletions js/profile-w3c-common.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
// In case everything else fails, we want the error
window.addEventListener("error", function(ev) {
window.addEventListener("error", ev => {
console.error(ev.error, ev.message, ev);
});

Expand Down Expand Up @@ -61,10 +61,10 @@ define(
"core/id-headers",
"core/rdfa",
"core/location-hash",
"ui/about-respec",
"ui/dfn-list",
"ui/save-html",
"ui/search-specref",
"ui/dfn-list",
"ui/about-respec",
"core/seo",
"w3c/seo",
"core/highlight",
Expand All @@ -74,24 +74,17 @@ define(
/*Linter must be the last thing to run*/
"core/linter",
],
function(domReady, runner, ui) {
ui = ui.ui;
var args = Array.from(arguments).filter(function(item) {
return item;
});
(domReady, runner, { ui }, ...plugins) => {
ui.show();
domReady(function() {
runner
.runAll(args)
.then(document.respecIsReady)
.then(function() {
ui.enable();
})
.catch(function(err) {
console.error(err);
// even if things go critically bad, we should still try to show the UI
ui.enable();
});
domReady(async () => {
try {
await runner.runAll(plugins);
await document.respecIsReady;
} catch (err) {
console.error(err);
} finally {
ui.enable();
}
});
}
);
28 changes: 14 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "respec",
"version": "19.0.1",
"version": "19.0.2",
"license": "W3C",
"description": "A technical specification pre-processor.",
"engines": {
Expand Down Expand Up @@ -29,11 +29,11 @@
"eslint-plugin-jasmine": "^2.9.1",
"glob": "^7.1.2",
"handlebars": "^4.0.11",
"http-server": "^0.10.0",
"jasmine-core": "^2.8.0",
"jasmine-reporters": "^2.2.1",
"jquery": "^3.2.1",
"karma": "^1.7.1",
"http-server": "^0.11.0",
"jasmine-core": "^2.9.1",
"jasmine-reporters": "^2.3.0",
"jquery": "^3.3.1",
"karma": "^2.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-detect-browsers": "^2.2.6",
"karma-edge-launcher": "^0.4.2",
Expand All @@ -46,11 +46,11 @@
"karma-safari-launcher": "^1.0.0",
"karma-safaritechpreview-launcher": "0.0.6",
"karma-verbose-summary-reporter": "0.0.1",
"mocha": "^4.0.1",
"moment": "^2.19.4",
"mocha": "^5.0.0",
"moment": "^2.20.1",
"requirejs": "^2.3.5",
"text": "github:requirejs/text",
"uglify-es": "^3.2.2",
"uglify-es": "^3.3.9",
"url-search-params": "^0.10.0",
"webidl2": "^5.0.0"
},
Expand All @@ -76,19 +76,19 @@
},
"dependencies": {
"colors": "^1.1.2",
"command-line-args": "^4.0.7",
"command-line-usage": "^4.0.2",
"command-line-args": "^5.0.0",
"command-line-usage": "^4.1.0",
"epipebomb": "^1.0.0",
"express": "^4.16.2",
"fs-extra": "^5.0.0",
"highlight.js": "github:marcoscaceres/highlight.js",
"hyperhtml": "^2.4.3",
"hyperhtml": "^2.5.4",
"loading-indicator": "^2.0.0",
"marcosc-async": "^4.0.3",
"marked": "^0.3.7",
"marked": "^0.3.12",
"nightmare": "^2.10.0",
"prompt": "^1.0.0",
"snyk": "^1.59.0"
"snyk": "^1.69.5"
},
"snyk": true
}
2 changes: 0 additions & 2 deletions src/core/aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ sub(
"end-all",
() => {
document.body.setAttribute("aria-busy", "false");
document.body.removeAttribute("aria-live");
},
{ once: true }
);

export function run(conf, doc, cb) {
doc.body.setAttribute("aria-busy", "true");
doc.body.setAttribute("aria-live", "polite");
cb();
}
5 changes: 3 additions & 2 deletions src/core/base-runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// The module in charge of running the whole processing pipeline.
import "core/include-config";
import "core/override-configuration";
import "core/remove-respec";
import "core/respec-ready";
import { removeReSpec } from "core/utils";
import { done as postProcessDone } from "core/post-process";
import { done as preProcessDone } from "core/pre-process";
import { pub } from "core/pubsubhub";
Expand Down Expand Up @@ -53,7 +53,7 @@ export async function runAll(plugs) {
performance.mark(name + "-start");
}
await preProcessDone;
const runnables = plugs.filter(plug => plug.run).map(toRunnable);
const runnables = plugs.filter(plug => plug && plug.run).map(toRunnable);
for (const task of runnables) {
try {
await task(respecConfig);
Expand All @@ -64,6 +64,7 @@ export async function runAll(plugs) {
pub("plugins-done", respecConfig);
await postProcessDone;
pub("end-all", respecConfig);
removeReSpec(document);
if (canMeasure) {
performance.mark(name + "-end");
performance.measure(name, name + "-start", name + "-end");
Expand Down
23 changes: 11 additions & 12 deletions src/core/highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,41 @@
* Performs syntax highlighting to all pre and code elements.
*/
import ghCss from "deps/text!core/css/github.css";
import { pub, sub } from "core/pubsubhub";
import { worker } from "core/worker";

export const name = "core/highlight";

// Opportunistically insert the style into the head to reduce FOUC.
const codeStyle = document.createElement("style");
codeStyle.textContent = ghCss;
document.head.appendChild(codeStyle);
let idCounter = 0;
function getLanguageHint(classList) {
return Array.from(classList)
.filter(item => item !== "highlight" && item !== "nolinks")
.map(item => item.toLowerCase());
}

export async function run(conf) {
// Nothing to do
// Nothing to highlight
if (conf.noHighlightCSS) {
codeStyle.remove();
return;
}
const highlightables = Array.from(
document.querySelectorAll("pre:not(.idl):not(.nohighlight), code.highlight")
);
if (!highlightables.length) {
// Nothing to highlight
if (highlightables.length === 0) {
codeStyle.remove();
return;
}
const promisesToHighlight = highlightables.map(element => {
const promisesToHighlight = highlightables.map((element, i) => {
return new Promise(resolve => {
if (element.textContent.trim() === "") {
return resolve(element); // no work to do
return resolve(); // no work to do
}
const done = () => {
element.setAttribute("aria-busy", "false");
resolve(element);
resolve();
};
// We always resolve, even if we couldn't actually highlight
const timeoutId = setTimeout(() => {
Expand All @@ -48,12 +48,9 @@ export async function run(conf) {
const msg = {
action: "highlight",
code: element.textContent,
id: "highlight:" + idCounter++,
id: `highlight:${i}`,
languages: getLanguageHint(element.classList),
};
element.setAttribute("aria-busy", "true");
element.setAttribute("aria-live", "polite");
worker.postMessage(msg);
worker.addEventListener("message", function listener(ev) {
const { data: { id, code, language, value } } = ev;
if (id !== msg.id) {
Expand All @@ -70,6 +67,8 @@ export async function run(conf) {
worker.removeEventListener("message", listener);
done();
});
element.setAttribute("aria-busy", "true");
worker.postMessage(msg);
});
});
await Promise.all(promisesToHighlight);
Expand Down
8 changes: 4 additions & 4 deletions src/core/l10n.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ if (html && !html.hasAttribute("lang")) {

// We use en-US as the base
const base = {
about_respec: "About ReSpec",
about_respec: "About",
abstract: "Abstract",
author: "Author:",
authors: "Authors:",
bug_tracker: "Bug tracker:",
close_parens: ")",
commit_history: "Commit history",
definition_list: "Definition List",
definition_list: "Definitions",
editor: "Editor:",
editors_note: "Editor's note",
editors: "Editors:",
Expand All @@ -44,7 +44,7 @@ const base = {
participate: "Participate",
references: "References",
save_as: "Save as",
save_snapshot: "Save Snapshot",
save_snapshot: "Export",
search_specref: "Search Specref",
sotd: "Status of This Document",
table_of_fig: "Table of Figures",
Expand Down Expand Up @@ -97,7 +97,7 @@ const ja = {
};

const nl = {
about_respec: "Over ReSpec",
about_respec: "Over",
abstract: "Samenvatting",
author: "Auteur:",
authors: "Auteurs:",
Expand Down
13 changes: 0 additions & 13 deletions src/core/remove-respec.js

This file was deleted.

36 changes: 15 additions & 21 deletions src/core/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,13 @@ function ariaDecorate(elem, ariaMap) {
if (!elem) {
return;
}
Array.from(ariaMap.entries()).reduce(function(elem, nameValue) {
const name = nameValue[0];
const value = nameValue[1];
Array.from(ariaMap.entries()).reduce((elem, [name, value]) => {
elem.setAttribute("aria-" + name, value);
return elem;
}, elem);
}

const $respecUI = $(
"<div id='respec-ui' class='removeOnSave' hidden></div>"
);
const $respecUI = $("<div id='respec-ui' class='removeOnSave' hidden></div>");
const $menu = $(
"<ul id=respec-menu role=menu aria-labelledby='respec-pill' hidden></ul>"
);
Expand All @@ -50,14 +46,14 @@ const buttons = {};

sub(
"start-all",
function() {
() => {
document.body.insertAdjacentElement("afterbegin", $respecUI[0]);
},
{ once: true }
);
sub(
"end-all",
function() {
() => {
document.body.insertAdjacentElement("afterbegin", $respecUI[0]);
},
{ once: true }
Expand All @@ -67,24 +63,21 @@ const $respecPill = $("<button id='respec-pill' disabled>ReSpec</button>");
$respecPill
.click(function(e) {
e.stopPropagation();
if( $menu[0].hidden ){
if ($menu[0].hidden) {
$menu[0].classList.remove("respec-hidden");
$menu[0].classList.add("respec-visible");
} else {
$menu[0].classList.add("respec-hidden");
$menu[0].classList.remove("respec-visible");
}
this.setAttribute("aria-expanded", String($menu[0].hidden));
$menu[0].hidden = !$menu[0].hidden
$menu[0].hidden = !$menu[0].hidden;
})
.appendTo($respecUI);
document.documentElement.addEventListener("click", function() {
if(!$menu[0].hidden){
if (!$menu[0].hidden) {
$menu[0].classList.remove("respec-visible");
$menu[0].classList.add("respec-hidden");
$menu[0].addEventListener("transitionend", ()=>{
debugger
})
$menu[0].hidden = true;
}
});
Expand Down Expand Up @@ -226,10 +219,10 @@ export const ui = {
errWarn(msg, warnings, "warning", "Warnings");
},
closeModal: function(owner) {
if ($overlay){
if ($overlay) {
$overlay[0].classList.remove("respec-show-overlay");
$overlay[0].classList.add("respec-hide-overlay");
$overlay[0].addEventListener("transitionend", ()=>{
$overlay[0].addEventListener("transitionend", () => {
$overlay.remove();
$overlay = null;
});
Expand Down Expand Up @@ -257,11 +250,12 @@ export const ui = {
const ariaMap = new Map([["labelledby", headingId]]);
ariaDecorate($modal[0], ariaMap);
$modal.find(".inside").append(content);
$("body").append($overlay).append($modal);
$overlay
.click(()=>{
this.closeModal(currentOwner);
});
$(document.body)
.append($overlay)
.append($modal);
$overlay.click(() => {
this.closeModal(currentOwner);
});
$overlay[0].classList.toggle("respec-show-overlay");
$modal[0].hidden = false;
},
Expand Down

0 comments on commit ba3fd63

Please sign in to comment.