Skip to content

Commit

Permalink
[Framework] Custom maturity icons for evergreen/informative specs (#265)
Browse files Browse the repository at this point in the history
Features initially proposed in #90.

W3C specs are automatically flagged as informative when they contain only
informative content or when they will be (or have been) published as a Note.

Specs can also be flagged as "evergreen", which means that, regardless of their
exact status on the Rec-track (or elsewhere), they can be considered fit for
reference. This is roughly equivalent to the notion of a Living Standard in
WHATWG.

These settings are used to adjust the maturity icon being rendered. Notably:
- regardless of their exact maturity status, evergreen specs use a green "REF"
(for "Reference") icon.
- informative icons are in dark grey to convey the fact that the spec does not
define normative content.

Note these colors do not match those proposed in the initial issue. This can be
adjusted later on if needed.
  • Loading branch information
tidoust authored and xfq committed Jun 21, 2018
1 parent 2934e92 commit f7b9673
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 8 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ Depending on the advancement of the underlying specification, the JSON object ca
* `edDraft`: when the specification is unknown to the [W3C API](https://w3c.github.io/w3c-api/) and to [Specref](https://www.specref.org/), or when these APIs do not know the URL of the Editor's Draft for the specification, the `edDraft` property should contain the URL of the Editor's Draft of the specification.
* `wgs`: when the specification is unknown to the [W3C API](https://w3c.github.io/w3c-api/) and to [Specref](https://www.specref.org/), the `wgs` property should be an array of objects describing the groups that are producing the spec; each such object should have a `url` property with a link to the group's home page, and a `label` property with the name of the group.
* `publisher`: the organization that published the specification. The framework automatically computes the publisher for W3C, WHATWG, and IETF specifications.
* `informative`: when the specification is unknown to the [W3C API](https://w3c.github.io/w3c-api/), set the `informative` property to `true` to tell the framework that it only contains informative content or that it will be (or has been) published as a Group Note and not as a Recommendation.
* `evergreen`: from time to time, specifications remain as drafts indefinitely but are continuously updated and can be considered stable whenever a new version is published. Set the `evergreen` property to `true` when the specification can always be used as a reference, no matter where it is on the Recommendation track.

Here is an example of a JSON file that describes the "Intersection Observer" specification:
```json
Expand Down
25 changes: 19 additions & 6 deletions js/generate-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const createSpecCell = function (column, featureId, featureName, specInfo, implI
const createMaturityCell = function (column, featureId, featureName, specInfo, implInfo, translate, lang, pos) {
// Render maturity info
let cell = document.createElement('td');
let maturityInfo = maturityData(specInfo);
let maturityInfo = maturityData(specInfo, translate);
fillCell(cell, maturityInfo.maturity, maturityInfo.maturityIcon);
cell.classList.add('maturity');
return cell;
Expand Down Expand Up @@ -388,16 +388,29 @@ const fillCell = function (el, data, image) {
};


const maturityData = function (spec) {
const maturityData = function (spec, translate) {
let iconSrc =
'https://www.w3.org/2013/09/wpd-rectrack-icons/' +
(spec.evergreen ? 'REF' : spec.status).toLowerCase() +
(spec.informative ? '-informative' : '') +
'.svg';
let label =
(spec.evergreen ? 'REF' : spec.status) +
(spec.informative ? ' - informative' : '');
let localizedLabel =
translate('maturity', spec.evergreen ? 'REF' : spec.status) +
(spec.informative ?
translate('maturity', ' - ') + translate('maturity', 'informative') :
'');
return {
maturity: {
label: spec.status,
label: label,
localizedLabel: localizedLabel,
level: maturityLevels[spec.status] || 'low'
},
maturityIcon: !spec.status ? null : {
src: 'https://www.w3.org/2013/09/wpd-rectrack-icons/' +
spec.status.toLowerCase() + '.svg',
alt: spec.status,
src: iconSrc,
alt: localizedLabel,
width: 50,
height: 50
}
Expand Down
11 changes: 11 additions & 0 deletions js/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,16 @@
"qq": "QQ Browser",
"samsunginternet": "Samsung Internet",
"uc": "UC Browser"
},
"maturity": {
"ED": "Editor's Draft",
"WD": "Working Draft",
"LS": "Living Standard",
"CR": "Candidate Recommendation",
"PR": "Proposed Recommendation",
"REC": "Recommendation",
"Retired": "Retired",
"NOTE": "Group Note",
"REF": "Reference"
}
}
6 changes: 4 additions & 2 deletions tools/extract-spec-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ async function extractSpecData(files, config) {
edDraft: latestInfo['editor-draft'],
title: latestInfo.title,
status: latestInfo.status,
publisher: 'W3C'
publisher: 'W3C',
informative: latestInfo.informative || !latestInfo['rec-track']
};
let deliverersJson = await fetchJson(
latestInfo._links.deliverers.href + `?embed=1`,
Expand All @@ -283,7 +284,8 @@ async function extractSpecData(files, config) {
title: spec.data.title || trInfo.title || lookupInfo.title,
status: spec.data.status || trInfo.status || lookupInfo.status || 'ED',
deliveredBy: spec.data.wgs || trInfo.deliveredBy || lookupInfo.deliveredBy || [],
publisher: spec.data.publisher || trInfo.publisher || lookupInfo.publisher
publisher: spec.data.publisher || trInfo.publisher || lookupInfo.publisher,
informative: spec.data.informative || trInfo.informative
};

// Spec must have a title, either retrieved from Specref or defined in
Expand Down
8 changes: 8 additions & 0 deletions tools/spec.jsons
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@
"description": "The URL of the Living Standard. Deprecated. Use `url` instead.",
"type": "string",
"format": "uri"
},
"evergreen": {
"description": "The spec may be a draft but is continuously updated and suitable for use as reference.",
"type": "boolean"
},
"informative": {
"description": "The spec contains only informative content or is/will be published as a Note.",
"type": "boolean"
}
}
}
8 changes: 8 additions & 0 deletions tools/tr.jsons
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
"description": "The organization that published the specification.",
"type": "string",
"minLength": 1
},
"evergreen": {
"description": "The spec may be a draft but is continuously updated and suitable for use as reference.",
"type": "boolean"
},
"informative": {
"description": "The spec contains only informative content or is/will be published as a Note.",
"type": "boolean"
}
}
}
Expand Down

0 comments on commit f7b9673

Please sign in to comment.