forked from w3c/browser-specs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fetch spec info from W3C API, Specref or the spec
This update adds the logic needed to complete specification metadata with the spec's title (w3c#10) and the TR/ED URLs (w3c#11). This additional information gets fetched from the W3C API when possible, from Specref when the W3C API does not know anything about the spec, or from the spec itself when neither the W3C API nor Specref knows anything about the spec. Fetching logic is in `src/fetch-info.js`. By definition, fetching this information requires sending network requests and, as such, cannot be done in realtime on hundreds of specs. Instead, the commit adds a GitHub action set to run every 6 hours to fetch the information and update the `specs-info.json` file. In turn, this file is imported by the `index.js` script, which now also returns the information. New properties returned for each specification are: - `title`: the title of the spec - `trUrl`: the URL of the TR document for specs published in TR space - `edUrl`: the URL of the latest Editor's Draft when known - `source`: one of `w3c`, `specref`, or `spec` to give the source of the info Other updates: - Refactored JSON schemas in a schema folder with a common `dfns.json` file to avoid duplicating type definitions. - Extended the filtering logic in `index.js` to also look for titles, source, and URLs. Note that the code and the tests now expect to find a `config.json` file in the root folder that contains an object with a `w3cApiKey` property set to a valid W3C API key (this file is *not* part of the commit). Also note that tests current fail if one tries to add a new spec to `specs.json` and does not run `npm run fetch-info`, because the new spec won't have a `title` property, which is defined as `required` in the JSON schema. This means that updates to `specs-info.json` need to be part of pull requests on the repo. Depending on the envisioned workflow for updates (and packaging), we might want to relax that rule later on.
- Loading branch information
Showing
16 changed files
with
643 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
on: | ||
schedule: | ||
- cron: '10 */6 * * *' | ||
push: | ||
branches: | ||
- master | ||
name: Fetch additional spec info from external sources | ||
jobs: | ||
fetch: | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions/setup-node@v1 | ||
with: | ||
node-version: 12.x | ||
- name: Setup environment | ||
run: | | ||
echo "${{ secrets.CONFIG_JSON }}" | base64 --decode > config.json | ||
npm ci | ||
- name: Fetch info | ||
run: npm run fetch-info | ||
- name: Commit updates | ||
run: | | ||
git config user.name "fetch-info bot" | ||
git config user.email "<>" | ||
git commit -m "[data] Update spec info" -a | ||
- name: Push changes | ||
uses: ad-m/github-push-action@v0.5.0 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
node_modules/ | ||
config.json |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema#", | ||
"$id": "https://github.com/w3c/browser-specs/tree/master/schema/dfns.json", | ||
|
||
"dfns": { | ||
"url": { | ||
"type": "string", | ||
"format": "uri" | ||
}, | ||
|
||
"name": { | ||
"type": "string", | ||
"pattern": "^[\\w\\-]+((?<=\\-\\d+)\\.\\d+)?$" | ||
}, | ||
|
||
"shortname": { | ||
"type": "string", | ||
"pattern": "^[\\w\\-]+$" | ||
}, | ||
|
||
"level": { | ||
"type": "number", | ||
"minimum": 1 | ||
}, | ||
|
||
"levelComposition": { | ||
"type": "string", | ||
"enum": ["full", "delta"] | ||
}, | ||
|
||
"forceCurrent": { | ||
"type": "boolean" | ||
}, | ||
|
||
"title": { | ||
"type": "string" | ||
}, | ||
|
||
"source": { | ||
"type": "string", | ||
"enum": ["w3c", "specref", "spec"] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema#", | ||
"$id": "https://github.com/w3c/browser-specs/tree/master/schema/index.json", | ||
|
||
"type": "array", | ||
"items": { | ||
"type": "object", | ||
"properties": { | ||
"url": { "$ref": "dfns.json#/dfns/url" }, | ||
"name": { "$ref": "dfns.json#/dfns/name" }, | ||
"shortname": { "$ref": "dfns.json#/dfns/shortname" }, | ||
"level": { "$ref": "dfns.json#/dfns/level" }, | ||
"levelComposition": { "$ref": "dfns.json#/dfns/levelComposition" }, | ||
"currentLevel": { "$ref": "dfns.json#/dfns/name" }, | ||
"previousLevel": { "$ref": "dfns.json#/dfns/name" }, | ||
"nextLevel": { "$ref": "dfns.json#/dfns/name" }, | ||
"edUrl": { "$ref": "dfns.json#/dfns/url" }, | ||
"trUrl": { "$ref": "dfns.json#/dfns/url" }, | ||
"title": { "$ref": "dfns.json#/dfns/title" }, | ||
"source": { "$ref": "dfns.json#/dfns/source" } | ||
}, | ||
"required": ["url", "name", "shortname", "currentLevel", "title", "source"], | ||
"additionalProperties": false | ||
}, | ||
"minItems": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema#", | ||
"$id": "https://github.com/w3c/browser-specs/tree/master/schema/specs-info.json", | ||
|
||
"type": "object", | ||
"propertyNames": { | ||
"pattern": "^[\\w\\-]+((?<=\\-\\d+)\\.\\d+)?$" | ||
}, | ||
"additionalProperties": { | ||
"type": "object", | ||
"properties": { | ||
"edUrl": { "$ref": "dfns.json#/dfns/url" }, | ||
"trUrl": { "$ref": "dfns.json#/dfns/url" }, | ||
"title": { "$ref": "dfns.json#/dfns/title" }, | ||
"source": { "$ref": "dfns.json#/dfns/source" } | ||
}, | ||
"required": ["title", "source"], | ||
"additionalProperties": false | ||
}, | ||
"minItems": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema#", | ||
"$id": "https://github.com/w3c/browser-specs/tree/master/schema/specs.json", | ||
|
||
"type": "array", | ||
"items": { | ||
"oneOf": [ | ||
{ | ||
"type": "string", | ||
"pattern": "^https://[^\\s]+(\\s(delta|current))?$" | ||
}, | ||
{ | ||
"type": "object", | ||
"properties": { | ||
"url": { "$ref": "dfns.json#/dfns/url" }, | ||
"name": { "$ref": "dfns.json#/dfns/name" }, | ||
"shortname": { "$ref": "dfns.json#/dfns/shortname" }, | ||
"level": { "$ref": "dfns.json#/dfns/level" }, | ||
"levelComposition": { "$ref": "dfns.json#/dfns/levelComposition" }, | ||
"forceCurrent": { "type": "boolean" } | ||
}, | ||
"required": ["url"], | ||
"additionalProperties": false | ||
} | ||
] | ||
}, | ||
"minItems": 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"compat": { | ||
"edUrl": "https://compat.spec.whatwg.org/", | ||
"title": "Compatibility Standard", | ||
"source": "specref" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.