indic-transliteration / sanscript.js

Transliteration package for Indian scripts
MIT License
98 stars 39 forks source link

Add JSON schema and validation script #17

Closed psvenk closed 4 years ago

psvenk commented 4 years ago

Closes #15. This schema is written to fit the current format of JSON scheme descriptions. As discussed in https://github.com/sanskrit/sanscript.js/pull/13, some further work should be done after this PR to improve this format to be more consistent and to capture some of the details that are currently expressed in code (e.g. the definition of the Kolkata scheme and the Brahmic/roman distinction).

psvenk commented 4 years ago

Perhaps we should try to integrate validate.js into the unit tests. I think ajv supports browsers, so we could just load it in test/index.html from node_modules as we load QUnit now.

rramphal commented 4 years ago

Ideally, both the validate and the test steps would be their own build steps runnable via npm scripts. That doesn't mean that we can't also use them within the test/index.html file, though. I think your current approach takes us in the right direction.

psvenk commented 4 years ago

Ideally, both the validate and the test steps would be their own build steps runnable via npm scripts.

I agree. The test script seems to be failing now because QUnit cannot find the definition of the Sanscript object. I see two solutions to this:

As for validation as one of the tests, I now realize that this would not be possible in a browser because filesystem access is needed (unless validate.js goes through a build process that integrates the contents of the JSON files, but that is a lot of complexity for little gain), so it would probably be better just to have validation separate from unit tests (especially considering that the sorts of changes that would trigger errors in each are mostly orthogonal to one another).

psvenk commented 4 years ago

@vvasuki Is this ready to merge?

vvasuki commented 4 years ago

Sure - go for it (generally plz don't wait on me - Some of the tech is new to me, and you seem to have good judgement.)