diff --git a/.gitignore b/.gitignore index 48d140682ba4b8bf55ca2dc8560e77520a7bacda..e6ca6341c84d18fd700bba91eb64a386934f2bad 100644 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,6 @@ npm-debug.log .tool-versions -# instanbul code coverage +# instanbul code coverage… coverage +/examples/tmp-docs diff --git a/examples/docs/README.md b/examples/docs/README.md index fbbb8173f4bdf83e20f0d41740b8ee9d95ae37d4..68536b765875bf0ff6ab2a2181e3cfb33fd2b98c 100644 --- a/examples/docs/README.md +++ b/examples/docs/README.md @@ -3,3 +3,26 @@ # Readme + +## / + +* [Abstract](./abstract.schema.md) – `https://example.com/schemas/abstract` +* [Arrays](./arrays.schema.md) – `https://example.com/schemas/arrays` +* [Complex References ](./complex.schema.md) – `https://example.com/schemas/complex` +* [Constant Types](./constants.schema.md) – `https://example.com/schemas/constants` +* [Custom](./custom.schema.md) – `https://example.com/schemas/custom` +* [Deeply Extending](./deepextending.schema.md) – `https://example.com/schemas/deepextending` +* [Definitions](./definitions.schema.md) – `https://example.com/schemas/definitions` +* [Enumerated ](./enums.schema.md) – `https://example.com/schemas/enums` +* [Example](./example.schema.md) – `https://example.com/schemas/example` +* [Examples](./examples.schema.md) – `https://example.com/schemas/examples` +* [Extending](./extending.schema.md) – `https://example.com/schemas/extending` +* [Extensible](./extensible.schema.md) – `https://example.com/schemas/extensible` +* [Simple](./simple.schema.md) – `https://example.com/schemas/simple` +* [Simple Types](./simpletypes.schema.md) – `https://example.com/schemas/simpletypes` +* [Stabilizing](./stabilizing.schema.md) – `https://example.com/schemas/stabilizing` + +## /subdir/ + +* [Subdir](./subdir/subdir.schema.md) – `https://example.com/schemas/subdir/subdir` + diff --git a/spec/examples/README.md b/spec/examples/README.md index 896a8a1f46598d8b780d61430d8847fb6139a7fb..68536b765875bf0ff6ab2a2181e3cfb33fd2b98c 100644 --- a/spec/examples/README.md +++ b/spec/examples/README.md @@ -25,3 +25,4 @@ ## /subdir/ * [Subdir](./subdir/subdir.schema.md) – `https://example.com/schemas/subdir/subdir` + diff --git a/spec/lib/integrationTest.spec.js b/spec/lib/integrationTest.spec.js index 76afa36ffcc0abe27c37d1a229aae3229628158c..e9952f8fa248a3f4bae17aa736837c7dc3e98476 100644 --- a/spec/lib/integrationTest.spec.js +++ b/spec/lib/integrationTest.spec.js @@ -11,50 +11,28 @@ beforeEach(function() { }); describe('Compare results', () => { - it('Run jsonschema2md on example schemas', done => { + + it('Run jsonschema2md for custom file extension', done => { const ls = spawn('node', [ 'cli.js', '-d', 'examples/schemas', '-o', - 'examples/docs', + 'examples/tmp-docs', '-x', 'examples/generated-schemas', - '-m', - 'template=reference', - '-m', - 'foo=bar', - '--link-abstract', - 'abstract.md', - '--link-status', - 'status.md' + '-e', + 'js' ]); ls.on('close', code => { expect(code).toEqual(0); - - const files = readdirSync('./spec/examples'); - - files.forEach(file => { - if (statSync('./spec/examples/' + file).isFile()) { - it('Comparing ' + file, indone => { - console.log('file ' + file); - readFile('./spec/examples/' + file, (err, expectedbuf) => { - expect(err).toBeNull(); - readFile('./examples/docs/' + file, (err, actualbuf) => { - expect(err).toBeNull(); - expect(actualbuf.toString()).toEqual(expectedbuf.toString()); - indone(); - }); - }); - }); - } - }); done(); }); }); - it('Run jsonschema2md for custom file extension', done => { + + it('Run jsonschema2md on example schemas', done => { const ls = spawn('node', [ 'cli.js', '-d', @@ -63,13 +41,39 @@ describe('Compare results', () => { 'examples/docs', '-x', 'examples/generated-schemas', - '-e', - 'js' + '-m', + 'template=reference', + '-m', + 'foo=bar', + '--link-abstract', + 'abstract.md', + '--link-status', + 'status.md' ]); ls.on('close', code => { expect(code).toEqual(0); + + const files = readdirSync('./spec/examples'); + expect(files.length).toEqual(17); done(); }); }); + + const files = readdirSync('./spec/examples'); + files.forEach(file => { + if (statSync('./spec/examples/' + file).isFile()) { + it('Comparing ' + file, indone => { + console.log('file ' + file); + readFile('./spec/examples/' + file, (err, expectedbuf) => { + expect(err).toBeNull(); + readFile('./examples/docs/' + file, (err, actualbuf) => { + expect(err).toBeNull(); + expect(actualbuf.toString()).toEqual(expectedbuf.toString()); + indone(); + }); + }); + }); + } + }); }); diff --git a/templates/md/readme.ejs b/templates/md/readme.ejs index 7fc4096fc80652425faaee790126c889b47c61d9..a275b9ce43984f5c7199a5c700c83f1e2c8d7dda 100644 --- a/templates/md/readme.ejs +++ b/templates/md/readme.ejs @@ -7,8 +7,9 @@ # Readme -<% for(group in groups) {%> +<% _.forIn(groups, (schemas, group) => { %> ## <%= group %> -<% for(let i=0; i<groups[group].length; i++) { %> -* [<%= groups[group][i].title %>](.<%= groups[group][i].relative %>.schema.md) – `<%= groups[group][i].id %>`<% }} %> +<% _.forEach(_.sortBy(schemas, [o => { return o.title }]), schema => { %> +* [<%= schema.title %>](.<%= schema.relative %>.schema.md) – `<%= schema.id %>`<% }); %> +<% }); %>