aerhard / linter-autocomplete-jing

Jing-based autocomplete and validation of XML documents in Atom
https://atom.io/packages/linter-autocomplete-jing
MIT License
19 stars 3 forks source link

supports external schema files based on filename #28

Closed philschatz closed 8 years ago

philschatz commented 8 years ago

(posted as Work in Progress to get feedback on the approach)

This fixes #26 by reading a new entry in ~/.atom/config.cson:

"linter-autocomplete-jing":
  rules: [
    {
      testPathRegex: ".cnxml$"
      outcomeSchemaProps: {
        lang: "rng"
        path: "/path/to/cnxml-jing.rng"
      }
    }

Additionally, if your file extension is not recognized by Atom as an XML file then you will need to add an entry similar to:

"*":
  core:
    customFileTypes:
      "text.xml": [ "index.cnxml" ]

Screenshot

Install Instructions

git clone https://github.com/philschatz/linter-autocomplete-jing`
cd linter-autocomplete-jing
git checkout external-schema-file
apm link .
npm run-script watch
# restart atom

TODO

aerhard commented 8 years ago

Hi Phil, thank you for the PR! You don't have to worry about rootNs -- there's already an implementation of a rule processor at https://github.com/aerhard/linter-autocomplete-jing/pull/25 which takes path regex, rootNs etc into account and also supports pre-parsing / caching the rules. Would you like to merge that branch into yours? What's missing is that the rules from the config need to get fed into the rule processor. You could achieve that in src/main.js by inserting something like this

if (key === 'rules') {
  parsedRules = ruleProcessor.parse(value);
  return;
}

at the start of setLocalConfig (https://github.com/aerhard/linter-autocomplete-jing/blob/feature/validation-config/src/main.js#L45). Would that make sense?

That's a nice graphic -- should we add the animated GIF file to README.md?

aerhard commented 8 years ago

I'm going to publish version 0.6.0 of the package (containing a couple of bug fixes and new features) so in order to include both config and external package based approaches I've merged your changes with the other commits, see https://github.com/aerhard/linter-autocomplete-jing/tree/external-schema-file -- do you have any additions or comments?

philschatz commented 8 years ago

🎉 Thanks! that should work for our use-case (and hopefully others)

aerhard commented 8 years ago

great, thanks!