Skip to content

Commit

Permalink
feat(readme): mention the most common schema version
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff committed Dec 16, 2019
1 parent 70b63c8 commit fc583d7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
21 changes: 20 additions & 1 deletion lib/readmeBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,32 @@
* governing permissions and limitations under the License.
*/
const {
map, pipe, filter, list: flist, mapSort,
map, pipe, filter, list: flist, mapSort, uniq,
} = require('ferrum');
const {
root, paragraph, text, heading, list, listItem, link, inlineCode,
} = require('mdast-builder');
const i18n = require('es2015-i18n-tag').default;
const s = require('./symbols');
const { gentitle, gendescription } = require('./formattingTools');
const { keyword } = require('./keywords');

function makeversionnote(schemas) {
const versions = flist(uniq(schemas
.map(schema => schema[keyword`$schema`])
.filter(e => !!e)));

if (versions.length === 1) {
return [
heading(2, text(i18n`Version Note`)),
paragraph([
text('The schemas linked above follow the JSON Schema Spec version: '),
inlineCode(versions[0]),
]),
];
}
return [];
}

/**
* Generate the README.md
Expand Down Expand Up @@ -64,6 +81,8 @@ function build({ readme = true }) {

heading(3, text('Arrays')),
list('unordered', bytype('array')),

...makeversionnote(schemas),
]);

// console.log(inspect(readmenode));
Expand Down
6 changes: 3 additions & 3 deletions schemasupport.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# JSON Schema Spec Coverage Report

This report lists the keywords of the JSON Schema spec that are covered in the tests. The overall coverage is 82%
This report lists the keywords of the JSON Schema spec that are covered in the tests. The overall coverage is 84%

## The JSON Schema Core Vocabulary

Coverage for [The JSON Schema Core Vocabulary](https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.8.1) is 44%.
Coverage for [The JSON Schema Core Vocabulary](https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.8.1) is 55%.

| Keyword | Supported |
| :----------------- | --------- |
Expand All @@ -15,7 +15,7 @@ Coverage for [The JSON Schema Core Vocabulary](https://json-schema.org/draft/201
| `$recursiveAnchor` | No |
| `$recursiveRef` | No |
| `$ref` | Yes |
| `$schema` | No |
| `$schema` | Yes |
| `$vocabulary` | No |

## A Vocabulary for Applying Subschemas
Expand Down
1 change: 1 addition & 0 deletions test/readmeBuilder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('Testing Readme Builder', () => {

assertMarkdown(result)
.contains('# README')
.contains('The schemas linked above')
.fuzzy`
## Top-level Schemas
Expand Down

0 comments on commit fc583d7

Please sign in to comment.