Add jq language#5233
Conversation
|
Hi, I will probably need some help with heuristics to distinguish between jsoniq and jq, they both use |
c693000 to
305ee86
Compare
|
Nice work on tests for this repo 👍 catches a lot of things! |
There was a problem hiding this comment.
Shouldn't this be
| Jq: | |
| JQ: |
instead?
There was a problem hiding this comment.
Can do, what is the convention? i think jq commonly is all lowercase but it seems the yml file uses captial keys?
There was a problem hiding this comment.
If a language's name uses non-standard or unusual casing (as jq does), then we use that; otherwise, Label Case is used (unless it's an obvious acronym, like HTML).
Aside from renaming the YAML entry, the samples/Jq directory will need to be renamed to use the updated capitalisation. Now, committing this might be tricky if you're using an OS with a case-insensitive filesystem (e.g., macOS). Running the following commands from the root of your fork should do the trick:
git config --local --add core.ignorecase false
git mv samples/Jq samples/JQThere was a problem hiding this comment.
Bloody hell, I gave you the wrong capitalisation. 😰 That last line should have been
git mv samples/Jq samples/jqSo you'll now have to run
git mv samples/JQ samples/jqApologies for the screw-up. 😞
There was a problem hiding this comment.
No worries, should be "jq" as yml key also?
There was a problem hiding this comment.
Sorry, I missed that last question.
Yes. Everywhere the language's name appears should match the exact characters used in languages.yml: Heuristics, tests, the name of the samples/ subdirectory, the grammar-index, etc.
The only exception to this is the F* language, which necessitated a new field that allowed us to use filename-safe characters for `./samples/Fstar/. However, this is an edge-case, and one you'll almost certainly never have to worry or care about.
There was a problem hiding this comment.
Ok, i assumed so, so already changed it
|
Just curious, i haven't specified a path to the syntax file in the submodule, will be derived automatically somehow? |
Aye. This should give you the gist of where Linguist looks for grammar files.
Are you sure that's for a different format also named JQ? If not, we can use the JSONIQ repository's existing |
3c36bd7 to
9503e1d
Compare
They have similar syntax and similar uses so not surprised it's confusing :) It's probably the reason linguist current is mis-detect some jq syntax as JSONIQ. Compare: So not sure what to do about the scope name, not great. Would be good in the future to be able to point the vendor submodule to a syntax file used for vscode/atom etc but extensions for them seem to use |
|
Do we have to add some heuristics because they are so similar? |
78d995a to
c3df97f
Compare
I'd submit a PR to the JSONiq repository to change the scope-name to |
I think so. Try |
Mm 😞 i guess they picked it based on extension name, both use .jq 😄 |
|
Some unique things for JSONIQ, uses |
That's fine. We don't need heuristics to be exhaustive and airtight, unless we're distinguishing between very similar languages (e.g., C / C++ / Objective-C / Objective C++). Otherwise, a heuristic need only match commonly-encountered constructs that cover the lion's share of real-world uses, and do so accurately. Don't forget, there's still the classifier to fall back on when heuristics (and every other strategy) fails to match a language. |
|
@Alhadis let me know when i should update things. I guess we should merge a rename and update of JSONiq submodule first? |
|
@wader See wcandillon/language-jsoniq#24. I couldn't resist fixing some glaring mistakes in the JSONiq grammar (though I left the XQuery grammar alone). We'll wait for it to get merged, then we can bump the grammar. 👍 |
Ok 👍 does the jq grammar look ok? i've noticed that it do allow quite a lot of things that are not valid jq, eg I noticed a merge commit got pushed, should i stay away from rebasing and just add more commits now? |
Aye, you'll want to update your branch locally by pulling from https://github.com/wader/linguist/tree/jq. 😉
That's fine. 👍 Syntax highlighting isn't the place for validating semantics; only stuff that's clearly illegal syntax really deserves to be marked as an error. |
|
Created a PR with the fixes wader/language-jq#4 |
|
@AlaineN Is linguist used in highlight code in github flavoured markdown? |
I think you may be intending to tag someone else. |
Alright, two things:
|
Oj sorry for that, not sure how your name got into the auto completer |
She's a GitHub staff member, and Linguist is hosted on the @github org, so... I imagine that's all it takes to be listed as an autocomplete suggestion. |
|
Getting close to merge? what happens after merge, will take some time until used by official github and jq-files being detected as jq? |
Hey @wader, sorry for the slow response. Yes, this LGTM. 👍 As for merging, changes made to Linguist only take effect on GitHub once there's been a new release of Linguist. Hence you won't see the improved highlighting on the site straight away. I should also point out that approval from a GitHub staff member is required before changes can be made to a production dependency, so we need to wait for @lildude to give his 👍 of approval. |
|
Ok! and as i understand submodules are updated regularly in linguist so no need to send PR if the syntax is updated? And thanks again for all the help! |
Grammars are all bumped to the latest versions right before a release is cut. Only in peculiar scenarios (such as this one) is it necessary to manually bump a grammar ourselves. |
https://stedolan.github.io/jq/
Description
Language color is based on code example color from jq documentation.
Checklist: